Tuesday, May 02, 2006

Rescue Disk and Partition Recovery in Linux

The other day, after my laptop hard drive "mysteriously" was inaccessible, I decided to try some tools to fix it. Of course, I had an emergency set of Mondo rescue images, that I made, which could have easily brought me back to a nice baseline. But I decided since the laptop was for testing, it would be nice to wipe it clean and start over. That way previous C.P.O.T.D. posts, could be checked, tested and updated to make sure they had all the dependencies that are needed.

It also was a perfect opportunity to check out some emergency rescue disks and other recovery tools. In keeping with the no cost rule, I drummed up the Cool Pick(s) Of The Day. They are TestDisk and R.I.P.

(R)ecovery (I)s (P)ossible Linux rescue system

To create a bootable Rescue Disk, you have to have a way to create one. I know I know- chicken and the egg dilemma- so go create one now so you have one! I already had a bootable USB pendrive with Slax Linux on it. See the C.P.O.T.D. post about making a Slax or STUX USB thumb drive. A bootable CD-Rom is also a very acceptable solution and I highly recommend creating a bootable rescue tools CD as well. Both options are fantastic. So I booted the Slax USB thumb drive. Then I did the following after inserting a blank CD-R into my cdrom recorder:

cd /tmp
wget http://www.tux.org/pub/people/kent-robotti/looplinux/rip/RIP-15.2.grub.iso
cdrecord /tmp/RIP-15.2.grub.iso


Test Disk

TestDisk is primarily designed to help recover lost partitions as well as make non-booting disks tro be bootable again when these symptoms are caused by things like faulty software, certain types of viruses or human error (such as accidentally erasing your Partition Table). Problems caused by data corruption are possibly not recoverable via ANY standard tool. IF you know what the partition was before, it _may_ be possible to reset it via fdisk... but as they say, your milage may vary.

Partition table recovery using TestDisk is very easy. Just run testdisk and follow the screens. The simple intelligent wizard is quite easy to use to repair the partition issues. You may have to "guess" at some settings, but I found that wrong guesses just makes the wizard complain... so I tried something else. For instance, while using the tool, it said the disk geometry was wrong and I had the wrong number of heads defined. I changed it to another setting and it still complained. I changed the number of heads to the last choice and it accepted it. Then I saved, quit and rebooted the computer with the R.I.P. disk and performed at filesystem check using fsck.ext3. All was happy after that.

Now I strongly recommend cloning your drive to an spare empty one with the dd command such as doing a

dd if=/dev/hda of=/dev/hdb

where /dev/hda is the problem disk and /dev/hdb is the empty hard disk (the hard disks must be same size and type).

Since mine disk was on an experimental/test laptop, I had no such way to do this nor did I care if I lost the contents of the disk. Why? I made a set of Mondo Rescue disks and all my work was backed up on a USB thumb drive. See the 3 C.P.O.T.D. posts about Mondo Rescue- doing so could save you much grief if you lose a hard drive. Also, for very important "this is your only" copy disks, I would absolutely recommend cloning the disk first and working on the clone.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?