3.  Disk Partition Rescue

If the disk partition is corrupted then use these techniques given below:

3.1.  Partition Repair Tools

The following tools are available:

3.2.  GPart Utility

If you're trying to rescue a system with a corrupted partition table on the main (boot) disk which is unable to boot you have two options:

  • the easiest way is to find a working system where you can add your disk. In case the other system cannot report the disk's correct geometry, note down its geometry prior to moving to the working system and tell gpart about it (use the "-C c,h,s" option).

  • download the gpart binary above, rename it to "gpart", store it on a floppy disk, print out the manual page above, and start your system by using your prefered boot disk.

After booting, look if your hard disk has been detected by your system by entering a shell and typing "dmesg". Under e.g. Linux you should look out for lines like "hdc: ST320430A, 19569MB w/512kB Cache, CHS=39761/16/63". If you have booted with a rescue disk mount the floppy disk with gpart on, and cd to the mount point.

# To read the online manual page on gpart do :
bash$ man gpart

bash$ gpart --help
gpart: invalid option -- -
Usage: gpart [options] device
Options: [-b <backup MBR>][-C c,h,s][-c][-d][-E][-e][-f][-g][-h][-i]
         [-K <last sector>][-k <# of sectors>][-L][-l <log file>]
         [-n <increment>][-q][-s <sector-size>][-t <module-name>]
         [-V][-v][-W <device>][-w <module-name,weight>]
gpart v0.1h (c) 1999-2001 Michail Brzitwa <michail@brzitwa.de>.
Guess PC-type hard disk partitions.

Now run "gpart /dev/[lt ]your disk[gt ]", e.g. "gpart /dev/hdc". Without any options, gpart performs a standard scan, and merely looks if it can guess a consistent primary partition table. A typical positive output looks like:

Begin scan...
Possible partition(DOS FAT), size(3999mb), offset(0mb)
Possible extended partition at offset(4000mb)
  Possible partition(Windows NTFS), size(3999mb), offset(4000mb)
  Possible partition(Linux ext2), size(3072mb), offset(8000mb)
  Possible partition(Linux ext2), size(3072mb), offset(11072mb)
Possible partition(Linux ext2), size(3072mb), offset(14144mb)
Possible partition(Linux ext2), size(2353mb), offset(17216mb)
End scan.
Checking partitions...
Partition(DOS or Windows 95 with 32 bit FAT): primary
  Partition(OS/2 HPFS, NTFS, QNX or Advanced UNIX): logical
  Partition(Linux ext2 filesystem): logical
  Partition(Linux ext2 filesystem): logical
Partition(Linux ext2 filesystem): primary
Partition(Linux ext2 filesystem): primary
Ok.
Guessed primary partition table:
Primary partition(1)
  type: 011(0x0B)(DOS or Windows 95 with 32 bit FAT)
  size: 3999mb #s(8191953) s(63-8192015)
  chs:  (0/1/1)-(1023/15/63)d (0/1/1)-(8126/15/63)r
Primary partition(2)
  type: 005(0x05)(Extended DOS)
  size: 10144mb #s(20775888) s(8192016-28967903)
  chs:  (1023/15/63)-(1023/15/63)d (8127/0/1)-(28737/15/63)r
Primary partition(3)
  type: 131(0x83)(Linux ext2 filesystem)
  size: 3072mb #s(6291456) s(28967904-35259359)
  chs:  (1023/15/63)-(1023/15/63)d (28738/0/1)-(34979/8/24)r
Primary partition(4)
  type: 131(0x83)(Linux ext2 filesystem)
  size: 2353mb #s(4819248) s(35259840-40079087)
  chs:  (1023/15/63)-(1023/15/63)d (34980/0/1)-(39760/15/63)r

Now if after the check-phase it says Ok, you should check the proposed partition table very carefully. After that you may write back the guessed table by calling "gpart -W /dev/hdc /dev/hdc" (exchange /dev/hdc with your disk device). When gpart has successfully written the new primary partition table, cross your fingers and reboot.

If gpart says it found inconsistencies, you are a bit on your own. What you can do is to fiddle with gparts numerous options. For example, to scan on sector boundaries instead of head boundaries, give it the "-n s" option. Normally gpart skips the disk space a possible partition seems to occupy, to really scan the whole disk, add the "-f" option. Read the man page and improvise.

The gpart tries to guess which partitions are on a hard disk. If the primary partition table has been lost, overwritten or destroyed the partitions still exist on the disk but the operating system cannot access them.

gpart ignores the primary partition table and scans the disk (or disk image, file) sector after sector for several filesystem/partition types. It does so by "asking" filesystem recognition modules if they think a given sequence of sectors resembles the beginning of a filesystem or partition type. Currently the following filesystem types are known to gpart (listed by module names) : beos, bsddl, ext2, fat, hmlvm, lswap, minix, ntfs, qnx4, rfs, s86dl, xfs.

3.3.  Partition Rescue Mini-Howto

See also "http://www.tldp.org/HOWTO/mini/Partition-Rescue/index.html"