Last Web page update: 10/14/2013, referencing FixParts version 0.8.8
I'm a technical writer and consultant specializing in Linux technologies. This Web page, and the associated software, is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find GPT fdisk or this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!
|Donate $1.00||Donate $2.50||Donate $5.00||Donate $10.00||Donate $20.00||Donate another value|
The FixParts program is an offshoot of my GPT fdisk (gdisk, cgdisk, and sgdisk) software. FixParts is a text-mode tool for Linux, FreeBSD, Mac OS X, and Windows that's designed to correct some common problems with computer partition tables. The usual symptom of the problems FixParts is intended to fix is a disk that shows no partitions in GParted or similar tools, although you know the disk to contain partitions because they're visible to the Linux kernel or to other partitioning software. This page describes the symptoms in more detail.
FixParts is a specialized partitioning tool. It has three main design goals, although it can do a few other things as well:
If this talk of primary, extended, and logical partitions has you scratching your head, take a detour and read this page on the topic. One small correction: In terms of the on-disk data structures, the theoretical limit on the number of logical partitions is approximately 2 billion. I myself have created a disk with over 128 logical partitions. I've never heard of a serious installation using more than one or two dozen partitions, though. FixParts has a limit of 128 partitions.
I do not recommend using FixParts for routine partitioning tasks such as deleting partitions, changing the active/bootable flag, or changing type codes. Although the program can do these things, these features are provided as conveniences when repairing more serious problems. The reason to not use FixParts for such routine tasks is that FixParts is not shy about making changes to partition numbering that might require changing the /etc/fstab file or boot loader configuration. Making such changes is a small price to pay if you've got a real problem with your disk, but it's an undesirable nuisance if your disk's data structures are legal. Thus, I recommend using fdisk, parted, GParted, or some other tool for routine partitioning tasks.
You can obtain FixParts from its download page on SourceForge. You'll find binary packages for RPM (used by Fedora, Red Hat, Mandriva, OpenSUSE, and several others), Debian packages (used by Debian, Ubuntu, and several others), Mac OS X, and Windows. The source code is part of the main GPT fdisk source package in the main download directory.
Once you've downloaded the binary file, you can install it. In Linux and OS X, double-clicking the file will usually launch an installer. In Windows, you should extract the fixparts.exe binary and install it somewhere on your path or use it directly, as described in the README.Windows file. FreeBSD users will have to compile the software manually or install it via ports.
Before you launch FixParts, I strongly recommend you back up your current partition table, even if it's badly damaged. In Linux, you can use sfdisk to do this job:
# sfdisk -d /dev/sdc > parts.txt
This command, typed as root in Linux, backs up /dev/sdc's partition table to the file called parts.txt. (You should change /dev/sdc as appropriate for your system, of course.) You can then copy parts.txt to a floppy disk, USB flash drive, CD-R, or some other disk other than the one you intend to fix! If disaster strikes and FixParts makes matters worse, you'll be able to recover by reversing the operation:
# sfdisk -f /dev/sdc < parts.txt
I don't know the equivalent commands in other OSes, although I'd be shocked if you couldn't do it with fdisk or similar tools in FreeBSD or OS X. If you can't find documentation on this, try downloading PartedMagic or System Rescue CD, which are Linux-based emergency CDs that include Linux sfdisk.
To use FixParts, you must launch it and pass it a device filename, as in:
# fixparts /dev/sdc
Under Linux, FreeBSD, and Mac OS X, you must launch the program as root or using sudo (as in sudo fixparts /dev/sdc). Under Windows, you must launch the program using Administrator privileges, which you can acquire by locating the Command Prompt program icon, right-clicking it, and selecting "Run as Administrator." You can then run fixparts from this Command Prompt window.
If you neglect to include the device filename on the command line, fixparts will prompt for one. Device filenames take various forms depending on the OS:
The first check that the program performs is for stray GPT data. Such data can remain behind on a disk if it was previously used on a Macintosh or in some other ways, then re-used as a conventional MBR disk. Although such leftover data should not technically be a problem because the GPT specification clearly states that such disks are not GPT disks and should therefore be treated as MBR disks, some utilities can be confused by the presence of both MBR and GPT data. Thus, FixParts checks for this condition when it starts. If it finds leftover GPT data, it warns you of this fact and asks you what to do:
NOTICE: GPT signatures detected on the disk, but no 0xEE protective partition! The GPT signatures are probably left over from a previous partition table. Do you want to delete them (if you answer 'Y', this will happen immediately)? (Y/N):
If you're not sure whether to delete the GPT data, don't do it; type N, exit from the program by typing q at the main prompt, and investigate further. If you're certain you want to keep just the MBR partitions, go ahead and type Y. If the stray GPT data was your only problem, you can then exit from the program by typing q, leaving the original MBR partition table untouched, although the errant GPT data will now be gone.
With the program launched, you should see a brief greeting and a command prompt. I recommend typing p to view your partition table:
# fixparts /dev/sdc FixParts 0.8.8 Loading MBR data from /dev/sdc MBR command (? for help): p ** NOTE: Partition numbers do NOT indicate final primary/logical status, ** unlike in most MBR partitioning tools! ** Extended partitions are not displayed, but will be generated as required. Disk size is 3981312 sectors (1.9 GiB) MBR disk identifier: 0x00000000 MBR partitions: Can Be Can Be Number Boot Start Sector End Sector Status Logical Primary Code 1 * 62 1171799 primary Y 0x07 2 1171800 1562399 primary Y 0x83 3 1562462 3124799 primary Y Y 0x0C 5 3124862 3980213 logical Y Y 0xAF MBR command (? for help):
FixParts checks the validity of the partitions it finds on your disk and will automatically (and silently) make adjustments for certain problems it finds. Thus, you may discover that your partition table is fine at this point. It's also possible that you'll see some changes in primary vs. logical status, or even omitted partitions.
The FixParts display is similar to that of fdisk or gdisk (in fact, it's identical to gdisk's GPT-to-MBR displays), but some features require comment. First, as specified in the note that appears the first time you display your partitions, partition numbers in the first column are not necessarily correlated with primary/logical status, as they are with most Linux partitioning tools. For instance, if you were to change the status of partition #5 in the preceding output to primary, it would still be identified as partition #5; or you could sort the partitions, making them range in number from 1 to 4, but the last partition would remain logical. When you save your partitions, FixParts assigns them correctly, and the partition numbers you subsequently see in fdisk, GParted, or other tools might bear little resemblance to what you see in FixParts. This probably seems strange if you're used to Linux's fdisk or most other partitioning tools. I designed FixParts in this way because many of its features could make for a very confusing user interface if the partition numbers were kept synchronized with the usual primary/logical assignments.
A second notable fact is that this partition list includes no mention of extended partitions. If you don't know what this means, don't worry about it. If you do know what it means, you may want to know that FixParts discards the disk's extended partition as a matter of course and generates a new one when you save the partition table.
The Can Be Logical and Can Be Primary columns specify whether you can convert a partition into a logical or primary partition now, given other current assignments. As described later, these columns' contents are likely to change as you make changes to the partitions.
Warning: Some operating systems, such as Microsoft Windows and FreeBSD, must boot from a primary partition. (In some cases, it's possible to put most Windows files on a logical partition, but a primary partition must still be involved to store some critical early boot files.) Thus, you should be sure that your Windows boot partition is a primary partition.
If your partition list doesn't look like what you expect, type q to exit from the program now, at least until you better understand what's going on.
If you were experiencing problems caused by a mis-sized extended partition, or if FixParts could otherwise automatically correct your problems, you can save your partition table now; however, please read the caveats in the upcoming section Saving Your Changes before you do so. If you need to adjust primary/logical assignments or make other changes, though, you should read on to learn how to do so.
You can type ? to see a list of the commands supported by the program:
MBR command (? for help): ? a toggle the active/boot flag c recompute all CHS values l set partition as logical o omit partition p print the MBR partition table q quit without saving changes r set partition as primary s sort MBR partitions t change partition type code w write the MBR partition table to disk and exit MBR command (? for help):
Many of these commands have self-evident effects, at least if you understand a bit about MBR partitioning. I describe partition omission and setting primary or logical status in the next section. A few words about some of the other options are in order, though:
If your partition display is not to your liking, you can adjust partitions' primary/logical status within certain constraints, delete (omit) a partition, or in some cases turn an omitted partition into a primary or logical partition. (Note that FixParts can not scan for lost partitions or those you've deleted with another program. Use TestDisk for this job—but be aware that TestDisk sometimes creates improperly-sized extended partitions, so you may need to use FixParts after you use TestDisk!)
Use the r option to turn a partition into a primary partition, l (that's a letter L, not a digit 1) to turn it into a logical partition, or o (the letter O, not the digit 0) to omit the partition. Note that omitting the partition does not immediately remove it from the partition list; it will still appear in the list when you type p, but it will be coded as omitted under the Status column. When you save your changes, omitted partitions will not be saved and so will be lost.
Adjusting primary/logical status can be tricky because of the rules governing primary and logical partitions. These rules are:
These four rules combine to create some peculiar situations when editing your partitions. The Can Be Logical and Can Be Primary columns in the partition table display identify partitions that may be turned into logical partitions or primary partitions at that moment. If you change any partition's status, it's possible that your ability to make changes to other partitions may change. For instance, in the preceding output, if you change partition #5 into a primary partition, you'll find that you'll be able to turn partition #1 into a logical partition. If you do that, you'll find that no other partition will be a candidate for conversion to a logical partition:
Can Be Can Be Number Boot Start Sector End Sector Status Logical Primary Code 1 * 62 1171799 logical Y Y 0x07 2 1171800 1562399 primary Y 0x83 3 1562462 3124799 primary Y 0x0C 5 3124862 3980213 primary Y 0xAF
The reason only partition #1 can be logical at this point is that logical partitions must be contiguous, so the only partition that's even a candidate for a primary-to-logical conversion is partition #2. There is, however, no free space between partitions #1 and #2, so partition #2 cannot be converted into a logical partition. With it as a primary, no other partition can become a logical partition. If you omit partition #2, you can turn partition #3 into a logical. If that's done, you'll find that you can convert partition #5 into a logical, too, but partition #2 won't be includable as either a primary or a logical:
Can Be Can Be Number Boot Start Sector End Sector Status Logical Primary Code 1 * 62 1171799 logical Y Y 0x07 2 1171800 1562399 omitted 0x83 3 1562462 3124799 logical Y Y 0x0C 5 3124862 3980213 primary Y Y 0xAF
Of course, the details of what partition can be what type vary from one disk to another; they depend on the factors specified in the earlier list. You'll need to run FixParts on your own disk to learn what changes you can make to it.
If you want to make changes, you may find that you'll need to temporarily or permanently change the status of other partitions in order to enable the changes you want to make. For instance, starting from the last display, if you wanted to include partition #2, you could do so by turning either partition #1 or partition #3 into a primary partition—because there's no gap between partitions #1 and #2, partition #2 can never be a logical partition, and including it as a primary requires that all the logical partitions come either before or after partition #2.
As you make changes, bear in mind that they all exist in memory, not on disk; you can experiment freely without fear of damaging your disk. Only when you type w to save your changes will your changes be committed to disk.
If your initial table contained any omitted partitions, it may be impossible to fix the partition table and include all the partitions. It may be possible to choose a low-importance partition for deletion. Linux swap partitions seldom contain important data, for instance, so you can safely delete a swap partition and then create a new one later (using fdisk or GParted) if it will enable you to make your desired changes. Alternatively, you may be able to convert from MBR to GPT form using GPT fdisk; however, this conversion will require re-installing your boot loader, and is inadvisable if you're booting Windows or other GPT-unaware OSes from the disk.
Assuming you've found a configuration that's to your liking, you can type w to save your changes. (If you can't seem to work out how to adjust your partitions, you can type q to quit without saving your changes. You can then seek further help or do further research before trying again.)
Saving your changes will automatically sort your logical partitions, so that they'll appear as partitions 5 and up, in on-disk order. Primary partitions may also be re-ordered, depending on the options you used. Even if your primary/logical assignments haven't changed, this sorting can mean you'll need to edit your /etc/fstab file; however, most modern Linux distributions use Universally Unique Identifier (UUID) values to identify partitions for mounting, so you might not need to make such edits even if your partition numbering has changed. Likewise, you may need to adjust your boot loader configuration, particularly if you use GRUB Legacy or LILO (GRUB 2 can use UUIDs and so may not need adjustment). You should be aware of the possible need, in case you reboot and your computer complains about being unable to mount the root filesystem or some such. If that happens, it's possible that your distribution's installation disc will be able to get the system booting again; or you may need to use a tool such as System Rescue CD or PartedMagic to manually edit your boot loader or /etc/fstab file.
If you have problems with or comments about this Web page, please e-mail me at firstname.lastname@example.org. Thanks.
Return to my main Web page.