Thursday, October 25, 2007

Failure to Recover

I have really old computers. You may think this odd with my being in the tech industry but I never go out and buy 'the next big thing' until it is superseded by at least two more 'next big things'. Its analagous to never buying a new car and letting someone else pay the 'drive off the lot' fee.

My personal computer has been a Dell Inspiron 8100 for some time. This thing is at least 6 years old and had begun to show its age. I run linux on my personal machines since it runs faster and in a smaller footprint than MS stuff and trends toward more reliable.

I like linux and I like the Ubuntu brand of linux for my personal use. Its reliable and easy to use without the normal issues of upgrading found in MS products. I did, however, get bit when I tried to upgrade from 7.04 to 7.10 (Feisty Fox to Gutsy Gibbon). The darn upgrade hung halfway through hosing my laptop. So, I created a 7.10 CD on another machine, mounted it on my laptop and proceeded to recover the files to my external USB via a combination of tar and gzip (also known as a tarball).

I wiped the disk on the laptop and proceeded to restore my data. This is when horror struck. The tarball was corrupt. The reason, I suspect, is that my usb is formated for the old windows FAT file system which has an upper limit of 4 GB. The tarball was bigger than that.

I tried everything I knew to try but I couldn't get past the corruption. Googling only brought back windows solutions to the corrupt tarball. I thought this very odd. Either I was missing something obvious or no one else had run into this issue.

I finally found a product for windows called gzrt which restored broken gzip files. It is a C program that comes with a make file. Of course, since I had a new install I didn't have a C compiler so I downloaded G++ the GNU C++ compile then found I was missing the zlib library which I also downloaded.

Once compiled, I lauched it against my corrupted backup
./gzrecover backup2.tar.gz

This made a file called backup2.tar.recover. Since tar doesn't work agianst bad files I used cpio to extract the data.
cpio -F backup2.tar.recovered -ivd

After that all was well. All my precious files came back.

Lessons learned include
1) FAT sucks.
2) Gzip and Tar should allow for more robustness.
3) Thank God for other geeks out there who have run into the same problem and taken the time to find a fix.

7 comments:

IRONMAN said...

I was able to recover all of my music because of your post...thanks!

Anonymous said...

I see now..
im trying to do a backup on a external usb with FAT.. and the tgz files seems to get stuck at 4-5 gb!
thanks for the tip, will try to reformat with FAT, or stick with ext3

R K Athey said...

I think that if you use both windoze and linux its a good idea to reformat your USB drives to NTFS. It doesn't have the same file size restrictions as FAT.

Anonymous said...

I know its a little late, but your post is showing up as a google search result.

The following might help someone:

tar --ignore-failed-read -B -i -xvf mytar.tar

(where tar is gnutar)

The issue is that if you have bad blocks on your disk, and you built the tar with --ignore-failed-read, i think tar will write zero blocks (two of which are normally treated as an EOF marker) instead of the bad data.

-i = ignore zero blocks in archive
-B = reblock as we read

This saved me from smashing another laptop to death...

R K Athey said...

I think I still have the busted file. I'll give your suggestions a shot to see if it works. Thanks.

Nicolas Deslions said...

I just recovered my system backup and a lot of important data with your help.
Thanks !!!

R K Athey said...

Glad it helped. :-)