終于搞清楚了為啥我的Ec2108在/etc/init.d/rcS中設(shè)置的PATH,啟動(dòng)后莫名的被修改了,原來(lái)是/etc/init.d/profile中又把PATH重新設(shè)置了,原因記錄下來(lái)。
【本文為OurUnix--Linux's境原創(chuàng),轉(zhuǎn)載請(qǐng)注明源地址www.ourunix.org】
這兩天在做根文件系統(tǒng)的時(shí)候,注意到/linuxrc、/etc/init.d/rcS、/etc/init.d/rc.local、/etc/init.d/profile這幾個(gè)文件尤其重要,遂把他們記載下來(lái)了。
/Linuxrc 執(zhí)行init 進(jìn)程初始化文件。主要工作是把已安裝根文件系統(tǒng)中的/etc 掛載為ramfs,并拷貝/mnt/etc/目錄下所有文件到/etc,這里存放系統(tǒng)啟動(dòng)后的許多特殊文件;接著Linuxrc 重新構(gòu)建文件分配表inittab;之后執(zhí)行系統(tǒng)初始化進(jìn)程/sbin/init。
Linuxrc
#!/bin/sh
echo "mount /etc as ramfs"
/bin/mount -n -t ramfs ramfs /etc
/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 /
/bin/mount -f -t ramfs ramfs /etc
exec /sbin/init
etc/init.d/rcS 完成各個(gè)文件系統(tǒng)的 mount,再執(zhí)行/usr/etc/rc.local;通過(guò)rcS 可以調(diào)用 dhcp 程序配置網(wǎng)絡(luò)。rcS 執(zhí)行完了以后,init 就會(huì)在一個(gè) console 上,按照 inittab 的指示開(kāi)一個(gè) shell,或者是開(kāi) getty + login,這樣用戶就會(huì)看到提示輸入用戶名的提示符。
rc.local
/usr/etc/
#!/bin/sh
. /usr/etc/profile
echo "HELLO! Embest"
echo "ifconfig eth0 192.168.0.10"
ifconfig eth0 192.168.0.10 #可自行配置開(kāi)發(fā)板IP
/usr/etc/rc.local 這是被init.d/rcS 文件調(diào)用執(zhí)行的特殊文件,與Linux 系統(tǒng)硬件平臺(tái)相關(guān),如安裝核心模塊、進(jìn)行網(wǎng)絡(luò)配置、運(yùn)行應(yīng)用程序、啟動(dòng)圖形界面等。
rcS
/mnt/etc/init.
d/
#!/bin/sh
/bin/mount -a
exec /usr/etc/rc.local
/usr/etc/profile 執(zhí)行該文件配置需要的環(huán)境變量等。
Profile
/usr/etc/
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin ?? 設(shè)置命令工具所在位置