用安裝光盤引導系統,在要開始安裝情況下按ALT選擇linux rescue
Rescue login# root
查看硬盤分區
Rescue# fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 1 1024 1048560 82 Linux swap
/dev/sda2 1025 11264 10485760 83 Linux
掛載分區
Rescue# mount -n / -o remount,rw
Rescue# mount /dev/sda2 /mnt
Rescue# mount -o bind /dev /mnt/dev
進入/etc/passwd進行修改,增加:
root:x:0:0:root:/root:/bin/bash
保存後設置root密碼,重啟主機即可恢復。