busybox rootfs 启动脚本分析(一)
imx6文件系统启动脚本分析。开机运行/sbin/init,读取/etc/inittab文件,进行初始化。
参考链接
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 # 系统启动的时候运行/etc/rc.d/rcS脚本
#::respawn:/etc/rc.d/rc_mxc.S
ttymxc0::once:/bin/login root # debug口使用ttymxc0,之运行一次/bin/login,root是传入的参数。# 这就是为什么登录之后退出就不能再登录。如果想再次运行/bin/login,将once改为respawn
#::once:/sbin/getty 115200 ttymxc0 # 也可以采用这种形式设置串口,不过这样就需要输入账户密码::sysinit:/etc/rc.d/rc_gpu.S # 系统启动的时候运行rc_gpu.S
::ctrlaltdel:/sbin/reboot # ctrl + alt + del 组合键是运行/sbin/reboot程序。
::shutdown:/etc/rc.d/rcS stop # 关机的时候运行 /etc/rc.d/rcS stop
::restart:/sbin/init # 重启时运行/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 # 运行/etc/rc.d/rc.conf 脚本
mode=${1:-start} # 当$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表示的可执行文件then /etc/rc.d/init.d/$i $mode # 运行/etc/rc.d/init.d中的shell脚本,start or stop fi
doneif [ $# -ge 2 ] # 如果传入脚本的参数个数大于 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是否存在,并且可执行
then /etc/rc.d/rc.local $mode # 运行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"
# 启动,运行顺序
cfg_services="mount-proc-sys udev hostname depmod modules filesystems inetd "
# 停止,停止顺序与启动顺序相反
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" ] # 是否存在可执行文件/usr/bin/rpm,以及/tmp/ltib
thenecho "rebuilding rpm database"rm -rf /tmp/ltib # 重新创建rpm数据库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 # 创建软连接fi if [ $CPUREV == "63" ]thenln -s $FILEVG355 $FILEVGfi if [ $CPUREV == "60" ]thenln -s $FILEVG355 $FILEVGfi
fi
/etc/profile
登录的时候,输入完账户密码之后,调用/etc/profile
Tony Liu
2016-12-13, Shenzhen
busybox rootfs 启动脚本分析(一)相关推荐
- tomcatSupplement(1)tomcat启动脚本分析(以Windows平台为例)
[0]README 1)本文部分文字描述转自:"深入剖析tomcat",旨在学习"tomcat启动脚本分析"的相关知识: 2)for tomcat4 start ...
- Spark配置启动脚本分析
2019独角兽企业重金招聘Python工程师标准>>> 今天想停止spark集群,发现执行stop-all.sh的时候spark的相关进程都无法停止.提示: no org.apach ...
- 第一章 Hadoop启动Shell启动脚本分析--基于hadoop-0.20.2-cdh3u1
我的新浪微博:http://weibo.com/freshairbrucewoo. 欢迎大家相互交流,共同提高技术. 第一章 Hadoop启动Shell启动脚本分析 第一节 start-all.sh脚 ...
- v210 启动脚本分析
1. 一般嵌入式linux系统的init进程会首先读取/etc/inittab文件,这里记录了系统在不阶段需要运行的程序与脚本文件. 其中v210的此文件里有这么一句 ::sysinit:/etc/i ...
- kafka之服务端启动脚本分析
前阵子在服务器上搭了个 kafka,搭好后安装在 /usr/local/kafka 下: [root@lucas kafka]# pwd /usr/local/kafka [root@lucas ka ...
- Hi3516开发笔记(三):Hi3516虚拟机基础环境搭建之交叉编译环境境搭建以及开机启动脚本分析
若该文为原创文章,转载请注明原文出处 本文章博客地址:https://hpzwl.blog.csdn.net/article/details/121458516 长期持续项目技术分享,Shang业Di ...
- Linux系统脚本分析之rc.sysinit
Linux系统脚本分析之rc.sysinit #!/bin/bash # # /etc/rc.d/rc.sysinit - run once at boot time # # # Rerun our ...
- Spark学习之路 (十五)SparkCore的源码解读(一)启动脚本
讨论QQ:1586558083 目录 一.启动脚本分析 1.1 start-all.sh 1.2 start-master.sh 1.3 spark-config.sh(1.2的第5步) 1.4 lo ...
- Hyperledger Fabric笔记3--BYFN启动流程分析
Hyperledger Fabric笔记3--BYFN启动流程分析 BYFN--构建你的第一个网络,该方案提供了一个示例Hyperledger Fabric网络,该网络由两个组织组成,每个组织都维护两 ...
最新文章
- C#编写的多生产者多消费者同步问题
- python Flask框架如何请求及返回数据——flask详细教程
- 20161011L04-03老男孩linux运维实战培训-Linux系统的用户和用户组管理-01
- python3多进程 进程池 协程并发
- PointNet:3D点集分类与分割深度学习模型
- sql having是什么意思_图解sql面试题:如何查找重复数据?
- Android性能优化(1) 内存泄露 amp; 解决方案
- 文本文档代码大全简单_简单4步搞定PC版微信多开,不再重复切换
- js基础-7-数组去重的es5和es6写法、数组扁平化
- 金蝶精斗云PDA移动扫码入库出库,搭配蓝牙打印机打印单据小票
- Java网上商城系统_JavaWeb源码网上商城系统
- CRM客户关系管理系统需求分析文档
- 如何用计算机算幂函数,怎样用计算器算幂指数
- win10 联想键盘快捷键关闭_Win10电脑不用鼠标怎么关机键盘与快捷键关机技巧
- php实现文件下载,提示压缩包损坏解决方法
- 2021年度总结及2022展望
- 这几所院校会压分!请注意!
- Python提取岛上书店书中所有书名后做成词云
- USC Computer Vision
- 丢掉鼠标吧,使用最好用的Eclipse快捷键