CPR for My Dying Disk

Over the past week or two my hard disk showed signs of illness, I ignored those signs which resulted in severe illness of the drive. I usually keep my machine running. Moreover, I am running KDE4, so buggy behavior was quite expected on my behalf. I realised my disk was dying only when it was too late, I was getting read errors.

Long story short, I got another disk and promptly began the recovery process. I booted off an old recovery distro I had on my USB stick (Ubuntu Rescue Remix 8.04).

First off I tried to mount the failed drive, that didn’t work, so I fired up testdisk, failed even more miserably. Well testdiskis not the right program anyways since it is used to recover partitions not dead drives. Next came ddrescue, and it more or less was to the rescue.

I have two partitions that were of interest, /dev/sda2 and /dev/sda5 those help my / (root) and /home respectively. So I ran the following two commands.

ddrescue -n /dev/sda2 /dev/sdb2 ddrescue -n /dev/sda5 /dev/sdb3
/dev/sdb is the new disk I brought in. It was being used as a spare for extra space on a windows machine, so i thought Ill just resize the main partition and make it a samba share once I am back up to speed.

The first of the two commands spewed a whole bunch of errors while it ran, but it more or less finished with less than 1MB of errors that were not recovered. The second command ran from start to finish with no errors.

mounting /dev/sdb2 after the command finished didn’t work, there were too many inode errors, which prompted me to run fsckon it which moved everything into the lost+found/directory. That’s annoying but at least I still have my files. Mounting /dev/sdb3 was perfect, no errors, I thought all is well.

I decided that this was good enough, I proceed to move the lost+found of sbd2 to sdb3 in preparation of a new OS install (off-topic, but this will insha’ Allah be debian with KDE4 (yes KDE4 I guess I don’t learn)). The move did not complete, I had insufficient space on disk. That was really weird as I had earlier made sure that I gave both partitions more than extra space. It turns out ddrescue mimics the source partition giving it the same size (this was determined by looking at df -h), whereas gnu partedwas reporting the bigger sizes.

Since I have recently had some experience resizing ext3 partitions, I looked for the same article that I had used earlier. There are many steps in that article that I did not have to go through, so I am posting what I needed to run here, mainly for self referential purposes.

tune2fs -O^has_journal /dev/sdb2 e2fsck -f /dev/sdb2 resize2fs /dev/sdb2 40G
Although I had the partition in parted to 40GB, resize2fscomplained that it was too much, so after trial and error I reached 37Gas the capacity. When I ran the same commands for /dev/sdb3, e2fsckreported so many errors that it fixed thus also moving all my files to lost+found. So now I have a whole bunch of numbered directories that have my files in them, better than nothing I suppose. I proceeded to remount and finish copying the files I started copying earlier:
mount /dev/sdb2 /mnt/sdb2 mount /dev/sdb3 /mnt/sdb3 rsync -av /mnt/sdb2/lost+found/ /mnt/sdb3/recovered_root/