Famiarize yourself with TestDisk. It will run on many platforms, and supports many different kinds of partitions. We were able to compile the source on two different machines (GNU/Linux and Mac OS X Tiger). One problem with compiling on Mac OS X is that the ext2 libraries are not available. This was, of course, not an issue on our GNU/Linux box:
[root@srv-1 testdisk-6.2-WIP]# ./configure checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... gcc checking for C compiler default output file name... a.out . . . checking for ext2fs_open in -lext2fs... yes . . . [root@srv-1 testdisk-6.2-WIP]# make make all-recursive make[1]: Entering directory `/usr/local/src/testdisk-6.2-WIP' Making all in src . . . make[2]: Leaving directory `/usr/local/src/testdisk-6.2-WIP' make[1]: Leaving directory `/usr/local/src/testdisk-6.2-WIP' [root@srv-1 testdisk-6.2-WIP]# |
One cool thing about this utility is you can make an image of the drive, and then operate on that image. You don’t have to be worried about completely hosing your data if you make a mistake, since as long as you make a backup of that image file, you can always apply the old one back to the drive in a pinch, or mount the image off of another system. It is a good idea with a failing drive to make an image if possible. See this article for an easy way to make an image of a hard drive. We used a small 500 meg image of a drive to test TestDisk:
[usr-1@srv-1 ~]$ /usr/local/sbin/testdisk c.img Disk c.img - 499 MB - CHS 1015 16 63 [Analyse ] [Advanced] [Geometry] [Options ] [ Delete ] [MBR Code] [ Quit ] |
Let’s analyse the current partition structure and search for lost partitions:
Disk c.img - 499 MB - CHS 1015 16 63 Partition Start End Size in sectors Structure: Ok. Use arrow keys to change partition characteristics: *=Primary bootable P=Primary L=Logical E=Extended D=Deleted Keys A: add partition, L: load backup, T: change type, P: list files, ENTER: to continue EXT2 Sparse superblock, 499 MB |
Here is our partition:
* Linux 0 1 1 1014 15 63 1023057 |
We can browse the files:
Directory /etc drwxr-xr-x 0 0 3072 2-Nov-2005 17:43 . drwxr-xr-x 0 0 1024 2-Nov-2005 14:49 .. -rw------- 0 0 0 2-Nov-2003 04:24 .pwd.lock drwxr-xr-x 0 0 1024 12-Nov-2004 12:32 Net drwxr-xr-x 0 0 1024 20-Feb-2005 02:10 X11 -rw-r--r-- 0 0 254 12-Nov-2004 11:53 adduser.conf -rw-r--r-- 0 0 47 4-Apr-2003 02:50 adjtime -rw-r--r-- 0 0 345 12-Nov-2004 11:53 aliases -rw-r--r-- 0 0 12288 21-Dec-2001 22:45 aliases.db drwxr-xr-x 0 0 1024 12-Nov-2004 12:32 apm -rw-r--r-- 0 0 86 3-May-2003 19:29 aumixrc -rw-r--r-- 0 0 66 12-Nov-2004 11:53 auto.master -rw-r--r-- 0 0 444 5-Jan-2002 17:45 auto.misc -rw-r--r-- 0 0 306 23-Sep-2003 15:24 auto.mnt -rwxr-xr-x 0 0 466 12-Nov-2004 11:53 auto.net -rwxr-xr-x 0 0 1749 12-Nov-2004 11:53 automount.sh |
We can locate the superblock info:
Disk c.img - 499 MB - CHS 1015 16 63 Partition Start End Size in sectors Linux 0 1 1 1014 15 62 1023056 superblock 0, blocksize=1024 superblock 8193, blocksize=1024 superblock 24577, blocksize=1024 superblock 40961, blocksize=1024 superblock 57345, blocksize=1024 |
There are many other options as well.