Feb. 24, 2007, 5:40 p.m.
posted by void
Rescue an Unbootable System
When you've had a little too much fun with your new Ubuntu system and it no longer boots, here are a few options to get your computer back in running order. If you are reading this hack, we want to offer you our condolences. It can be stressful and upsetting when your system won't boot. We're sure you are thinking right now about all of those files you wished you backed up (We know this is a bad time, but once your system is back up and running, you might want to check out "Back Up Your System" [Hack #79]). We've certainly been in the same situation far too many times, but so far we've also been able to bring our systems back to life. While it would be impossible to cover every possible scenario that might cause a system to no longer boot, we're going to go over how to use the Ubuntu install CD in rescue mode to fix the problem and describe some common rescue scenarios. Boot into Rescue ModeFirst, find your trusty Ubuntu install CD and reboot your system to its initial boot screen. Among the number of options is "Recover a broken system." Select this option, and Ubuntu will start what appears at first to be the default installation program. You will be prompted for some standard language and network settings as you are during the installation, but these steps are only to set up the initial rescue environment. Notice that in the top-left corner of the screen, "Rescue mode" appears. Continue through these dialogs until you are prompted to choose your root device. In Figure, you see a sample of this dialog with a lot of different drives. How do you pick the right one? If you aren't too familiar with the partition layout of your drives, it might require a bit of trial and error, but here's a basic rule of thumb: The rescue-disk root-device dialog
After you choose your root filesystem, the Ubuntu CD will attempt to mount it, and it will continue to the next dialog if it was successful. If it wasn't successful, you might have chosen the wrong partition, so pick another and try again. Common Rescue ScenariosThe next dialog will present you with a number of different rescue options (see Figure). The operation you choose here will vary greatly depending on the symptoms of your unbootable system, so instead of describing everything possible with these options, we're going to describe a few common rescue scenarios and what to do from this dialog to fix the problem. The rescue-mode chooser
The system won't go past the boot menu, or the menu is missingThis is a common symptom for an unbootable system. Perhaps you reinstalled Windows or some other operating system as a dual-boot system. Whatever the reason, your default GRUB boot menu is now missing and needs to be restored. From the rescue operations menu, select the "Reinstall GRUB boot loader" option. The next screen that appears is the same one you might remember being prompted with when you first installed Ubuntu. It asks you where you would like to install the GRUB boot loader. Unless you remember setting up GRUB somewhere in particular, chances are you probably installed it to the Master Boot Record on your first hard drive. If so, type (hd0) and then continue. The rescue mode will reinstall GRUB and drop you back to the main "Rescue operations" menu. Select "Reboot the system," and you should hopefully be presented with your standard boot menu. The system goes past the boot menu but can't access the root filesystemThis can be a tricky symptom, as a number of different problems can be the cause, from corrupted filesystems to new problematic kernels. Before you go through any steps in the rescue mode, first try to boot and select a different kernel option in the boot menu. If that kernel boots, then there is likely some sort of hardware support problem for your latest kernel. Check for updates to your kernel package and, in the meantime, boot from the working kernel. If you experience the same problem with the different kernels in your boot menu, continue to the following steps. For this sort of problem, the troubleshooting will need to be done directly from the rescue CD, so select the "Execute a shell in the installer environment" option. You will then be dropped to a basic BusyBox shell where you can perform some basic diagnostics and repairs:
Some sample diagnostics from the BusyBox shell
The system boots and continues through part of the boot process, but hangs at a particular serviceWhether it is due to a poorly written init script or some other bug, on some rare occaisions, an init script might stall and refuse to continue through the boot process. When this happens, you can't drop to a shell to repair the problem, so you must resort to a rescue CD. Make a note of the service that is stalling, and boot into the rescue mode of your Ubuntu install CD. To fix this sort of issue, you will need to actually drop to a shell within your root filesystem's environment, so select "Execute a shell in /dev/discs/disc0/part1" from the Ubuntu rescue operations menu. (This option might be named something slightly different if you picked a different partition as your root filesystem.) This option will drop you to a shell from within your own root filesystem. You can navigate this filesystem and run commands as though you had actually booted into it. At this point, you will want to identify the init service that is causing you problems and disable it. "Control Startup Services" [Hack #77] has instructions on how to identify and disable startup services from the command line, so read through that hack for the specifics. In a default Ubuntu install, you will likely want to look for your init service in either /etc/rc2.d or /etc/rcS.d. Once you find the offending init script, rename it, changing the S at the beginning of the filename to a D. Once the init script has been disabled, type exit to exit out of the shell and then reboot and attempt to boot back into your Ubuntu system. The disabled init script should not stall you this time, so you should be able to get to your default login screen. ConclusionIt's true that these are only a few of the possible problems that could render a system unbootable. If you have tried all of these rescue options and still can't fix your system, don't give up! Read "Get Help" [Hack #2] for some information on how to enlist the help of some fellow Ubuntu users. |
- Comment