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密碼,檔案系統的掛載預設也會開啟寫入功能。