CentOS7のシングルユーザーモード

概要

CentOS7はシングルユーザーモードに入るときにカーネルパラメータに追加する値がCentOS7以前のOSとちょっと違ったのでそのメモです。

この手順はrootのパスワードが必要なのでrootパスワードリセットには使えません。

環境

CentOS 7.1.1503(KVM)
3.10.0-229.1.2.el7.x86_64


grub編集

CentOS Linux (3.10.0-229.1.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-123.20.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-123.13.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-123.13.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-123.9.3.el7.x86_64) 7 (Core)
CentOS Linux, with Linux 0-rescue-586d1be91

Use the ^ and v keys to change the selection.
Press 'e' to edit the selected item, or 'c' for a command prompt.

起動するカーネルを選択してeを押すと編集画面になります。

カーネルパラメータ編集

linux16 /vmlinuz-3.10.0-229.1.2.el7.x86_64 root=UUID=209ae889-38ef-444\
f-bb37-53faf2a51f44 ro vconsole.keymap=jp106 console=ttyS0,115200n8 crashkerne\
l=auto  vconsole.font=latarcyrheb-sun16 LANG=en_US.UTF-8

linux16 /vmlinuz-3.10.0-229.1.2.el7.x86_64 root=UUID=209ae889-38ef-444\
f-bb37-53faf2a51f44 ro vconsole.keymap=jp106 console=ttyS0,115200n8 crashkerne\
l=auto  vconsole.font=latarcyrheb-sun16 LANG=en_US.UTF-8 systemd.unit=rescue.t\
arget

linux16の最終行に
systemd.unit=rescue.target
を追記します。(スペースを空けて)

編集後、Ctrl + xを押すとシングルユーザーモードで起動します。

起動後

Welcome to rescue mode! Type "systemctl default" or ^D to enter default mode.
Type "journalctl -xb" to view system logs. Type "systemctl reboot" to reboot.
Give root password for maintenance
(or type Control-D to continue): 

rootパスワードを入力するとシングルユーザーモードで操作可能になります。


シングルユーザーモード終了

Ctrl + dでログアウトで終了します。


表示例

[root@tsunokawa ~]# exit
[  254.989999] systemd-journald[338]: Received request to flush runtime journal from PID 1
[  256.346038] type=1305 audit(1434105605.193:3): audit_pid=514 old=0 auid=4294967295 ses=4294967295 res=1

CentOS Linux 7 (Core)
Kernel 3.10.0-229.1.2.el7.x86_64 on an x86_64

tsunokawa login: