Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

December 29, 2005

System rescue act using GNU/Linux Live CD

Filed under: GNU/Linux, General — tabrez @ 4:22 pm

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:

sh# fdisk -l

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.

sh# mkdir /mnt/tmp && mount -t ext3 /dev/hda9 /mnt/tmp

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:

sh# fsck /dev/hda9

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:

#mount /dev/hda9 /mnt/tmp

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# chroot /mnt/tmp
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# badblocks -svn /dev/hda9
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.


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Another system rescue story, using Ubuntu LiveCD
  • Linux Bible 2007 Edition: Install/Run 10+ GNU/Linux Distributions(Ubuntu, Fedora, Gentoo etc)
  • Moving A GNU/Linux Installation To A Different Partition
  • Windows Live Writer: A Slick And Powerful Blogging Tool From Microsoft
  • Five More Desktop Blog Editors for GNU/Linux Users
  • Installing Ubuntu & Kubuntu Dapper(6.06 LTS) For NVidia GeForce Cards
  • Upgrading to Wordpress 2.3 with Zero Downtime!

  • Readers who viewed this page, also viewed:


    1 Comment »

    1. [...] 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) [...]

      Quote

      Pingback by Every Flavour Beans » Another system rescue story, using Ubuntu LiveCD — May 24, 2006 @ 3:59 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost