busybox rootfs 启动脚本分析(二)
上次分析了busybox的启动脚本,这次分析一下init.d中一些脚本的内容。
参考链接
http://www.cnblogs.com/helloworldtoyou/p/6169678.html
http://m.blog.chinaunix.net/uid-20678569-id-1574823.html
https://www.ibm.com/developerworks/cn/linux/l-cn-udev/
http://blog.csdn.net/future_fighter/article/details/3862795
mount-proc-sys
#!/bin/sh
# Copyright 2006-2007 Freescale Semiconductor, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
if [ "$1" = "start" -o "$1" = "restart" ]
then
echo "Mounting /proc and /sys
# -t指定文件系统类型, -n不把安装记录在/etc/mtab文件中"
mount -n -t proc proc /proc # 挂载 proc
mount -n -t sysfs sys /sys # 挂载 sysfs
fi
udev
#!/bin/sh
PATH=$PATH:/sbin:/bin
if [ ! -x /sbin/udevd ]
then
exit 0
fi
case "$1" in # start
start)
echo "" > /proc/sys/kernel/hotplug
mount -n -o mode=0755 -t tmpfs tmpfs /dev # 挂载tmpfs到/dev
# Create static device nodes in /dev
mknod /dev/console c 5 1 # 创建/dev/console节点
mknod /dev/null c 1 3 # 创建/dev/null节点
echo "Starting the hotplug events dispatcher udevd"
udevd --daemon # 启动udev,监听内核的uevent,自动创建或删除/dev中的文件
echo "Synthesizing initial hotplug events"
udevtrigger # 扫描sysfs文件系统,生成相应的硬件设备hotplug事件
udevsettle --timeout=300 # 查看udev事件队列,等队列内事件全部处理完毕才退出。
mkdir /dev/pts
mount -n -t devpts devpts /dev/pts # 挂载 devpts
mkdir /dev/shm
;;
stop) # stop
;;
reload)
udevcontrol --reload_rules
;;
*)
echo "Usage: /etc/rc.d/init.d/udev {start|stop|reload}"
echo
exit 1
;;
esac
exit 0
hostname
#!/bin/sh
if [ "$1" = "start" ]
then
if [ -x /bin/hostname -o -x /usr/bin/hostname ]
then
echo Setting the hostname to $HOSTNAME
hostname $HOSTNAME # 设置主机名
fi
fi
depmod
#!/bin/sh
if [ ! -x /sbin/depmod ]
then
exit 0
fi
if [ "$1" = "start" -a ! -s /lib/modules/`uname -r`/modules.dep ] # 判断modules.dep内容是否为空
then
echo Running depmod
/sbin/depmod -a # 使用depmod创建modules.dep文件
# depmod读取/lib/modules/`uname -r`中的所有模块一来关系,并记录到modules.dep文件中。
fi
modules
#!/bin/sh
if [ "$1" = "start" -a -x /sbin/modprobe -a "$MODLIST" ]
then
for i in $MODLIST
do
echo Loading module $i
modprobe $i # 根据MODLIST中的列表安装模块
done
fi
filesystems
#!/bin/sh
if [ "$1" = "stop" ]
then
echo Unmounting filesystems
umount -a -r # -a: All of the file systems described in /etc/mtab are unmounted.
# -r: In case unmounting fails, try to remount read-only.
mount -o remount -r %root% / # 重新挂载分区
[ -x /sbin/swapoff ] && swapoff -a # 关闭配置文件/etc/fstab中所有系统交换分区
fi
if [ "$1" = "start" ]
then
echo Mounting filesystems
if [ "$TMPFS" = "tmpfs" ]
then
mount -n -t $TMPFS shm /dev/shm
fi
if [ -n "$TMPFS" ]
then
mount -n -t $TMPFS rwfs /mnt/rwfs -o size=$TMPFS_SIZE
fi
if [ "$READONLY_FS" != "y" ]
then
mount -n -o remount -w %root% /
NFSBOOT="`cat /proc/cmdline | grep -q /dev/nfs ; echo $?`"
if [ "$NFSBOOT" == "0" -a -n "$RAMDIRS" ]
then
echo "Booted NFS, not relocating: $RAMDIRS"
RAMDIRS=""
fi
else
# initramfs, ramdisks, others? come up read/write by default
mount -n -o remount -r %root% /
RAMDIRS="$RAMDIRS /tmp /etc /var"
fi
if [ -n "$RAMDIRS" ]
then
for i in $RAMDIRS
do
if [ ! -e /mnt/rwfs/$i ]
then
cp -a $i /mnt/rwfs/
mount -n -o bind /mnt/rwfs/$i $i
fi
done
fi
if [ -e /etc/mtab ]
then
rm -f /etc/mtab
fi
ln -s /proc/mounts /etc/mtab # 创建/proc/mounts软连接 /etc/mtab
if [ ! -d /dev/pts ]
then
mkdir /dev/pts # 创建/dev/pts
fi
mount -a
fi
inetd
#!/bin/sh
if [ ! -x /usr/sbin/inetd ]
then
exit 0
fi
if [ "$1" = "stop" -o "$1" = "restart" ]
then
echo "Stopping inetd: "
killall inetd
fi
if [ "$1" = "start" -o "$1" = "restart" ]
then
echo "Starting inetd: "
/usr/sbin/inetd $INETD_ARGS
fi
Tony Liu
2016-12-18, Shenzhen
busybox rootfs 启动脚本分析(二)的更多相关文章
- busybox rootfs 启动脚本分析(一)
imx6文件系统启动脚本分析.开机运行/sbin/init,读取/etc/inittab文件,进行初始化. 参考链接 http://blog.163.com/wghbeyond@126/blog/st ...
- Linux内核启动代码分析二之开发板相关驱动程序加载分析
Linux内核启动代码分析二之开发板相关驱动程序加载分析 1 从linux开始启动的函数start_kernel开始分析,该函数位于linux-2.6.22/init/main.c start_ke ...
- Hadoop启动脚本分析
Hadoop启动脚本分析 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 能看到这篇博客的你估计对Hadoop已经有一个系统的了解了,最起码各种搭建方式你应该是会的,不会也没有关系, ...
- HBase配置&启动脚本分析
本文档基于hbase-0.96.1.1-cdh5.0.2,对HBase配置&启动脚本进行分析 date:2016/8/4 author:wangxl HBase配置&启动脚本分析 剔除 ...
- Spark配置&启动脚本分析
本文档基于Spark2.0,对spark启动脚本进行分析. date:2016/8/3 author:wangxl Spark配置&启动脚本分析 我们主要关注3类文件,配置文件,启动脚本文件以 ...
- 4. hadoop启动脚本分析
4. hadoop启动脚本分析 1. hadoop的端口 ``` 50070 //namenode http port 50075 //datanode http port 50090 //2name ...
- hadoop启动脚本分析及常见命令
进程------------------ [hdfs]start-dfs.sh NameNode NN DataNode DN SecondaryNamenode 2NN [yarn]start-ya ...
- Uboot启动流程分析(二)
1.前言 在前面的文章Uboot启动流程分析(一)中,链接如下: https://www.cnblogs.com/Cqlismy/p/12000889.html 已经简单地分析了low_level_i ...
- linux系统 initrd.img中init启动脚本分析
概述:这篇文章主体内容来源于网上转载.前面几篇文章倾向于制作initrd.img,这篇文章更倾向于initrd.img的运行过程:加载framebuff驱动 ide驱动和文件系统驱动,最后进入到真正的 ...
随机推荐
- Tensorflow二分类处理dense或者sparse(文本分类)的输入数据
这里做了一些小的修改,感谢谷歌rd的帮助,使得能够统一处理dense的数据,或者类似文本分类这样sparse的输入数据.后续会做进一步学习优化,比如如何多线程处理. 具体如何处理sparse 主要是使 ...
- 第二十七篇:SOUI中控件属性查询方法
SOUI项目的SVN根目录下有一个doc目录,下面有一份控件属性表.包含了大部分控件的大部分属性,不过也不一定完全准确.最保险的办法还是查源代码. SOUI对象包含控件及ISkinObj等从SObje ...
- linux apt-get install 错误: Package has no installation candidate
sudo apt-get install vim 在安装vim时报如下错误: Error accoured: This may mean that the package is missing, ha ...
- java中的继承与oc中的继承的区别
为什么要使用继承? 继承的好处: (1)抽取出了重复的代码,使代码更加灵活 (2)建立了类和类之间的联系 继承的缺点: 耦合性太强 OC中的继承 1.OC中不允许子类和父类拥有相同名称的成员变量名:( ...
- BestCoder Round #86
A题 Price List 巨水..........水的不敢相信. #include <cstdio> typedef long long LL; int main() { int T; ...
- hdu 5677 ztr loves substring 多重背包
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission( ...
- ACM:UESTC - 649 括号配对问题 - stack
UESTC - 649 括号配对问题 Time Limit: 1000MS Memory Limit: 65535KB 64bit IO Format: %lld & %llu ...
- 自己写的AutoMapper
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Sy ...
- css选择器总结
(一)选择器优先级: 不同级别 1. 在属性后面使用 !important 会覆盖页面内任何位置定义的元素样式. 2.作为style属性写在元素内的样式 3.id选择器 4.类选择器 5.标签选择器 ...
- Django分析之导出为PDF文件
最近在公司一直忙着做exe安装包,以及为程序添加新功能,好久没有继续来写关于Django的东西了….难得这个周末清闲,来了解了解Django的一些小功能也是极好的了~ 那今天就来看看在Django的视 ...