How to Fix Linux Boot Failures: Single‑User Mode, GRUB & Rescue Techniques
This guide explains how to troubleshoot Linux boot problems by using single‑user mode to reset forgotten root passwords, repairing disk errors with fsck, correcting GRUB configuration mistakes, and employing Linux rescue mode to restore missing system files or rebuild the bootloader for dual‑boot systems.
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 system damage, restoring configuration files, or moving user data.
Case 1: Forgotten root password
In single‑user mode most Linux distributions do not require the root password (Fedora Core 6 example). To reset the password:
During boot, press any key to access the GRUB menu.
Press e to edit the selected entry and move to the kernel line.
Append single to the end of the line, press Enter, then b to boot.
When the root shell appears, run passwd root, then exit to reboot.
Other common 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., set id:3:initdefault:).
Case 2: Disk sector errors
Bad sectors or corrupted partitions often appear after an improper shutdown. The system may stop at a prompt like “Press root password or ctrl+D”. After entering the root password, run: fsck -y /dev/hda6 Replace /dev/hda6 with the appropriate partition, then reboot with reboot.
Case 3: Incorrect GRUB configuration
An “Error 15” indicates that GRUB cannot find the kernel specified in grub.conf, often due to a typo such as “vmlinux” instead of “vmlinuz”. Edit the entry in GRUB, correct the typo, save, and boot.
2. GRUB Boot Troubleshooting
When the system drops to a grub> prompt, the most common causes are:
Incorrect options in grub.conf.
Missing or corrupted grub.conf (or other boot files).
If the configuration file is wrong, you can boot manually from the GRUB prompt, then fix grub.conf from within the running system. The typical grub.conf layout is:
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.imgThe boot sequence loads the /boot partition, then the kernel, and finally the initrd image.
Example: Missing title line
If the title line is missing, the system stops at the grub> prompt. Use the following commands to locate and inspect grub.conf:
GRUB> find /boot/grub/grub.conf (hd0,0)
GRUB> cat (hd0,0)/boot/grub/grub.conf
GRUB> cat (hd0,0)/boot/grub/grub.conf.bak # if a backup existsAfter correcting the file, reboot.
3. Linux Rescue Mode
If neither single‑user mode nor GRUB commands can restore the system, boot from a Linux installation CD into rescue mode:
Boot from the CD, at the boot: prompt type linux rescue.
Follow the prompts to select language, keyboard, and optionally network settings.
The installer mounts the root partition under /mnt/sysimage. Choose “continue” for read‑write access.
Run chroot /mnt/sysimage to work inside the installed system.
Case A: Restoring a dual‑boot GRUB
After reinstalling Windows, the MBR may be overwritten. From rescue mode run:
chroot /mnt/sysimage
grub-install /dev/hda # adjust device name as needed
exit
exitThe system will boot both Linux and Windows again.
Case B: Recovering a lost /etc/inittab
If /etc/inittab is missing, restore it from a backup or reinstall the package that provides it. Example using RPM:
chroot /mnt/sysimage
rpm -ivh --replacepkgs --root /mnt/sysimage /mnt/source/Fedora/RPMS/initscripts-8.45.3-1.i386.rpmOr extract the file directly:
rpm2cpio /mnt/source/Fedora/RPMS/initscripts-8.45.3-1.i386.rpm | cpio -idv ./etc/inittab
cp etc/inittab /mnt/sysimage/etcAfter restoring the file, exit the chroot and reboot.
Source: csghjnbj, blog.chinaunix.net/uid-26567710-id-3050269.html
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
