在busybox 系统中执行reboot 失败,使用reboot -f 可以强制重启
# reboot
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Failed to talk to init daemon.
系统里面集成了 systemd,
查看systemd 的使用说明 https://www.freedesktop.org/software/systemd/man/init.html#
systemd is a system and service manager for Linux operating systems. When run as first process on boot (as PID 1), it acts as init system that brings up and maintains userspace services. Separate instances are started for logged-in users to start their services.
systemd is usually not invoked directly by the user, but is installed as the /sbin/init
symlink and started during early boot. The user manager instances are started automatically through the user@.service(5) service.
For compatibility with SysV, if the binary is called as init and is not the first process on the machine (PID is not 1), it will execute telinit and pass all command line arguments unmodified. That means init and telinit are mostly equivalent when invoked from normal login sessions. See telinit(8) for more information.
由上可知,若systemd 不是作为第一个进程运行,系统启动则先执行telinit 。
启动时通过内核传参指定启动 systemd 即可。即在内核参数中指定init=/lib/systemd/systemd
或 init=/sbin/init
使用init=/sbin/init
适用于systemd或sysv 两种模式,因为在systemd 模式下 /sbin/init
是指向/lib/systemd/systemd
的软链接。
在sysv 模式下/sbin/init
和/linuxrc
均是指向/bin/busybox
的软链接。
systemd 的相关使用说明:https://wiki.debian.org/systemd
要支持systemd 的内核须满足相关条件,详见 https://cgit.freedesktop.org/systemd/systemd/tree/README#n36