busybox 集成systemd之后reboot 失败

在 Busybox 系统中尝试执行 reboot 命令失败,因为systemd没有作为第一个进程启动。系统提示需要在启动时通过内核参数指定init=/lib/systemd/systemd或init=/sbin/init来启动systemd。这表明在sysv模式下,/sbin/init和/linuxrc指向busybox,而在systemd模式下,/sbin/init是systemd的软链接。为了解决问题,需要确保系统支持systemd并正确配置内核启动参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 在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/systemdinit=/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

https://wiki.gentoo.org/wiki/Systemd#:~:text=Configuration%201%20Machine%20ID.%20Create%20a%20machine%20ID,...%209%20Configure%20verbosity%20of%20boot%20process.%20

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值