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
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 root, then
exitto 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:
<code>fsck -y /dev/hda6</code>Replace
/dev/hda6with 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.conffrom within the running system. The typical
grub.conflayout is:
<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>The boot sequence loads the
/bootpartition, then the kernel, and finally the initrd image.
Example: Missing title line
If the
titleline is missing, the system stops at the
grub>prompt. Use the following commands to locate and inspect
grub.conf:
<code>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 exists</code>After 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/sysimageto work inside the installed system.
Case A: Restoring a dual‑boot GRUB
After reinstalling Windows, the MBR may be overwritten. From rescue mode run:
<code>chroot /mnt/sysimage
grub-install /dev/hda # adjust device name as needed
exit
exit</code>The system will boot both Linux and Windows again.
Case B: Recovering a lost /etc/inittab
If
/etc/inittabis missing, restore it from a backup or reinstall the package that provides it. Example using RPM:
<code>chroot /mnt/sysimage
rpm -ivh --replacepkgs --root /mnt/sysimage /mnt/source/Fedora/RPMS/initscripts-8.45.3-1.i386.rpm</code>Or extract the file directly:
<code>rpm2cpio /mnt/source/Fedora/RPMS/initscripts-8.45.3-1.i386.rpm | cpio -idv ./etc/inittab
cp etc/inittab /mnt/sysimage/etc</code>After restoring the file, exit the chroot and reboot.
Source: csghjnbj, blog.chinaunix.net/uid-26567710-id-3050269.html
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.