A Linux machine freezes during boot. To boot directly to a shell prompt so that editing of files and manual starting of services is possible which command line must be passed to the kernel for the boot process?
A. init=/bin/bash
B. 1
C. runlevel=1
D. sh
E. /bin/sh
题解
在 kernel 参数加上「init=/bin/bash」,若有「rhgb」参数需要将其移除掉。如此一来开机就可以直接略过输入 root 密码的步骤进入文字命令模式了。所以答案是选项 A。
这个模式预设是用唯读的方式挂载文件系统,可以用如以下指令来重新将文件系统用可读写的方式挂载:
mount -o remount,rw /
另外,如果是使用 systemd 这个 init 系统的话,还可以有另外的作法达到类似的结果。只要在 kernel 参数加上「systemd.debug-shell」,若有「rhgb」参数需要将其移除掉。如此一来开机之后就会自动使用 tty9 登录 root 帐号,且不需要输入 root 密码,文件系统的挂载预设也会打开写入功能。
