Master Linux Boot Failures: Single-User Mode, GRUB Fixes & Rescue Mode Guide
This guide explains how to troubleshoot Linux boot problems using single‑user mode, correct GRUB configuration errors, and employ Linux rescue mode to repair root passwords, disk errors, and dual‑boot issues, providing step‑by‑step commands and examples.
I discovered various Linux boot failures and compiled several case studies on single‑user mode, GRUB commands, and rescue mode to help readers resolve these issues.
1. Single-User Mode
Linux provides a single‑user mode (runlevel 1) similar to Windows safe mode, where the system boots into a root shell with networking disabled and only essential processes running. It is useful for repairing file systems, restoring configuration files, moving user data, and other maintenance tasks.
Case 1: Forgotten root password
In many distributions (e.g., Red Hat) single‑user mode does not require the root password, making password reset straightforward. To enter single‑user mode:
During boot, press any key to access the GRUB menu.
Press
eto edit the selected entry and move to the
kernelline.
Append
singleto the end of the line, press
Enter, then
bto boot.
When the root shell appears, run
passwd rootto set a new password, then
exitto reboot.
Other typical fixes in single‑user mode include disabling problematic services (e.g.,
chkconfig smb off) and changing the default runlevel by editing
/etc/inittab(e.g., setting
id:3:initdefault:).
Case 2: Disk sector errors
Bad sectors or corrupted partitions often appear after power loss. The system may stop with a prompt like “Press root password or ctrl+D”. Enter the root password to drop into single‑user mode and run:
<code>fsck -y /dev/hda6</code>Replace
/dev/hda6with the affected partition. After the check finishes, reboot with
reboot.
Case 3: GRUB configuration typo
An “Error 15” usually means the kernel filename in
grub.confis misspelled (e.g.,
vmlinuxinstead of
vmlinuz). Return to the GRUB edit screen, correct the typo, save, and boot with
b. Then fix the typo permanently in
grub.conf.
2. GRUB Boot Troubleshooting
Sometimes the system boots directly to a
grub>prompt. The two most common causes are:
Incorrect options in
grub.conf.
Missing or corrupted
grub.conf(or kernel/image files).
If the configuration is wrong, you can edit it from the GRUB command line; if the file is missing, you need to use Linux rescue mode.
Key entries in
grub.confinclude:
<code>title Fedora Core (2.6.18-1.2798.fc6)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-1.2798.fc6 ro root=LABEL=/ rhgb quiet initrd /boot/initrd-2.6.18-1.2798.fc6.img</code>GRUB first loads the
/bootpartition, then the kernel, then the initrd.
Example: Missing title line
If the
titleline is removed, the system drops to
grub>. To recover:
Locate
grub.confwith
find /boot/grub/grub.conf (hd0,0).
Inspect the file using
cat (hd0,0)/boot/grub/grub.conf(or a backup).
Correct the entries, then boot with
b.
3. Linux Rescue Mode
If neither single‑user nor GRUB recovery works, boot from a Linux installation CD and choose “linux rescue”. Follow the prompts to select language, keyboard, and network settings (network is usually unnecessary). The installer will mount the root filesystem under
/mnt/sysimage. Run
chroot /mnt/sysimageto operate on the installed system.
Case 1: Restoring dual‑boot after Windows overwrites MBR
Enter rescue mode, then:
<code>chroot /mnt/sysimage
grub-install /dev/hda # replace hda with the appropriate disk
exit
exit # leave chroot and rescue mode
reboot</code>Case 2: Recovering a lost /etc/inittab
If a backup exists, copy it back:
<code>chroot /mnt/sysimage
cp /etc/inittab.bak /etc/inittab
exit
reboot</code>If no backup is available, reinstall the package that provides
inittab:
<code>rpm -qf /etc/inittab # find the owning package
rpm -ivh --replacepkgs --root /mnt/sysimage /mnt/source/Fedora/RPMS/initscripts-8.45.3-1.i386.rpm</code>Alternatively, extract the file from the RPM:
<code>rpm2cpio /mnt/source/Fedora/RPMS/initscripts-8.45.3-1.i386.rpm | cpio -idv ./etc/inittab
cp etc/inittab /mnt/sysimage/etc</code>Rescue mode is a powerful tool for fixing boot problems; understanding the Linux boot process is essential for effective troubleshooting.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.