Blew away my partition table

Eberhard Moenkeberg emoenke at gwdg.de
Tue Jun 29 15:22:48 CDT 2010


Hi,

On Tue, 29 Jun 2010, Jefferson Ogata wrote:
> 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.

Yes, it works only after reboot.

> 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).

A very good idea, to avoid the reboot.

> 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.

A nice collection. Thanks, I will keep it in case i get into partition 
table trouble.


Viele Gruesse
Eberhard Moenkeberg (emoenke at gwdg.de, em at kki.org)

-- 
Eberhard Moenkeberg
Arbeitsgruppe IT-Infrastruktur
E-Mail: emoenke at gwdg.de      Tel.: +49 (0)551 201-1551
-------------------------------------------------------------------------
Gesellschaft fuer wissenschaftliche Datenverarbeitung mbH Goettingen (GWDG)
Am Fassberg 11, 37077 Goettingen
URL:    http://www.gwdg.de             E-Mail: gwdg at gwdg.de
Tel.:   +49 (0)551 201-1510            Fax:    +49 (0)551 201-2150
Geschaeftsfuehrer:           Prof. Dr. Bernhard Neumair
Aufsichtsratsvorsitzender: Dipl.-Kfm. Markus Hoppe
Sitz der Gesellschaft:     Goettingen
Registergericht:           Goettingen  Handelsregister-Nr. B 598
-------------------------------------------------------------------------



More information about the Linux-PowerEdge mailing list