文件系统的制作和加载过程,网上有很多优秀的博文,我就不多说了。只是对其中一些地方存在一点疑惑
1、文件系统的linuxrc文件
When using initrd, the system typically boots as follows:
1) the boot loader loads the kernel and the initial RAM disk
2) the kernel converts initrd into a "normal" RAM disk and
frees the memory used by initrd
3) initrd is mounted read-write as root
4) /linuxrc is executed (this can be any valid executable, including
shell scripts; it is run with uid 0 and can do basically everything
init can do)
5) linuxrc mounts the "real" root file system
6) linuxrc places the root file system at the root directory using the
pivot_root system call
7) the usual boot sequence (e.g. invocation of /sbin/init) is performed
on the root file system
有人说linuxrc是一个脚本,可以直接打开,脚本的最后执行的是/sbin/init 初始化进程,但我试过加载还是会出现init的内核恐慌。而用busybox生成的linuxrc却不是脚本,而是一个二进制文件,这个文件可以正常加载。不知道是不是文件系统格式的不同,反正脚本格式的linuxrc并没有加载成功过。
其实说到底linuxrc的最用就是执行/sbin/init,所以我们可以在参数中直接指定init=/sbin/init,而跳过linuxrc文件。
2、inittab文件
/sbin/init执行后会调用inittab文件执行
# Run any rc scripts
::sysinit:/etc/init.d/rcS
# Run a shell on the first serial port. Comment this out if you want
# a getty instead
ttymxc1::respawn:-/bin/sh
#::askfirst:-/bin/sh
::respawn:/usr/sbin/inetd -f
# Uncomment this to run a getty on the first serial port
#ttymxc0::respawn:/sbin/getty -L ttymxc0 115200 vt100
# Run a script on shutdown
::shutdown:/etc/init.d/rcK
#::restart:/sbin/init
inittab文件的作用从上面一个例子很容易看出来。它指定了系统初始化的配置文件是rcS,以及一些重启和关机指令。
也可以指定输出串口以及快捷键组合。
当然它最主要的最用仍然是运行rcS脚本文件
3、rcS
rcS的主要最用是加载驱动,以及调用其他的脚本配置文件。如果想要加快启动速度,可以在这个文件中对要加载的配置文件进行裁剪,
将不需要配置的属性去掉即可。
4、profile文件
这个文件相当于用户配置文件。它可以放置一些用户需要配置的东西,如Qt的环境变量,tslib,需要开机运行的程序等。
文件系统的裁剪:
文件系统的裁剪主要是去掉那些你不需要的命令。如/sbin、/usr/bin/、/usr/sbin里面的一些,根据自己的需求可以删除很多不需要的可执行文件。