System rescue act using GNU/Linux Live CD
It happened like this: I once rebooted my machine and got back a grub call-whatever-you-like error at the boot prompt with the consequence that there was no gnu/linux or windows for me for the time being. I had so many operating systems installed on my computer, but I could not boot into atleast one of them as the boot loader itself had deserted me. What to do? Re-install all the operating systems again? Re-install one gnu/linux os and recover the others using it? Or recover the entire hard disk from the backup drives? The last option looks like the most sensible one, provided that I had taken such a backup in the first place. I did not.
I keep the Live CD of Knoppix OS just for such occassions. It allows me to conveniently boot into the gnu/linux environment right from the CD without having anything to do with the hard disk(s) present on my computer. Once there, I could connect to the Internet and ask for help. But I had my recipe to recover from such situations written safely in a corner of my mind and I decided to make use of it on this occassion. I opened the terminal emulator and got on with the job:
This listed all my disks and their partitions, inducing a sigh of relief in me, and I started mumbling to myself “Everything is fine mate, everything is fine!”
Then it was time to see if I had lost any data.
I panicked for a moment as the mount failed with an error. I knew I need to run ‘fsck’ now, so headed straight to that step:
and accepted all the suggestions from it(pressed ‘yes’ to all the questions). My filesystem was ‘apparently’ fixed but i wanted to confirm it. I tried to mount it again:
Celebration time! The partition was successfully mounted and I could browse all the data present in the partition. I happily repeated the procedure with other gnu/linux os’es and then turned my attention to the boot loader.
I quickly chroot‘ed to the root partition of the Ubuntu OS(whose boot loader was installed on my MBR) and entered the following commands at the command shell:
sh# grub-install /dev/hda
sh# exit
sh# reboot
That’s it! My system was back to its normal state, with the familiar grub bootloader greeting me with all the operating systems that were installed on my computer.
In related but different situations, there are variations of the above procedure which I had to follow to get my system working again. After one hard disk failure, for example, ‘fsck’ refused to work with my filesystem; I had to first run ‘badblocks’ to scan for any possible bad blocks on the disk, and then run e2fsck with an alternate block number as the main super-block was corrupted.
sh# dumpe2fs /dev/hda8 (use a partition here whose super-block is not corrupted)
sh# e2fsck -b <alternate-super-block-from-above-command> /dev/hda9
If there is currently no partition that has a valid super-block, then the trick is to make a new file with an equal number of blocks as the corrupted partition, and then finding an alternate super block by applying the above procedure to this newly created file.
Anyway, there is atleast one way to get out of the trouble if you have a GNU/Linux Live CD handy with you. If you don’t have one already, go and grab it right now.
A list of popular gnu/linux live cd’s is here.
Related Posts:
Readers who viewed this page, also viewed:
- Moving A GNU/Linux Installation To A Different Partition
- Convert DVD Movies to iPod Format(with Subtitles) Using Free Software
- Update or Install Applications on Debian/Ubuntu Without an Internet Connection
- Linux Bible 2007 Edition: Install/Run 10+ GNU/Linux Distributions(Ubuntu, Fedora, Gentoo etc)
- Six Popular IDEs For Developing Software in C/C++ on Windows Platform
[...] Adding to what I had written in one of my earlier posts about the rescue act using a GNU/Linux Live CD , here is a related story posted on the ubuntu-users mailing list: (this is a trimmed version, full story here) [...]
QuotePingback by Every Flavour Beans » Another system rescue story, using Ubuntu LiveCD — May 24, 2006 @ 3:59 pm