Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2225448
  • 博文数量: 668
  • 博客积分: 10016
  • 博客等级: 上将
  • 技术积分: 8588
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-29 19:22
文章分类

全部博文(668)

文章存档

2011年(1)

2010年(2)

2009年(273)

2008年(392)

分类:

2008-08-27 16:11:28

5.创建相关配置文件

 [root@localhost root]# tree

.

|-- bin

|-- dev

|-- etc

|   |-- fstab

|   |-- init.d

|   |   `-- rcS

|   |-- inittab

|   `-- resolv.conf

|-- home

|-- lib

|   |-- ld-2.3.2.so

|   |-- ld-linux.so.2 -> ld-2.3.2.so

|   |-- libc-2.3.2.so

|   |-- libc.so.6 -> libc-2.3.2.so

|   |-- libcap.so.1 -> libcap.so.1.10

|   |-- libcap.so.1.10

|   |-- libcom_err.so.2 -> libcom_err.so.2.0

|   |-- libcom_err.so.2.0

|   |-- libcrypt-2.3.2.so

|   |-- libcrypt.so.1 -> libcrypt-2.3.2.so

|   |-- libcrypto.so.0.9.7a

|   |-- libcrypto.so.4 -> libcrypto.so.0.9.7a

|   |-- libdl-2.3.2.so

|   |-- libdl.so.2 -> libdl-2.3.2.so

|   |-- libgcc_s-3.3.so.1

|   |-- libgcc_s.so.1 -> libgcc_s-3.3.so.1

|   |-- libm-2.3.2.so

|   |-- libm.so.6 -> libm-2.3.2.so

|   |-- libnss_dns-2.3.2.so

|   |-- libnss_dns.so.2 -> libnss_dns-2.3.2.so

|   |-- libnss_files-2.3.2.so

|   |-- libnss_files.so.2 -> libnss_files-2.3.2.so

|   |-- libpthread-0.10.so

|   |-- libpthread.so.0

|   |-- libresolv-2.3.2.so

|   |-- libresolv.so.2 -> libresolv-2.3.2.so

|   |-- libtermcap.so.2 -> libtermcap.so.2.0.8

|   |-- libtermcap.so.2.0.8

|   `-- modules

|       `-- 2.6.14.7

|-- linuxrc

|-- mnt

|-- proc

|-- root

|-- sbin

|-- sys

|-- tmp

|-- usr

|   |-- bin

|   |-- etc

|    `--  profile

|    `-- rc.local

|   |-- lib

|   `-- sbin

`-- var

 

5.1.创建 linuxrc 文件

*这里需要注意一点的是,只要 install busybox,我们根文件系统下先前建好的 linuxrc 就会被覆盖为一同名二进制文件。所以如果事先已做好了自己的 linuxrc,备份我们自己的 linuxrc,在安装完 busybox 后,将 linuxrc 复制回去就好

5.1.1 创建 linuxrc,加入如下内容:

[root@localhost root]# vi linuxrc

#!/bin/sh    //注:在此bin下必须有sh命令

 

#/bin/mount -n -t proc none /proc  #

/bin/mount -n -t sysfs none /sys    #挂载/syssysfs文件系统

/bin/mount -n -t tmpfs none /tmp  #挂载/tmptmpfs文件系统

/bin/mount -n -t ramfs ramfs /mnt   #挂载/mntramfs文件系统

/bin/mount -t ramfs ramfs /var

#/bin/mount -n -t tmpfs tmpfs /dev/shm

exec /sbin/init

 

另我们也可根据须要添加以下项

/sbin/insmod -f /lib/yaffs.o  ?

由于我这里用到了YAFFS系统, 故将yaffs.o考到root_fs/lib之下
/bin/mount -t  yaffs /dev/mtdblock/4   /usr  ?

/bin/cp ­a /mnt/etc/* /etc

echo "re­create the /etc/mtab entries"

# re­create the /etc/mtab entries

/bin/mount ­f ­t cramfs ­o remount,ro /dev/mtdblock/3 /

5.1.2修改权限

[arm@localhost my_rootfs]#chmod 775 linuxrc

[arm@localhost my_rootfs]#ls linuxrc ­al

­rwxrwxr­x  1 root root  533 Jun  4 11:19 linuxrc

当编译内核时,指定命令行参数如下

Boot options  ­­­> Default kernel command string: 我的命令行参数如下

noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200

其中的 init 指明 kernel 执行后要加载的第一个应用程序,缺省为/sbin/init,此处指定为/linuxrc

4.       编写 inittab文件

[root@localhost etc]# vi inittab

# This is run first except when booting

::sysinit:/etc/init.d/rcS    //指定系统初始化脚本文件

 

# Start an "askfirst" shell on the console

::askfirst:/bin/sh        //指定一个登陆的shell (注意,这里如果用gettyminigetty代替sh,那么shell就会等待用户登录,而不会直接进入shell)

 

# Stuff to do when restarting the init process

::restart:/sbin/init    //指定系统重启时执行的初始化程序

 

#::once:/usr/sbin/inetd

::once:/usr/etc/rc.local   //指定首次执行的脚本文件

 

# Stuff to do before rebooting

#::ctrlaltdel:/sbin/reboot         //指定当按下ctrl+alt+del键时执行的命令,嵌入式中不用。

::shutdown:/bin/umount -a –r    //指定关机时执行的操作

 

/etc/下面须有init.d/rcS,
  passwd,  group, fstab
  至于是否是非要这几个文件不可, 还有待考证,我做的文件系统就没要它。
 

[root@localhost etc]# vi init.d/rcS

#! /bin/sh

 

echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"

echo "^     Welcome to YAFFS root filesystem!   ^"

echo "^                                         ^"

echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"

 

PATH=/sbin:/bin:/usr/sbin:/usr/bin

runlevel=S

prevlevel=N

umask 022

export PATH runlevel prevlevel

 

#

#       Trap CTRL-C &c only in this shell so we can interrupt subprocesses.

#

trap ":" INT QUIT TSTP

 

 

/bin/mount –a   //将调用fstab文件执行

/bin/mkdir -p /var/tmp

/bin/mkdir -p /var/run

/bin/mkdir -p /var/log

/bin/mkdir -p /var/lock

/bin/mkdir -p /var/lib

 

#/etc/rc.d/init.d/netd start

#/etc/rc.d/init.d/httpd start

 

/bin/hostname -F /etc/sysconfig/HOSTNAME(这句很明显配置hostname ,要不要随你)
#
/bin/mount -o remount,rw  /

5.3
fstab ------->
none          /proc           proc      defaults    0   0
none         /dev/pts         devpts    mode=0622     0    0
tmpfs        /dev/shm         tmpfs     defaults      0    0

[root@localhost etc]# vi ../usr/etc/rc.local

#!/bin/sh

. /usr/etc/profile

 

/sbin/ifconfig lo 127.0.0.1 up

#/sbin/ifconfig eth0 192.168.2.223 netmask 255.255.255.0 up

#/bin/route add default gw 192.168.2.1 eth0

#/sbin/inetd

#/usr/sbin/makelinks

#source /.bashrc

/bin/ln -s /dev/sound/dsp /dev/dsp

/bin/ln -s /dev/sound/mixer /dev/mixer

 

 

/bin/mkdir /mnt/udisk

/bin/mkdir /mnt/sdcard


[root@localhost etc]# vi ../usr/etc/profile

# Ash profile

# vim: syntax=sh

 

# No core files by default

 

#/bin/mkdir /dev/bus/usb

ulimit -S -c 0 > /dev/null 2>&1

 

 

#USER="`id -un`"

LOGNAME=$USER

PS1='[\u@\h \W]\$ '

PATH=$PATH

LD_LIBRARY_PATH=/lib:/usr/lib

 

HOSTNAME=`/bin/hostname`

 

export USER LOGNAME PS1 PATH LD_LIBRARY_PATH

 

创建dev目录下相关连接文件

所有节点添加相应驱动才有的。

/bin/ln -s /dev/sound/dsp /dev/dsp    音频播放须要用到的设备节点

/bin/ln -s /dev/sound/mixer /dev/mixer  音频播放须要用到的设备节点

/bin/ln -s /dev/misc/rtc /dev/rtc

/bin/ln -s /dev/vc/0 /dev/tty0

/bin/ln -s /dev/vc/1 /dev/tty1

/bin/ln -s /dev/vc/2 /dev/tty2

/bin/ln -s /dev/tts/0 /dev/ttyS0

阅读(916) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~