b0rked partition table! halp!
December 12, 2006 6:38 AM   Subscribe

I have a SATA hard drive with all my data (yeah, I was just about to implement a backup scheme with rsync...), and my Ubuntu installation shit the bed. I'm back up, but the partition table on that drive is kablooey. It is formated ext3, and I have little reason to suspect that the data is not there. Are there any good tools for restoring a partition table on ext3, or can this be done natively? Gparted shows the file system marked as ext3, but with a warning about not being able to open dumpe2fs.

If it helps any, here's the result of fdisk -l:

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sda doesn't contain a valid partition table
posted by adampsyche to Computers & Internet (5 answers total) 1 user marked this as a favorite
The partition table and the filesystem are two different things. The partition table isn't something you "restore...on ext3," it's just a block at the front end of the disk. If you know your partition scheme (was it just one big honkin' partition?) you can write a fresh partition table from scratch using fdisk and the filesystem tools should be able to find your filesystem.

However, if you don't actually know what your partition scheme was -- down to the "cylinder" -- this is more or less guaranteed not to work.
posted by majick at 6:50 AM on December 12, 2006

To reiterate and expand on what majick said... You are confusing partitions with filesystems. There is nothing about a partition that makes it ext3 or ext2 or whatever. A partition is a logical block of space on the disk.

If you remember how you originally partitioned the disk, and you reproduce the partitioning steps exactly as you did originally, you should be able to remount the filesystems on there and get at your data. (Assuming your data wasn't damaged in the process, too.) Again, the partition table is just a header at the front of the disk that tells the OS where the partitions start and end. It has nothing to do with the data you stored in filesystems on those partitions.
posted by knave at 6:56 AM on December 12, 2006

Response by poster: Right, I'm aware of that, sorry if my language was confusing. That's why I'm certain that my data is there, etc. But, I'm not at all sure what the partition scheme was beyond a big honking partition. No idea where the cylinders are at, etc.
posted by adampsyche at 7:04 AM on December 12, 2006

I would first back up all the data on the drive with the partimage program. The SystemRescueCd is a bootable linux cd that contains partimage. You can use a program like gpart or partimage to guess where the partitions are and then rewrite the table but backing up the information first and then reinstalling the operating systems is safer and you won't have to worry about the integrity of your filesytem.
posted by calumet43 at 7:55 AM on December 12, 2006

If I were you, I'd rush out and buy another drive & use dd to make an exact copy of your current disk before touching anything at all. Then you can play with your data to your hearts content safe in the knowledge that if you do mess up, you can always get back to your current state.

If you've got some space handy on another drive but not enough for an image of the borked one, then piping the output of dd into gzip like so:

$ dd if=/dev/hda bs=128k | gzip > imagefile

(replacing hda with the appropriate device name obviously) might give you an image file small enough to fit. YMMV.

ddrescue may be handy if some of the disc is corrupt to the point of being unreadable.

gpart will try and guess where the original partitions were on your disc & will give you enough information to manually recreate them if it can.
posted by pharm at 8:00 AM on December 12, 2006

« Older Zip Code Proximity Search   |   Juicy Sushi goodness Newer »
This thread is closed to new comments.