Sha*_*jee 12 linux startup busybox init.d runlevel
我在 BusyBox 中编译了一个自定义的 linux 内核。BusyBoxinit
不支持运行级别。当内核在 BusyBox 中启动时,它首先执行init
它在/etc/inittab
. BusyBoxinit
没有/etc/inittab
. 当没有inittab
找到时,它具有以下行为:
::sysinit:/etc/init.d/rcS
Run Code Online (Sandbox Code Playgroud)
这部分对我来说很清楚,但我想知道如何管理启动网络、创建串行端口或启动java
进程的守护进程。我查看了驻留在其中的脚本,/etc/init.d/
但我不明白如何管理它们。我正在寻找一个很好的教程或解决方案来自己控制这些服务,而无需像buildroot
. 我想了解这些脚本是如何工作的以及如何在中创建设备/dev/
(现在我只有console
和ttyAM0
)。
对于 buildroot,您的所有脚本都必须放在$path_to_buildroot/output/target/etc/init.d
构建映像之前。在我的例子中,这个目录包含rcS
一些名为 S[0-99]script_name 的脚本。因此,您可以创建自己的启动\停止脚本。
回复:
#!/bin/sh
# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
Run Code Online (Sandbox Code Playgroud)
例如 S40network:
#!/bin/sh
#
# Start the network....
#
case "$1" in
start)
echo "Starting network..."
/sbin/ifup -a
;;
stop)
echo -n "Stopping network..."
/sbin/ifdown -a
;;
restart|reload)
"$0" stop
"$0" start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
Run Code Online (Sandbox Code Playgroud)
小智 7
在“目标”文件夹中更改 fs 是个坏主意。这是因为更改output/target/
不会在make clean
命令中保留。
在 buildroot 手册中描述了如何 正确执行
您应该在部分覆盖文件系统的地方创建目录。例如,您可以在创建此结构的 buildroot 目录中创建目录“your-overlay”
your-overlay/etc/init.d/<any_file>
然后你应该在 defconfig 中设置这个覆盖的路径
System configuration > Root filesystem overlay directories
(或者,找到 BR2_ROOTFS_OVERLAY)
此外,此叠加层的推荐路径是
board/<company>/<boardname>/rootfs-overlay
归档时间: |
|
查看次数: |
50919 次 |
最近记录: |