init现在力求统一标准,最为常用的还是system V init和busybox init。system V
init是host上常用的,也是redhat的默认init。system V
init是比较复杂的,支持多级别启动。相对于嵌入式系统来说,有些复杂。busybox只支持一个级别,相对来说,更适合嵌入式系统应用。
[armlinux@lqm basicfs1]$ tree -L 1 . |-- bin |-- dev |-- etc |-- home |-- lib |-- mnt |-- proc |-- root |-- rootfs |-- sbin |-- sys |-- tmp |-- usr `-- var
也写了小的脚本:
[armlinux@lqm fs]$ cat mkrootfs.sh #!/bin/bash # make the basic root file system # set the target documentation ROOTFS=rootfs TRUE=1 FALSE=0 # check whether the user is the root is_root() { if [ `id -u` == 0 ]; then return $TRUE else return $FALSE fi } # must be the root if is_root; then echo "Must be root to run this script." exit 1 fi # create the rootfs mkdir $ROOTFS; cd $ROOTFS mkdir -p bin dev etc lib/modules proc sbin sys usr/bin usr/lib
usr/sbin tmp # create the basic dev mknod -m 600 dev/console c 5 1 mknod -m 666 dev/null c 1 3 # copy lib cp -av ../simple_fs/lib cp -av ../simple_fs/etc/* etc/
diff -urN tinylogin-1.4.orig/Makefile tinylogin-1.4/Makefile --- tinylogin-1.4.orig/Makefile 2003-01-03 18:56:33.000000000 +0800 +++ tinylogin-1.4/Makefile 2008-03-19 11:00:01.000000000 +0800 @@ -49,12 +49,12 @@ # this adds just 1.4k to the binary size (which is a _lot_ less
then glibc NSS # costs). Note that if you want hostname resolution to work with
glibc, you # still need the libnss_* libraries. -USE_SYSTEM_PWD_GRP = true +USE_SYSTEM_PWD_GRP = false # Setting this to `true' will cause tinylogin to directly use the
system's # shadow password functions. If you leave this off, tinylogin will
use its # own (probably smaller) shadow password functions. -USE_SYSTEM_SHADOW = true +USE_SYSTEM_SHADOW = false # This enables compiling with dmalloc ( http://dmalloc.com/ ) # which is an excellent public domain mem leak and malloc problem @@ -73,7 +73,7 @@ # If you are running a cross compiler, you may want to set this # to something more interesting, like "powerpc-linux-". -CROSS = +CROSS = /usr/local/arm/3.4.1/bin/arm-linux- CC = $(CROSS)gcc AR = $(CROSS)ar STRIPTOOL = $(CROSS)strip
[armlinux@lqm etc]$ cat init.d/rcS #!/bin/sh # Initial Environment # mount /etc/fstab spcified device /bin/mount -a # mount devpts in order to use telnetd /bin/mkdir /dev/pts /bin/mount -t devpts devpts /dev/pts # read the busybox docs: mdev.txt /bin/mount -t sysfs sysfs /sys /bin/echo /sbin/mdev > /proc/sys/kernel/hotplug /sbin/mdev -s # when mdev is mounted, /sys can be umounted /bin/umount /sys # Hostname Setting /bin/hostname listentec # Network Setting /sbin/ifconfig lo 127.0.0.1 /sbin/ifconfig eth0 192.168.1.100 netmask 255.255.255.0 /sbin/route add default gw 192.168.1.1 # Adjust Time /usr/sbin/ntpdate 210.72.145.44 # NFS client /bin/mount -o nolock,wsize=1024,rsize=1024
192.168.1.106:/home/armlinux/nfs /mnt/nfs /bin/echo "NFS client is on now and the mounted point is /mnt/nfs" # Print the author information /bin/echo /bin/echo "********************************" /bin/echo " made by lqm " /bin/echo "********************************" /bin/echo