gpart is a software utility which scans a
storage device, examining the data in order to detect
partitions which may exist but are absent from the disk's partition tables. Gpart was written by Michail Brzitwa of
Germany
Germany, officially the Federal Republic of Germany, is a country in Central Europe. It lies between the Baltic Sea and the North Sea to the north and the Alps to the south. Its sixteen States of Germany, constituent states have a total popu ...
. The release on the author's website is now older than the releases some distributions are using. It appears that Michail Brzitwa does not actively maintain the code, instead the various distributions (I.E.
Fedora
A fedora () is a hat with a soft brim and indented crown.Kilgour, Ruth Edwards (1958). ''A Pageant of Hats Ancient and Modern''. R. M. McBride Company. It is typically creased lengthwise down the crown and "pinched" near the front on both sides ...
or
Debian
Debian () is a free and open-source software, free and open source Linux distribution, developed by the Debian Project, which was established by Ian Murdock in August 1993. Debian is one of the oldest operating systems based on the Linux kerne ...
) appear to maintain their own versions.
gpart tries to guess partitions from any device that can be partitioned, even a file. If the primary partition table has been lost, overwritten or destroyed the partitions still exist on the media 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.
Michail Brzitwa,
man page"gpart(8) - Linux man page", January 2001
A list of these modules are listed below. Also modules can be written for future
filesystems and used in the detection process.
If recovering partitions is needed that are damaged on the only bootable disk in a machine, a
live CD
A live CD (also live DVD, live disc, or live operating system) is a complete booting, bootable computer installation including operating system which runs directly from a CD-ROM or similar storage device into a computer's memory, rather than lo ...
can be used such as
knoppix
Knoppix, stylized KNOPPIX ( ), is an operating system based on Debian designed to be run directly from a CD or DVD (Live CD) or a USB flash drive ( Live USB). It was first released in 2000 by German Linux consultant Klaus Knopper, and was one ...
to start the machine and use the utilities from the disk.
It is also good at finding and listing the types, locations, and sizes of inadvertently-deleted partitions, both primary and logical. It gives you the information you need to manually re-create them (using
fdisk
fdisk is a command-line utility for disk partitioning. It has been part of DOS, DR FlexOS, IBM OS/2, and early versions of Microsoft Windows, as well as certain ports of FreeBSD, NetBSD, OpenBSD, DragonFly BSD and macOS for compatibilit ...
,
cfdisk
cfdisk is a Linux partition editor, similar to fdisk, but with a different, curses (programming library), curses-based user interface. It is part of the util-linux package of Linux utility programs.
The current cfdisk implementation utilizes th ...
,
sfdisk, etc.). The guessed partition table can also be written to a file or (if you firmly believe the guessed table is entirely correct) directly to a disk device.
With some badly damaged devices it is a good idea to use a utility such as
ddrescue to make a
backup
In information technology, a backup, or data backup is a copy of computer data taken and stored elsewhere so that it may be used to restore the original after a data loss event. The verb form, referring to the process of doing so, is "wikt:back ...
. Then when you have a copy of the device, use gpart to guess the partitions on the copy. If it is successful, you can try writing them back to the device. You may find that when using
ddrescue you get read errors because the device is damaged but if you can get the partitions readable with your copy then you can try using
Mount (Unix)
In computing, mount is a command in various operating systems. Before a user can access a file on a Unix-like machine, the file system on the device which contains the file needs to be mounted with the mount command. Frequently mount is used fo ...
and retrieve the data from the copy.
$ mount -t
/path/to/imagefile -o loop,offset= /mnt/loop
This will mount the partition at offset on /mnt/loop so you can recover your data from the file.
To get the partition offset you can use either fdisk
fdisk is a command-line utility for disk partitioning. It has been part of DOS, DR FlexOS, IBM OS/2, and early versions of Microsoft Windows, as well as certain ports of FreeBSD, NetBSD, OpenBSD, DragonFly BSD and macOS for compatibilit ...
-ul /path/to/imagefile or use the output from gpart.
Look at the sample output at the size line, the last pair of round brackets has the start (16) and then end (3906559).
When specifying the offset, always specify the start.
Sample output
This is sample output from a scan of an 8GB flash memory stick with two partitions, one FAT16B
File Allocation Table (FAT) is a file system developed for personal computers and was the default file system for the MS-DOS and Windows 9x operating systems. Originally developed in 1977 for use on floppy disks, it was adapted for use on h ...
2GB partition and one xfs
XFS is a high-performance 64-bit journaling file system created by Silicon Graphics, Inc (SGI) in 1993. It was the default file system in SGI's IRIX operating system starting with its version 5.3. XFS was ported to the Linux kernel in 2001; a ...
6GB partition.
Begin scan...
Possible partition (DOS FAT), size (1907mb), offset (0mb)
Possible partition (SGI XFS filesystem), size (5730mb), offset (1907mb)
End scan.
Checking partitions...
Partition (DOS or Windows 95 with 32 bit FAT, LBA): primary
Partition (Linux ext2 filesystem): primary
Ok.
Guessed primary partition table:
Primary partition(1)
type: 012 (0x0C) (DOS or Windows 95 with 32 bit FAT, LBA)
size: 1907mb #s(3906544) s(16-3906559)
chs: (0/1/1)-(1023/19/16)d (0/1/1)-(12207/19/16)r
Primary partition(2)
type: 131 (0x83)(Linux ext2 filesystem)
size: 5730mb #s(11736000) s(3906560-15642559)
chs: (1023/19/16)-(1023/19/16)d (12208/0/1)-(48882/19/16)r
Primary partition(3)
type: 000 (0x00)(unused)
size: 0mb #s(0) s(0-0)
chs: (0/0/0)-(0/0/0)d (0/0/0)-(0/0/0)r
Primary partition(4)
type: 000 (0x00)(unused)
size: 0mb #s(0) s(0-0)
chs: (0/0/0)-(0/0/0)d (0/0/0)-(0/0/0)r
Partition types
Supported (guessable) filesystem or partition types:
* BeOS Be File System
The Be File System (BFS) is the native file system for the BeOS. In the Linux kernel, it is referred to as "BeFS" to avoid confusion with Boot File System.
BFS was developed by Dominic Giampaolo and Cyril Meurillon over a ten-month period, st ...
.
* FreeBSD
FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
/NetBSD
NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was fork (software development), forked. It continues to ...
/386BSD
386BSD (also known as "Jolix") is a Unix-like operating system that was developed by couple Lynne and William "Bill" Jolitz. Released as free and open source in 1992, it was the first fully operational Unix built to run on IBM PC-compatible s ...
BSD disklabel sub-partitioning scheme used on Intel platforms.
* IBM OS/2
OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
High Performance File System
HPFS (High Performance File System) is a file system created specifically for the OS/2 operating system to improve upon the limitations of the FAT file system. It was written by Gordon Letwin and others at Microsoft and added to OS/2 version ...
(HPFS).
* Linux ext2
ext2, or second extended file system, is a file system for the Linux kernel (operating system), kernel. It was initially designed by French software developer Rémy Card as a replacement for the extended file system (ext). Having been designed ...
(second extended filesystem).
* Linux LVM (Logical Volume Manager) physical volumes.
* Linux swap partitions (versions 0 and 1).
* The Minix
MINIX is a Unix-like operating system based on a microkernel Software architecture, architecture, first released in 1987 and written by American-Dutch computer scientist Andrew S. Tanenbaum. It was designed as a clone of the Unix operating syste ...
operating system filesystem type.
* DOS and Windows 9x
Windows 9x is a generic term referring to a line of discontinued Microsoft Windows operating systems released from 1995 to 2000 and supported until 2006, which were based on the kernel introduced in Windows 95 and modified in succeeding version ...
FAT12
File Allocation Table (FAT) is a file system developed for personal computers and was the default file system for the MS-DOS and Windows 9x operating systems. Originally developed in 1977 for use on floppy disks, it was adapted for use on ...
, FAT16
File Allocation Table (FAT) is a file system developed for personal computers and was the default file system for the MS-DOS and Windows 9x operating systems. Originally developed in 1977 for use on floppy disks, it was adapted for use on Ha ...
and FAT32
File Allocation Table (FAT) is a file system developed for personal computers and was the default file system for the MS-DOS and Windows 9x operating systems. Originally developed in 1977 for use on floppy disks, it was adapted for use on ...
filesystems.
* Microsoft Windows NT
Windows NT is a Proprietary software, proprietary Graphical user interface, graphical operating system produced by Microsoft as part of its Windows product line, the first version of which, Windows NT 3.1, was released on July 27, 1993. Original ...
and later NTFS
NT File System (NTFS) (commonly called ''New Technology File System'') is a proprietary journaling file system developed by Microsoft in the 1990s.
It was developed to overcome scalability, security and other limitations with File Allocation Tabl ...
filesystem.
* ReiserFS
ReiserFS is a general-purpose, journaling file system initially designed and implemented by a team at Namesys led by Hans Reiser and licensed under GPLv2. Introduced in version 2.4.1 of the Linux kernel, it was the first journaling file syst ...
(version 3.5.X, X > 11).
* XFS
XFS is a high-performance 64-bit journaling file system created by Silicon Graphics, Inc (SGI) in 1993. It was the default file system in SGI's IRIX operating system starting with its version 5.3. XFS was ported to the Linux kernel in 2001; a ...
, Silicon Graphics' journaling file system
A journaling file system is a file system that keeps track of changes not yet committed to the file system's main part by recording the goal of such changes in a data structure known as a " journal", which is usually a circular log. In the ev ...
for Linux.
* Oracle Solaris
Oracle Solaris is a proprietary Unix operating system offered by Oracle for SPARC and x86-64 based workstations and servers. Originally developed by Sun Microsystems as Solaris, it superseded the company's earlier SunOS in 1993 and became kno ...
on Intel platforms uses a sub-partitioning scheme on PC hard disks similar to the BSD disklabels.
* QNX
QNX ( or ) is a commercial Unix-like real-time operating system, aimed primarily at the embedded systems market.
The product was originally developed in the early 1980s by Canadian company Quantum Software Systems, founded March 30, 1980, and l ...
4.x filesystem.
* Other types may be added relatively easily, as separately compiled modules.
See also
* TestDisk – another partition recovery tool
* fdisk
fdisk is a command-line utility for disk partitioning. It has been part of DOS, DR FlexOS, IBM OS/2, and early versions of Microsoft Windows, as well as certain ports of FreeBSD, NetBSD, OpenBSD, DragonFly BSD and macOS for compatibilit ...
, cfdisk
cfdisk is a Linux partition editor, similar to fdisk, but with a different, curses (programming library), curses-based user interface. It is part of the util-linux package of Linux utility programs.
The current cfdisk implementation utilizes th ...
, gparted
GParted is a GTK front-end to GNU Parted and an official GNOME partition-editing application (alongside GNOME Disks, Disks). GParted is used for creating, deleting, resizing, moving, checking, and copying Partition (computing), disk partitions a ...
- partition editors
* Knoppix
Knoppix, stylized KNOPPIX ( ), is an operating system based on Debian designed to be run directly from a CD or DVD (Live CD) or a USB flash drive ( Live USB). It was first released in 2000 by German Linux consultant Klaus Knopper, and was one ...
References
{{reflist
External links
gpart – Guess PC-type hard disk partitions
gpart(8): guess PC-type hard disk partitions
(Linux ''man'' page)
CLI Magic: Salvage lost partitions with gpart
(Linux.com)
Unix file system-related software
Free partitioning software