[Wylug-help] Disaster recovery: how to use gpart properly

Dave Fisher wylug-help at davefisher.co.uk
Sun Feb 25 02:15:03 GMT 2007


On Sat, Feb 24, 2007 at 11:52:23PM +0000, shaun laughey wrote:
> http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Partition-Rescue.html

Thanks, once again, to Shaun for pointing out this HOWTO.

Unfortunately, I am struggling to get full use from it. Partly due to
the franglais, partly due to my own ignorance and partly, because my
case is not quite the same as those illustrated.

I'd appreciate advice and comments before I write anything to disk.

Following the HOWTO, I set gpart to guess where my partitions might be:

    $ sudo gpart /dev/hda
    
    Begin scan...
    Possible partition(Windows NT/W2K FS), size(54mb), offset(0mb)
    Possible partition(Windows NT/W2K FS), size(30921mb), offset(54mb)
    Possible partition(Linux swap), size(368mb), offset(30976mb)
    Possible partition(Linux ext2), size(41346mb), offset(31345mb)
    Possible partition(DOS FAT), size(3584mb), offset(72700mb)
    End scan.
    
    Checking partitions...
    
    * Warning: more than 4 primary partitions: 5.
    Partition(OS/2 HPFS, NTFS, QNX or Advanced UNIX): primary 
    Partition(OS/2 HPFS, NTFS, QNX or Advanced UNIX): primary 
    Partition(Linux swap or Solaris/x86): primary 
    Partition(Linux ext2 filesystem): primary 
    Partition(DOS or Windows 95 with 32 bit FAT): invalid primary 
    Ok.
    
    Guessed primary partition table:
    Primary partition(1)
       type: 007(0x07)(OS/2 HPFS, NTFS, QNX or Advanced UNIX)
       size: 54mb #s(112392) s(63-112454)
       chs:  (0/1/1)-(111/8/63)d (0/1/1)-(111/8/63)r
    
    Primary partition(2)
       type: 007(0x07)(OS/2 HPFS, NTFS, QNX or Advanced UNIX)
       size: 30921mb #s(63328224) s(112455-63440678)
       chs:  (111/9/1)-(1023/15/63)d (111/9/1)-(62937/2/57)r
    
    Primary partition(3)
       type: 130(0x82)(Linux swap or Solaris/x86)
       size: 368mb #s(754984) s(63440748-64195731)
       chs:  (1023/15/63)-(1023/15/63)d (62937/4/1)-(63686/3/55)r
    
    Primary partition(4)
       type: 131(0x83)(Linux ext2 filesystem)
       size: 41346mb #s(84678552) s(64195803-148874354)
       chs:  (1023/15/63)-(1023/15/63)d (63686/5/1)-(147692/12/63)r

The MB sizes and offsets more or less match my memory of the original
partition table.

It was arranged, pretty-much, like so:

    /dev/hda1      54 MB   primary    NTFS
    /dev/hda2   30921 MB   primary    NTFS
    /dev/hda3   41714 MB   extended   
      /dev/hda5   368 MB   logical    Linux Swap
      /dev/hda6 41345 MB   logical    Ext3/ext2
    /dev/hda4    3584 MB   primary    FAT 32 

N.B. The figures are from gpart, not my records.

In otherwords, gpart has found the 3 primary and 2 logical partitions,
but 'mislaid' the extended partition which contains the logical partitions.

As a consequence it mistakes hda5 and hda6 for primaries and, hence,
wrongly considers hda4 to be an invalid primary.

The HOWTO deals with how to find logical partitions within an extended
partition, but that's the opposite of my problem, i.e.  I need to
identify the precise start and end of the extended partition itself,
since gpart appears to have already found the partitions contained
within it.

My other big problem is figuring out how to write a new partition table
properly. In particular, how to set the begining and end of partitions
accurately.
    
I obviously need to get my head around the use of cylinders, heads,
sectors (CHS) again ... that's stuff I forgot almost a decade ago :-(

Can anyone give me pointers on how to put the extended partition back in
the right place?

Dave







More information about the Wylug-help mailing list