NAME
gpart - guess PC-type hard disk partitionsSYNOPSIS
gpart [options] deviceDESCRIPTION
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.- beos
- BeOS filesystem type.
- bsddl
- FreeBSD/NetBSD/386BSD disklabel sub-partitioning scheme used on Intel platforms.
- ext2
- Linux second extended filesystem.
- fat
- MS-DOS FAT12/16/32 "filesystems".
- hpfs
- IBM OS/2 High Performance filesystem.
- hmlvm
- Linux LVM physical volumes (LVM by Heinz Mauelshagen).
- lswap
- Linux swap partitions (versions 0 and 1).
- minix
- The Minix operating system filesystem type.
- ntfs
- MS Windows NT/2000 filesystem.
- qnx4
- QNX 4.x filesystem.
- reiserfs
- The Reiser filesystem (version 3.5.X, X > 11, 3.6.X).
- s86dl
- Sun Solaris on Intel platforms uses a sub-partitioning scheme on PC hard disks similar to the BSD disklabels.
- xfs
- Silicon Graphic's journalling filesystem for Linux.
EXTENDED PARTITIONS
If the disk/file to be examined consists of primary partitions only, gpart has quite a good chance to identify them. Extended partitions on the other hand can result in a lot of problems.DISK TRANSFERS
If you want to investigate hard disks from other systems you should note down the geometry (number of cylinders, heads per cylinder and sectors per head) used for that disk, and tell gpart about this geometry.LARGE DISKS
gpart relies on the OS reporting the correct disk geometry. Unfortunately sometimes the OS may report a geometry smaller the the actual one (e.g. disks with more than 1024 or 16384 cylinder).gpart -C 1028,255,63 <other options>
<device>
PRECAUTIONS
gpart may be of some help when the primary partition table was lost or destroyed but it can under no circumstances replace proper disk/partition table backups. To save the master boot record (MBR) including the primary partition table to a file typedd if=/dev/hda of=mbr bs=512 count=1
dd if=mbr of=/dev/hda bs=1 count=64 skip=446
seek=446
OPTIONS
- -b backupfile
- If the guessed primary partition table seems consistent and should be written (see the -W option) backup the current MBR into the specified file.
- -C c,h,s
- Set the disk geometry (cylinders, heads, sectors) for the scan. This is useful if a disk should be scanned which was partitioned using a different geometry, if the device is a disk-image or if the disk geometry cannot be retrieved through the PCs BIOS. No spaces are allowed between the numbers, unless all three are enclosed in quotes.
- -c
- Check/compare mode (implies the -q quiet option). After the scan is done, the resulting primary partition table is compared to the existing one. The return code of gpart then contains the number of differences (0 if they are identical except for the boot/active flag which cannot be guessed). This option has no effect if -d is given on the command line.
- -d
- Do not start the guessing loop. Useful if the partition table should be printed (in combination with the -v option) without actually scanning for partitions.
- -E
- Do not try to identify extended partition tables. If there are extended partitions on the given device gpart will most certainly complain about too many primary partitions because there can be only four primary partitions. Existing logical partitions will be listed as primary ones.
- -e
- Do not skip disk read errors. If this option is given, and short disk reads or general disk read errors (EIO) are encountered, gpart will exit. If not given, the program tries to continue.
- -f
- Full scan. When a possible partition is found, gpart normally skips all sectors this entry seems to occupy and continues the scan from the end of the last possible partition. The disk scan can take quite a while if this option is given, be patient.
- -g
- Do not try to get the disk geometry from the OS. If the device is no block or character device but a plain file this option should be supplied. If the file to be scanned is an image of a disk, the geometry can be given by the -C option.
- -h
- Show some help.
- -i
- Run interactively. Each time a possible partition is identified the user is asked for confirmation.
- -K last sector
- Scan only up to the given sector or the end of the file or device whichever comes first.
- -k sectors
- Skip given number of sectors before the scan. Potentially useful if a partition is looked for at the end of a large disk.
- -L
- List available filesystem/partition type modules and their weights, then exit.
- -l logfile
- Log output to the given file (even if -q was supplied).
- -n increment
- Scan increment: number of sectors or "s" for single sector increment, "h" for an increment of sectors per head (depends on geometry) or "c" for cylinder increment. The increment also influences the condition where extended partition tables are searched: if the scan increment is "s" (i.e. 1) extended partition tables are required to be on a head boundary, otherwise they must be on a cylinder boundary. If the disk geometry could not be retrieved and no geometry was given on the command line, the default increment is one sector.
- -q
- Quiet/no output mode. However if a logfile was specified (see -l option) all output is written to that file. This option overrides the -i interactive mode.
- -s sector size
- Preset medium sector size. gpart tries to find out the sector size but may fail in doing so. Probed sector sizes are 2^i, i=9..14 (512 to 16384 bytes). The default medium sector size is 512 bytes.
- -V
- Show version number.
- -v
- Be verbose. This option can be given more than once resulting in quite a lot of information.
- -W device
- Write partition table. If a consistent primary partition table has been guessed it can be written to the specified file or device. The supplied device can be the same as the scanned one. Additionally the guessed partition entries can be edited. No checks are performed on the entered values, thus the resulting table is allowed to be highly inconsistent. Please beware. Warning: The guessed partition table should be checked very carefully before writing it back. You can always write the guessed partition table into a plain file and write this into sector 0 using dd(1) (see section PRECAUTIONS above).
- -w module name,weight
- Put the given module at the head of the module chain and assign a new weight to that module. All modules are given an initial weight of 1.0. Again no spaces are allowed.
EXAMPLES
- To scan the first IDE hard disk under Linux using default settings typegpart /dev/hda
gpart -vvd /dev/wd2
gpart -vdg /boot/boot.0300
gpart -k 1 -n s /dev/hdb
gpart -w ntfs,1.5 /dev/hdb
gpart -W /dev/sdc /dev/sdc
gpart -k 1008 -n 126 /dev/sda
gpart -vvfn s -ql /tmp/gpart.log /dev/sd2
&
FILES
/dev/*Hard disk block devices. The naming scheme of
hard disk block devices is OS dependent, consult your system manuals for more
information.
DIAGNOSTICS
There are many error message types, all of them should be self-explanatory. Complain if they are not.BUGS
gpart is beta software, so expect buggy behaviour.TO DO
- Support big-endian architectures.AUTHOR
Please send bug reports, suggestions, comments etc. toMichail Brzitwa
<[email protected]>
SEE ALSO
fdisk(8).January 2001 | Administration Tools |