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.
Now run "gpart /dev/<your disk>", 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.
In case gpart fails completely I can only point out some other similar
tools which may help you. There is a tool called rescuept by Andries
Brouwer which is included in the non-installed part of util-linux (you
can find them on almost every Linux ftp site). Another tool is Gordon Chaffees
fixdisktable.
Good luck. |