Blew away my partition table

Jefferson Ogata poweredge at antibozo.net
Tue Jun 29 15:06:56 CDT 2010


On 2010-06-29 19:44, Eberhard Moenkeberg wrote:
> On Tue, 29 Jun 2010, J. Epperson wrote:
>> Arrived home very tired and in a lapse of judgement tried to configure a
>> new USB backup drive on my PERC3 based home server, with a new cat roaming
>> between me and the monitor.  Created a new partition on the existing
>> /dev/sda instead of the new /dev/sdb.  System is still running, and I"m
>> doing an rsync to the new drive now.
>>
>> Can some kind soul help me remember how to repair this surgically instead
>> of rebuilding the filesystem and reloading it?  If not, I deserve it.
> 
> You just need to revert the partition table change.
> If you do not have a backup of the master boot record (LILO would have 
> one), you can use the df output to estimate the right cylinder numbers.

/proc/partitions is possibly a better reference.

> If you need trial and error to find the boundaries, "tune2fs -l /dev/sdaX" 
> is a non-destructive test.

Doubtful that will work; it will refer to the old partition table the 
kernel is still using.

You should be able to use dmsetup to create device nodes with offset 
into /dev/sda if you want to do this. But you should be able to find 
your filesystem headers with dd and xxd (or any hexdump program).

Where to look:

- The first partition starts one track into the disk; typically that's 
63 512-byte sectors.

- The second, third, and fourth partitions are usually on cylinder 
boundaries, with a cylinder typically being 63 * 255 512-byte sectors.

- If you had more than four partitions, then the last physical partition 
has a partition table at the beginning. The first logical partition will 
begin one track into that physical partition.

What to look for:

- For ext3 filesystems, a superblock begins 1024 bytes into the 
partition. At offset 0x38 in the superblock you should find the magic 
number 0x53ef (big-endian).

- For swap partitions, look at the first 4096 bytes. At the end of that 
page you should find the string SWAPSPACE2.

- For LVM physical volumes you should see an LVM label 512 bytes from 
the beginning of the partition.



More information about the Linux-PowerEdge mailing list