busybox rootfs 启动脚本分析(一)
生活随笔
收集整理的這篇文章主要介紹了
busybox rootfs 启动脚本分析(一)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
imx6文件系統(tǒng)啟動(dòng)腳本分析。開(kāi)機(jī)運(yùn)行/sbin/init,讀取/etc/inittab文件,進(jìn)行初始化。
參考鏈接
http://blog.163.com/wghbeyond@126/blog/static/35166181201051483723579/
/etc/inittab
# see busybox-1.00rc2/examples/inittab for more examples ::sysinit:/etc/rc.d/rcS # 系統(tǒng)啟動(dòng)的時(shí)候運(yùn)行/etc/rc.d/rcS腳本 #::respawn:/etc/rc.d/rc_mxc.S ttymxc0::once:/bin/login root # debug口使用ttymxc0,之運(yùn)行一次/bin/login,root是傳入的參數(shù)。# 這就是為什么登錄之后退出就不能再登錄。如果想再次運(yùn)行/bin/login,將once改為respawn #::once:/sbin/getty 115200 ttymxc0 # 也可以采用這種形式設(shè)置串口,不過(guò)這樣就需要輸入賬戶密碼::sysinit:/etc/rc.d/rc_gpu.S # 系統(tǒng)啟動(dòng)的時(shí)候運(yùn)行rc_gpu.S ::ctrlaltdel:/sbin/reboot # ctrl + alt + del 組合鍵是運(yùn)行/sbin/reboot程序。 ::shutdown:/etc/rc.d/rcS stop # 關(guān)機(jī)的時(shí)候運(yùn)行 /etc/rc.d/rcS stop ::restart:/sbin/init # 重啟時(shí)運(yùn)行/sbin/init/etc/rc.d/rcS
#!/bin/sh# minimal startup script, will work with msh (this is best available in # MMUless format).# load the configuration information . /etc/rc.d/rc.conf # 運(yùn)行/etc/rc.d/rc.conf 腳本 mode=${1:-start} # 當(dāng)$1的值不存在或者為空,那么mode=start,否者mode=$1 if [ $mode = "start" ] thenservices=$cfg_services elseservices=$cfg_services_r fi cfg_services=${2:-$services}# run the configured sequence for i in $cfg_services doif [ -x /etc/rc.d/init.d/$i ] # 判斷/etc/rc.d/init.d/中是否存在$i表示的可執(zhí)行文件then /etc/rc.d/init.d/$i $mode # 運(yùn)行/etc/rc.d/init.d中的shell腳本,start or stop fi doneif [ $# -ge 2 ] # 如果傳入腳本的參數(shù)個(gè)數(shù)大于 2 then exit 0 # 退出, 返回值為 0 fi # show all kernel log messages #echo 8 > /proc/sys/kernel/printk# run rc.local if present and executable if [ -x /etc/rc.d/rc.local ] # 判斷rc.local是否存在,并且可執(zhí)行 then /etc/rc.d/rc.local $mode # 運(yùn)行rc.local, mode= start/stop fi/etc/rc.d/rc.conf
all_services="mount-proc-sys mdev udev hostname devfsd depmod modules filesystems syslog network inetd portmap dropbear sshd boa smb dhcpd settime fslgnome watchdog bluetooth gtk2 pango" all_services_r="pango gtk2 bluetooth watchdog fslgnome settime dhcpd smb boa sshd dropbear portmap inetd network syslog filesystems modules depmod devfsd hostname udev mdev mount-proc-sys" # 啟動(dòng),運(yùn)行順序 cfg_services="mount-proc-sys udev hostname depmod modules filesystems inetd " # 停止,停止順序與啟動(dòng)順序相反 cfg_services_r=" inetd filesystems modules depmod hostname udev mount-proc-sys"export HOSTNAME="freescale" export NTP_SERVER="" export MODLIST="" export RAMDIRS="" export TMPFS="tmpfs" export TMPFS_SIZE="512k" export READONLY_FS="" export INETD_ARGS="" export BOA_ARGS="" export SMBD_ARGS="" export NMBD_ARGS="" export DHCP_ARG="" export DEPLOYMENT_STYLE="RAMDISK" export SYSCFG_DHCPC_CMD="udhcpc -b -i " export DROPBEAR_ARGS=""/etc/rc.d/rc.local
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if [ -x "/usr/bin/rpm" -a -e "/tmp/ltib" ] # 是否存在可執(zhí)行文件/usr/bin/rpm,以及/tmp/ltib thenecho "rebuilding rpm database"rm -rf /tmp/ltib # 重新創(chuàng)建rpm數(shù)據(jù)庫(kù)rpm --rebuilddb fi# fix up permissions if [ -d /home/user ] # 是否存在/home/user目錄 thenchown -R user.user /home/user # 更改所有者,所在組 fi# Add nodes when running under the hypervisor and static devices if [ -r /sys/class/misc/fsl-hv/dev -a ! -r /dev/fsl-hv ] # 查看/sys/class/misc/fsl-hv/dev是否可讀,并且/dev/fsl-hv不可讀 thenecho "creating hypervisor nodes"DEVID=`cat /sys/class/misc/fsl-hv/dev`if [ -n "$DEVID" ] # 判斷是否為空thenMAJOR="${DEVID%:*}"MINOR="${DEVID##*:}"if [ \( "$MAJOR" -gt 0 \) -a \( "$MINOR" -gt 0 \) ]thenrm -f /dev/fsl-hvmknod /dev/fsl-hv c $MAJOR $MINORfififor i in 0 1 2 3 4 5 6 7domknod /dev/hvc$i c 229 $idone fi# add the fm device nodes if [ -n "$(cat /proc/devices | grep fm | sed 's/\([0-9]*\).*/\1/')" -a ! -r /dev/fm0 ] thenecho "creating fman device nodes"cd /usr/share/doc/fmd-uspace-01.01/test/sh fm_dev_createcd - fifor i in 0 1 2; doif [ -e /sys/class/graphics/fb$i ]; thenchmod 0666 /sys/class/graphics/fb$i/panfi done/etc/rc.d/rc_gpu.S
#!/bin/bash CPUREV=$(cat /proc/cpuinfo | grep Revision | awk '{print $3}' | awk '{print substr($0,1,2)}') # 查看cpu的版本,mx6dl讀取的是61 FILEVG=/usr/lib/libOpenVG.so FILEVG3D=/usr/lib/libOpenVG_3D.so FILEVG355=/usr/lib/libOpenVG_355.so echo 4 > /sys/module/galcore/parameters/gpu3DMinClock if [ -e $FILEVG3D ] && [ -e $FILEVG355 ] thenif [ $CPUREV == "61" ] || [ $CPUREV == "63" ] || [ $CPUREV == "60" ] && [ -e $FILEVG ]thenrm -f $FILEVGfi if [ $CPUREV == "61" ]thenln -s $FILEVG3D $FILEVG # 創(chuàng)建軟連接fi if [ $CPUREV == "63" ]thenln -s $FILEVG355 $FILEVGfi if [ $CPUREV == "60" ]thenln -s $FILEVG355 $FILEVGfi fi/etc/profile
登錄的時(shí)候,輸入完賬戶密碼之后,調(diào)用/etc/profile
Tony Liu
2016-12-13, Shenzhen
總結(jié)
以上是生活随笔為你收集整理的busybox rootfs 启动脚本分析(一)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Android 轮询最佳实践 Servi
- 下一篇: app端微信支付(二) - 生成预付单