Re: Getting table of partition from one disk?

Mike A. Harris (mharris@meteng.on.ca)
Sun, 31 Oct 1999 15:30:41 -0500 (EST)


On Sun, 31 Oct 1999, Grégoire Favre wrote:

>I have 3 hard disk in ma machine, one IDE and two SCSI. I just
>played with windows 98 and my second SCSI disk come with just
>one big (more that 8 Gb) partition instead of the ten little I
>had on it (in the order: sdb1:NTFS,sdb2:/boot,sdb3:/usr/src,
>sdb5:/data,sdb6:/home,sdb7:fat 16,sdb8:linux swap,sdb9:NTFS,
>sdb10:/) and I also know the approximate size of each partitions.

Just some words of wisdom for EVERYONE out there. Immediately
after setting up any hard disk, and every time you modify a
partition table _ever_, you should IMMEDIATELY do:

dd if=/dev/hda of=/root/hostname-hda-todaysdate.ptbl bs=512 count=1

Where "hda" is the actual device you're backing up, "hostname" is
the actual hostname of the machine, "todaysdate" is today's date
in some filename friendly, and y2k friendly format.

This backs up the first sector of the device, which is where the
partition table exists. Personally, I back up the entire first
cylinder instead by changing "count=1" to "count=63".

Note also that any "extended partition tables" should also be
backed up too as should any other sectors on disk that indicate
some other format of partitioning such as BSD disklabel, and all
other things Linux supports.

I'm not aware of any software which does this automatically,
however it wouldn't be too hard I don't think to write such
software.

>Is there a way to reconstruct the table of partition?
>I know that the data are still there: cat /dev/sdb...

Only if you know where the partition boundaries lay. If all
partitions are of known formats which you can locate, you can
scan the disk looking for the beginning point and end point of
the various partitions. I *STRONGLY* recommend duplication of
the raw disk with "dd" to an alternate device or backup tape, so
that if you hose something while attempting a recovery, you can
get another chance.

There is software on Sunsite I believe that will scan your hard
disk and try to locate partition beginnings based on "magic"
data, and then tell you what it found. I don't know what the
program is called though...

>Please, cc all answer to greg@ulima.unil.ch as I am just near dead...

Hang in there! ;o) Disk recovery is very sensitive, it is
important to back up the entire disk NOW, before attempting any
changes.

>For all of you that have good table of partition: just fdisk p them
>and print that, it could be of some use...

Not much. Someone else's partition table would be useless to
you. If you don't have partition table backups, your ONLY
recourse is:

1) Using software to scan for partitions and recreate them either
automatically, or manually afterward.

2) Sending the drive to a data recovery place, which will cost
you an arm and a leg.

3) Chocking it up to experience, and making a strong mental note
to backup partition tables on every machine you ever get your
hands on. ;o)

That is about it...

Good luck!
TTYL

--
Mike A. Harris                                     Linux advocate     
Computer Consultant                                  GNU advocate  
Capslock Consulting                          Open Source advocate

Join the FreeMWare project - the goal to produce a FREE program in which you can run Windows 95/98/NT, and other operating systems.

http://www.freemware.org

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/