GDISK(8)         GPT fdisk Manual         GDISK(8)



NAME
       gdisk - Interactive GUID partition table (GPT) manipulator

SYNOPSIS
       gdisk [ -l ] device


DESCRIPTION
       GPT  fdisk  (aka gdisk) is a text-mode menu-driven program for creation
       and manipulation of partition tables. It will automatically convert  an
       old-style  Master  Boot Record (MBR) partition table or BSD disklabel
       stored without an MBR carrier partition to the  newer  Globally Unique
       Identifier  (GUID)  Partition  Table  (GPT) format, or will load a GUID
       partition table. When used with the -l command-line option, the program
       displays the current partition table and then exits.

       GPT fdisk operates mainly on the GPT headers and partition tables; how-
       ever, it can and will generate a fresh protective MBR,  when  required.
       (Any  boot loader code in the protective MBR will not be disturbed.) If
       you've created an unusual protective MBR, such as a hybrid MBR  created
       by  gptsync or gdisk's own hybrid MBR creation feature, this should not
       be disturbed by most ordinary  actions. Some  advanced data  recovery
       options require you to understand the distinctions between the main and
       backup data, as well as between the  GPT  headers  and the  partition
       tables. For information on MBR vs. GPT, as well as GPT terminology and
       structure, see the extended  gdisk  documentation  at  http://www.rods-
       books.com/gdisk/ or consult Wikipedia.

       The  gdisk  program employs a user interface similar to that of Linux's
       fdisk, but gdisk modifies GPT partitions. It also has the capability of
       transforming MBR partitions or BSD disklabels into GPT partitions. Like
       the original fdisk program, gdisk does not modify disk structures until
       you  explicitly write  them to disk, so if you make a mistake, you can
       exit from the program with the 'q'  option  to  leave  your  partitions
       unmodified.

       Ordinarily,  gdisk  operates  on disk device files, such as /dev/sda or
       /dev/hda under Linux,  /dev/disk0  under  Mac  OS  X,  or  /dev/ad0  or
       /dev/da0  under FreeBSD.  The  program can also operate on disk image
       files, which can be either copies of whole disks  (made with  dd,  for
       instance)  or raw disk images used by emulators such as QEMU or VMWare.
       Note that only raw disk images are supported; gdisk cannot work on com-
       pressed or other advanced disk image formats.

       The  MBR partitioning system uses a combination of cylinder/head/sector
       (CHS) addressing and logical block  addressing  (LBA).  The  former  is
       klunky  and limiting. GPT drops CHS addressing and uses 64-bit LBA mode
       exclusively. Thus, GPT data structures, and  therefore  gdisk,  do  not
       need  to  deal  with  CHS  geometries and all the problems they create.
       Users of fdisk will note that gdisk lacks the options  and  limitations
       associated with CHS geometries.

       For best results, you should use an OS-specific partition table program
       whenever possible. For example, you should make Mac  OS  X  partitions
       with  the  Mac  OS X Disk Utility program and Linux partitions with the
       Linux gdisk or GNU Parted program.

       Upon start, gdisk attempts to identify the partition type in use on the
       disk.  If  it finds valid GPT data, gdisk will use it. If gdisk finds a
       valid MBR or BSD disklabel but no GPT data, it will attempt to  convert
       the  MBR or disklabel into GPT form. (BSD disklabels are likely to have
       unusable first and/or final partitions because they  overlap  with  the
       GPT  data structures, though.) GPT fdisk can identify, but not use data
       in, Apple Partition Map (APM) disks, which are used on 680x0- and  Pow-
       erPC-based  Macintoshes.  Upon  exiting with  the  'w' option,  gdisk
       replaces the MBR or disklabel with a GPT. This  action  is  potentially
       dangerous!  Your system may become unbootable, and partition type codes
       may become corrupted if the disk uses  unrecognized  type  codes.  Boot
       problems  are  particularly  likely  if you're multi-booting with any
       GPT-unaware OS. If you mistakenly launch gdisk on an MBR disk, you  can
       safely  exit  the  program  without making any changes by using the 'q'
       option.

       The MBR-to-GPT conversion will leave at least one gap in the  partition
       numbering  if  the original MBR used logical partitions. These gaps are
       harmless, but you can eliminate them by using the 's'  option,  if  you
       like.  (Doing this may require you to update your /etc/fstab file.)

       When creating a fresh partition table, certain considerations may be in
       order:


       *      For data (non-boot) disks, and for boot disks used on BIOS-based
              computers  with  GRUB as the boot loader, partitions may be cre-
              ated in whatever order and in whatever sizes are desired.


       *      Boot disks for EFI-based systems require an EFI System Partition
              (gdisk  internal code  0xEF00) formatted as FAT-32.  The recom-
              mended size of this  partition  is  between  100 and  300  MiB.
              Boot-related  files are stored here. (Note that GNU Parted iden-
              tifies such partitions as having the "boot flag" set.)


       *      Some boot loaders for BIOS-based systems make use of a BIOS Boot
              Partition  (gdisk  internal code 0xEF02), in which the secondary
              boot loader  is  stored, possibly  without  the benefit  of  a
              filesystem.  (GRUB2  may optionally use such a partition.) This
              partition can typically be quite small (roughly 32 to 200  KiB),
              but  you should consult  your  boot  loader  documentation for
              details.


       *      If Windows is to boot from a GPT disk, a partition of  type  Mi-
              crosoft  Reserved  (gdisk  internal code 0x0C01) is recommended.
              This partition should be about 128 MiB in  size. It  ordinarily
              follows  the  EFI  System Partition and immediately precedes the
              Windows data partitions. (Note that old versions of  GNU Parted
              create all FAT partitions as this type, which actually makes the
              partition unusable for normal file storage in both  Windows  and
              Mac OS X.)


       *      Some  OSes' GPT utilities create some blank space (typically 128
              MiB) after each partition. The intent is to enable  future  disk
              utilities  to use this space. Such free space is not required of
              GPT disks, but creating it may help in future disk  maintenance.
              You  can use  GPT fdisk's relative partition positioning option
              (specifying the starting sector as  '+128M',  for  instance)  to
              simplify creating such gaps.


OPTIONS
       -l     List  the  partition  tables  for the specified devices and then
              exit.

       Most interactions with  gdisk  occur  with  its interactive  text-mode
       menus.  Three menus exist: the main menu, the recovery & transformation
       menu, and the experts' menu. The main menu provides the functions  that
       are  most  likely  to be useful for typical partitioning tasks, such as
       creating and deleting partitions, changing partition type codes, and so
       on. Specific functions are:


       b      Save  partition data to a backup file. You can back up your cur-
              rent in-memory partition table to a disk file using this option.
              The resulting file is a binary file consisting of the protective
              MBR, the main GPT header, the backup GPT header, and one copy of
              the  partition  table, in that order. Note that the backup is of
              the current in-memory data structures, so if you launch the pro-
              gram,  make  changes,  and then use this option, the backup will
              reflect your changes. Note also that the restore option is  on
              the  recovery & transformation menu; the backup option is on the
              main menu to encourage its use.



       c      Change the GPT name of a partition. This name is encoded  as  a
              UTF-16  string,  but proper entry and display of anything beyond
              basic ASCII values requires suitable locale  and font  support.
              For  the most part, Linux ignores the partition name, but it may
              be important in some OSes. GPT fdisk sets a default  name  based
              on  the partition type code. Note that the GPT partition name is
              different from the filesystem name,  which  is  encoded  in  the
              filesystem's data structures.


       d      Delete  a partition. This action deletes the entry from the par-
              tition table but does not disturb the data  within  the  sectors
              originally  allocated  to the partition on the disk. If a corre-
              sponding hybrid MBR partition exists, gdisk deletes it, as well,
              and expands any adjacent 0xEE (EFI GPT) MBR protective partition
              to fill the new free space.


       i      Show detailed partition  information.  The  summary  information
              produced by the 'p' command necessarily omits many details, such
              as the partition's unique GUID and the  translation  of  gdisk's
              internal partition  type  code  to  a  plain type name. The 'i'
              option displays this information for a single partition.


       l      Display a summary of partition types. GPT uses a GUID  to  iden-
              tify  partition types for particular OSes and purposes. For ease
              of data entry, gdisk compresses these into two-byte  (four-digit
              hexadecimal)  values  that  are  related to their equivalent MBR
              codes. Specifically, the MBR code is multiplied  by  hexadecimal
              0x0100.  For  instance,  the code for Linux swap space in MBR is
              0x82, and it's 0x8200 in gdisk. A one-to-one  correspondence  is
              impossible, though. Most notably, the codes for all varieties of
              FAT and NTFS partition correspond to a single GPT code  (entered
              as 0x0700 in sgdisk). Some OSes use a single MBR code but employ
              many more codes in GPT.  For  these,  gdisk  adds  code  numbers
              sequentially, such as 0xa500 for a FreeBSD disklabel, 0xa501 for
              FreeBSD boot, 0xa502 for FreeBSD swap,  and  so  on.  Note  that
              these two-byte codes are unique to gdisk.


       n      Create  a  new  partition.  This command  is modelled after the
              equivalent fdisk option, although some  differences  exist.  You
              enter a partition number, starting sector, and an ending sector.
              Both start and end sectors can be specified in absolute terms as
              sector  numbers  or  as  positions  measured  in kibibytes (K),
              mebibytes (M), gibibytes (G), tebibytes (T), or  pebibytes  (P);
              for  instance,  40M specifies a position 40MiB from the start of
              the disk. You can specify locations relative to the start or end
              of  the specified default range by preceding the number by a '+'
              or '-' symbol, as in +2G to  specify  a  point  2GiB  after  the
              default  start sector, or -200M to specify a point 200MiB before
              the last available sector. Pressing the Enter key with no  input
              specifies  the  default value, which is the start of the largest
              available block for the start sector and the  end  of  the  same
              block for the end sector.


       o      Clear out all partition data. This includes GPT header data, all
              partition definitions, and the protective MBR. The sector align-
              nt is reset to the default (2048 sectors, or 1MB).


       p      Display  basic  partition  summary data. This includes partition
              numbers, starting and ending sector  numbers,  partition sizes,
              gdisk's  partition  types  codes, and partition names. For addi-
              tional information, use the 'i' command.


       q      Quit from the program without saving  your  changes.   Use  this
              option  if  you just wanted to view information or if you make a
              mistake and want to back out of all your changes.


       r      Enter the recovery & transformation  menu.  This menu  includes
              emergency  recovery options (to fix damaged GPT data structures)
              and options to transform to or from other partitioning  systems,
              including creating hybrid MBRs.


       s      Sort partition entries. GPT partition numbers need not match the
              order of partitions on the disk. If you want them to match,  you
              can use this option.  Note that some partitioning utilities sort
              partitions whenever they make  changes.  Such  changes  will  be      
              reflected  in  your  device  filenames,  so you may need to edit
              /etc/fstab if you use this option.


       t      Change a single partition's type code. You enter the  type  code
              using  a two-byte hexadecimal number, as described earlier. You
              may also enter a GUID  directly, if  you  have  one  and  gdisk
              doesn't know it.


       v      Verify  disk. This option checks for a variety of problems, such
              as incorrect CRCs and mismatched main  and  backup  data.  This
              option does not automatically correct most problems, though; for
              that, you must use options  on  the  recovery  & transformation
              menu.  If no problems are found, this command displays a summary
              of unallocated disk space.


       w      Write data. Use this command to save your changes.


       x      Enter the experts' menu. Using this option  provides  access  to
              features you can use to get into even more trouble than the main      
              menu allows.

       ?      Print the menu. Type this command  (or  any  other  unrecognized
              command) to see a summary of available options.


       The second gdisk menu is the recovery & transformation menu, which pro-
       vides access to data recovery  options  and  features  related  to  the
       transformation  of  partitions between partitioning schemes (converting
       BSD disklabels  into  GPT  partitions  or  creating  hybrid  MBRs,  for
       instance).   A  few options on this menu duplicate functionality on the
       main menu, for the sake of convenience. The options on this menu are:


       b      Rebuild GPT header from backup.  You  can  use  the  backup  GPT
              header  to  rebuild  the main GPT header with this option. It's
              likely to be useful if your  main  GPT  header  was  damaged  or
              destroyed (say, by sloppy use of dd).


       c      Load  backup  partition  table.  Ordinarily, gdisk uses only the
              main partition table (although the backup's integrity is checked
              when  you  launch  the program). If the main partition table has
              been damaged, you can use this option to load  the  backup  from
              disk  and  use  it instead. Note that this will almost certainly
              produce no or strange partition entries if you've just converted
              an  MBR disk to GPT format, since there will be no backup parti-
              tion table on disk.


       d      Use main GPT header and  rebuild the  backup.  This  option  is       
              likely to be useful if the backup GPT header has been damaged or
              destroyed.


       e      Load main partition table. This option reloads the  main parti-
              tion  table  from  disk. It's only likely to be useful if you've
              tried to use the backup partition table (via 'c')  but  it's  in
              worse shape then the main partition table.


       f      Load  MBR  and  build fresh GPT from it. Use this option if your
              GPT is corrupt or conflicts with the MBR and you want to use the
              MBR as the basis for a new set of GPT partitions.


       g      Convert GPT into MBR and exit. This option converts as many par-
              titions as possible into MBR form, destroys the GPT data struc-
              tures,  saves the new MBR, and exits.  Use this option if you've
              tried GPT and find that MBR works better for  you.   Note  that
              this  function  generates  up  to four primary MBR partitions or
              three primary partitions and as many logical partitions  as  can
              be generated. Each logical partition requires at least one unal-
              located block immediately before its first block. Therefore,  it
              may be possible to convert a maximum of four partitions on disks
              with tightly-packed  partitions; however,  if  free  space  was
              inserted between  partitions when they were created, and if the
              disk is under 2 TiB in size, it should be  possible  to  convert
              all the partitions to MBR form.  See also the 'h' option.


       h      Create  a  hybrid  MBR.  This is an ugly workaround that enables
              GPT-unaware OSes, or those that can't boot from a GPT  disk,  to
              access up to three of the partitions on the disk by creating MBR
              entries for them. Note that these hybrid MBR entries can easily
              go   out of  sync  with the  GPT  entries,  particularly  when
              hybrid-unaware GPT utilities are used to edit the  disk.  Thus,
              you  may need to recreate the hybrid MBR if you use such tools.
              Unlike the 'g' option, this option does not  support  converting
              any partitions into MBR logical partitions.


       i      Show detailed partition information. This option is identical to
              the 'i' option on the main menu.


       l      Load partition data from a  backup  file.  This  option  is  the
              reverse  of the 'b' option on the main menu. Note that restoring
              partition data from anything but the original disk is not recom-
              mended.


       m      Return  to  the  main  menu.  This  option  enables you to enter
              main-menu commands.


       o      Print protective MBR data. You can see a summary of the  protec-
              tive  MBR's  partitions with this option. This may enable you to
              spot glaring problems or help  identify the  partitions  in  a        
              hybrid MBR.


       p      Print  the  partition table. This option is identical to the 'p'
              option in the main menu.


       q      Quit without saving changes. This option is identical to the 'q'
              option in the main menu.


       t      Transform  BSD partitions into GPT partitions. This option works
              on BSD disklabels held within GPT (or converted MBR) partitions.
              Converted  partitions'  type  codes  are likely to need manual
              adjustment. gdisk will attempt to convert BSD disklabels stored
              on the main disk when launched, but this conversion is likely to
              produce first and/or last partitions that are unusable. The many
              BSD variants means that the probability of gdisk being unable to
              convert a BSD disklabel is high compared to  the likelihood  of
              problems with an MBR conversion.


       v      Verify  disk.  This option is identical to the 'v' option in the
              main menu.


       w      Write table to disk and exit. This option is  identical  to  the
              'w' option in the main menu.


       x      Enter  the  experts'  menu.  This option is identical to the 'x'
              option in the main menu.


       ?      Print the menu. This option (or any unrecognized entry) displays
              a summary of the menu options.


       The  third gdisk menu is the experts' menu. This menu provides advanced
       options that aren't  closely  related  to  recovery  or transformation
       between partitioning systems. Its options are:


       a      Set  attributes. GPT provides a 64-bit attributes field that can
              be used to set features for each partition. gdisk supports  four
              attributes:  system  partition,  read-only,  hidden,  and do not
              automount. You can  set  other  attributes,  but their  numbers
              aren't  translated  into anything useful. In practice, most OSes
              seem to ignore these attributes.


       c      Change partition GUID. You can enter a custom unique GUID for  a
              partition  using this option. (Note this refers to the GUID that
              uniquely identifies a partition, not to its type code, which you
              can  change  with  the  't' main-menu option.) Ordinarily, gdisk
              assigns this number randomly; however, you might want to adjust
              the number manually if you've wound up with the same GUID on two
              partitions because of buggy GUID assignments (hopefully  not  in
              gdisk) or sheer incredible coincidence.


       d      Display  the  sector alignment value. See the description of the
              'l' option for more details.


       e      Move backup GPT data structures to the end of the disk. Use this
              command  if  you've added disks to a RAID array, thus creating a
              virtual disk with space that follows the backup GPT data struc-
              tures.  This command moves the backup GPT data structures to the
              end of the disk, where they belong.


       f      Randomize the disk's GUID and all partitions' unique GUIDs  (but
              not  their partition type code GUIDs). This function may be used
              after cloning a disk with another utility in order to render all
              GUIDs once again unique.


       g      Change  disk GUID. Each disk has a unique GUID code, which gdisk
              assigns randomly upon creation of the GPT data  structures.  You
              can generate a fresh random GUID or enter one manually with this
              option.


       h      Recompute CHS values in protective or hybrid  MBR.  This option
              can  sometimes  help if a disk utility, OS, or BIOS doesn't like
              the CHS values used by  the  partitions  in  the protective  or
              hybrid  MBR. In particular, the GPT specification requires a CHS
              value of 0xFFFFFF for over-8GiB partitions, but  this  value  is
              technically  illegal by the usual standards. Some BIOSes hang if
              they encounter this value. This option  will  recompute  a  more
              normal  CHS value -- 0xFEFFFF for over-8GiB partitions, enabling
              these BIOSes to boot.


       i      Show detailed partition information. This option is identical to
              the 'i' option on the main menu.


       l      Change  the sector alignment value. Disks with more logical sec-
              tors per physical  sectors  (such  as  modern  Advanced Format
              drives), some  RAID  configurations,  and many SSD devices, can
              suffer performance problems if partitions are not aligned  prop-
              erly for their internal data structures. On new disks, GPT fdisk
              attempts to align partitions on 2048-sector (1MiB) boundaries by
              default, which  optimizes  performance  for  all  of these disk
              types. On pre-partitioned disks, GPT fdisk attempts to  identify
              the  alignment  value  used  on that disk, but will set 8-sector
              alignment on disks larger than 300 GB even if  lesser  alignment
              values  are detected. In either case, it can be changed by using
              this option.


       m      Return to the main  menu.  This  option  enables you  to  enter
              main-menu commands.


       n      Create a new protective MBR. Use this option if the current pro-
              tective MBR is damaged in a way that gdisk doesn't automatically
              detect  and correct, or if you want to convert a hybrid MBR into
              a "pure" GPT with a conventional protective MBR.


       o      Print protective MBR data. You can see a summary of the  protec-
              tive  MBR's  partitions with this option. This may enable you to
              spot glaring problems or help  identify the  partitions  in  a
              hybrid MBR.


       p      Print  the  partition table. This option is identical to the 'p'
              option in the main menu.


       q      Quit without saving changes. This option is identical to the 'q'
              option in the main menu.


       r      Enter  the recovery & transformations menu. This option is iden-
              tical to the 'r' option on the main menu.


       s      Resize partition table. The default partition table size is  128
              entries.  Officially,  sizes  of  less  than 16KB (128 entries,
              given the normal entry size) are unsupported by the GPT specifi-
              cation;  however,  in  practice they seem to work, and can some-
              times be useful in converting MBR disks. Larger sizes also  work
              fine.  OSes  may impose their own limits on the number of parti-
              tions, though.


       t      Swap two partitions' entries in the partition table. One parti-
              tion  may be empty. For instance, if partitions 1-4 are defined,
              transposing 1 and 5 results in a table with partitions  numbered
              from  2-5.  Transposing  partitions in this way has no effect on
              their disk space allocation; it only alters their order  in  the
              partition table.


       u      Replicate  the  current  device's  partition  table  on  another
              device. You will be prompted to type the new device's  filename.
              After  the  write  operation completes, you can continue editing
              the original device's partition table.  Note that the replicated
              partition  table is  an exact copy, including all GUIDs; if the
              device should have its own unique GUIDs, you should  use the  f
              option on the new disk.


       v      Verify  disk.  This option is identical to the 'v' option in the
              main menu.


       z      Zap (destroy) the GPT data structures and exit. Use this option
              if  you want to repartition a GPT disk using fdisk or some other
              GPT-unaware program.  You'll be given the choice of  preserving
              the  existing  MBR,  in  case it's a hybrid MBR with salvageable
              partitions or if you've already created new MBR  partitions  and
              want  to erase  the  remnants of your GPT partitions. If you've
              already created new MBR partitions, it's conceivable  that  this
              option will damage the first and/or last MBR partitions! Such an
              event is unlikely, but could occur if your  new  MBR  partitions
              overlap the old GPT data structures.


       ?      Print the menu. This option (or any unrecognized entry) displays
              a summary of the menu options.


       In many cases, you can press the Enter key to select a  default option
       when  entering  data.  When  only one option is possible, gdisk usually
       bypasses the prompt entirely.


BUGS
       As of May 2012 (version 0.8.5), gdisk should be considered  beta  soft-
       ware. Known bugs and limitations include:


       *      The program compiles correctly only on Linux, FreeBSD, Mac OS X,
              and Windows.  Linux versions for x86-64 (64-bit), x86  (32-bit),
              and  PowerPC  (32-bit) have been tested, with the x86-64 version
              having seen the most testing. Under FreeBSD,  32-bit  (x86)  and
              64-bit  (x86-64) versions have been tested. Only 32-bit versions
              for Mac OS X  and  Windows  have been  tested  by  the  author,
              although I've  heard of 64-bit versions being successfully com-
              piled.


       *      The FreeBSD version of the program can't write  changes  to  the
              partition  table to a disk when existing partitions on that disk
              are mounted. (The same problem exists with  many other  FreeBSD
              utilities,  such as gpt, fdisk, and dd.) This limitation can be
              overcome by typing sysctl  kern.geom.debugflags=16  at  a  shell
              prompt.


       *      The  fields used to display the start and end sector numbers for
              partitions in the 'p'  command  are  14  characters  wide.  This
              translates to a limitation of about 45 PiB. On larger disks, the
              displayed columns will go out of alignment.


       *      In the Windows version, only ASCII characters are  supported  in
              the   partition  name  field.  If  an  existing  partition  uses
              non-ASCII UTF-16 characters, they're likely to be  corrupted  in
              the  'i' and 'p' menu options' displays; however, they should be
              preserved when  loading  and  saving  partitions.  Binaries  for
              Linux, FreeBSD, and OS X support full UTF-16 partition names.


       *      The program can load only up to 128 partitions (4 primary parti-
              tions and 124 logical partitions) when converting from MBR  for-
              mat.   This   limit  can be  raised  by changing  the  #define
              MAX_MBR_PARTS line in the basicmbr.h source code file and recom-
              piling; however,   such   a   change   will  require  using  a
              larger-than-normal partition table. (The limit of 128 partitions
              was  chosen  because  that number equals the 128 partitions sup-
              ported by the most common partition table size.)


       *      Converting from MBR format sometimes fails because  of  insuffi-
              cient space at the start or (more commonly) the end of the disk.
              Resizing the partition  table  (using  the  's'  option  in  the
              experts' menu) can sometimes overcome this problem; however, in
              extreme cases it may be necessary to resize  a  partition  using
              GNU Parted or a similar tool prior to conversion with gdisk.


       *      MBR  conversions work only if the disk has correct LBA partition
              descriptors. These descriptors should be present  on  any  disk
              over  8 GiB in size or on smaller disks partitioned with any but
              very ancient software.


       *      BSD disklabel support can create first  and/or  last  partitions
              that overlap with the GPT data structures. This can sometimes be
              compensated by  adjusting  the  partition  table size,  but  in
              extreme cases the affected partition(s) may need to be deleted.


       *      Because  of  the highly variable nature of BSD disklabel struc-
              tures, conversions from this form may be unreliable  -- parti-
              tions  may  be dropped, converted in a way that creates overlaps
              with other partitions, or converted with incorrect start or  end
              values. Use this feature with caution!


       *      Booting  after converting an MBR or BSD disklabel disk is likely
              to be disrupted. Sometimes re-installing a boot loader will  fix
              the  problem,  but other times you may need to switch boot load-
              ers. Except on EFI-based platforms,  Windows  through  at  least
              Windows  7  doesn't  support  booting from GPT disks. Creating a
              hybrid MBR (using the 'h' option on the recovery &  transforma-
              tion  menu)  or  abandoning GPT in favor of MBR may be your only
              options in this case.


AUTHORS
       Primary author: Roderick W. Smith (rodsmith@rodsbooks.com)

       Contributors:

       * Yves Blusseau (1otnwmz02@sneakemail.com)

       * David Hubbard (david.c.hubbard@gmail.com)

       * Justin Maggard (justin.maggard@netgear.com)

       * Dwight Schauer (dschauer@ti.com)

       * Florian Zumbiehl (florz@florz.de)



SEE ALSO
       cfdisk (8), cgdisk (8), fdisk (8), mkfs (8),  parted  (8),  sfdisk  (8)
       sgdisk (8) fixparts (8)

       http://en.wikipedia.org/wiki/GUID_Partition_Table

       http://developer.apple.com/technotes/tn2006/tn2166.html

       http://www.rodsbooks.com/gdisk/


AVAILABILITY
       The  gdisk  command  is part of the GPT fdisk package and is available
       from Rod Smith.




SGDISK(8)         GPT fdisk Manual        SGDISK(8)



NAME
       sgdisk  - Command-line GUID partition table (GPT) manipulator for Linux
       and Unix

SYNOPSIS
       sgdisk [ options ] device


DESCRIPTION
       GPT fdisk is a text-mode menu-driven package for creation and manipula-
       tion  of  partition  tables. It consists of two programs: the text-mode
       interactive gdisk and the  command-line sgdisk.  Either  program  will
       automatically  convert  an old-style Master Boot Record (MBR) partition
       table or BSD disklabel stored without an MBR carrier partition  to  the
       newer  Globally Unique Identifier (GUID) Partition Table (GPT) format,
       or will load a GUID partition table. This man page documents  the  com-
       mand-line sgdisk program.

       Some  advanced  data  manipulation  and recovery options require you to
       understand the distinctions between the main and backup data,  as  well
       as between the GPT headers and the partition tables. For information on
       MBR vs. GPT, as well as GPT terminology and structure, see the extended
       gdisk   documentation  at  http://www.rodsbooks.com/gdisk/  or  consult
       Wikipedia.

       The sgdisk program employs a user interface that's  based  entirely  on
       the  command  line, making it suitable for use in scripts or by experts
       who want to make one or two quick changes to a disk. (The  program  may
       query  the  user when certain errors are encountered, though.) The pro-
       gram's name is based on sfdisk, but the user options of the  two  pro-
       grams are entirely different from one another.

       Ordinarily,  sgdisk  operates on disk device files, such as /dev/sda or
       /dev/hda under Linux,  /dev/disk0  under  Mac  OS  X,  or  /dev/ad0  or
       /dev/da0  under FreeBSD.  The  program can also operate on disk image
       files, which can be either copies of whole disks  (made with  dd,  for
       instance)  or raw disk images used by emulators such as QEMU or VMWare.
       Note that only raw disk images are supported;  sgdisk  cannot  work  on
       compressed or other advanced disk image formats.

       The  MBR partitioning system uses a combination of cylinder/head/sector
       (CHS) addressing and logical block  addressing  (LBA).  The  former  is
       klunky  and limiting. GPT drops CHS addressing and uses 64-bit LBA mode
       exclusively. Thus, GPT data structures, and therefore  sgdisk,  do  not
       need to deal with CHS geometries and all the problems they create.

       For best results, you should use an OS-specific partition table program
       whenever possible. For example, you should make Mac  OS  X  partitions
       with  the  Mac  OS X Disk Utility program and Linux partitions with the
       Linux gdisk, sgdisk, or GNU Parted programs.

       Upon start, sgdisk attempts to identify the partition type  in  use  on
       the  disk.  If  it  finds valid GPT data, sgdisk will use it. If sgdisk
       finds a valid MBR or BSD disklabel but no GPT data, it will attempt  to
       convert the MBR or disklabel into GPT form. (BSD disklabels are likely
       to have unusable first and/or final  partitions because  they  overlap
       with  the GPT data structures, though.) GPT fdisk can identify, but not
       use data in, Apple Partition Map (APM) disks, which are used on 680x0-
       and  PowerPC-based  Macintoshes. If you specify any option that results
       in changes to an MBR or BSD disklabel,  sgdisk  ignores those  changes
       unless  the  -g (--mbrtogpt),  -z (--zap), or -Z (--zap-all) option is
       used. If you use the -g option, sgdisk replaces the  MBR  or  disklabel
       with  a GPT.  This  action  is potentially dangerous! Your system may
       become unbootable, and partition type codes may become corrupted if the
       disk  uses  unrecognized  type  codes.  Boot  problems are particularly
       likely if you're multi-booting with any GPT-unaware OS.

       The MBR-to-GPT conversion will leave at least one gap in the  partition
       numbering  if  the original MBR used logical partitions. These gaps are
       harmless, but you can eliminate them by using the -s  (--sort)  option,
       if  you like.  (Doing  this  may require you to update your /etc/fstab
       file.)

       When creating a fresh partition table, certain considerations may be in
       order:


       *      For data (non-boot) disks, and for boot disks used on BIOS-based
              computers with GRUB as the boot loader, partitions may  be  cre-
              ated in whatever order and in whatever sizes are desired.


       *      Boot disks for EFI-based systems require an EFI System Partition
              (sgdisk internal code 0xEF00) formatted as FAT-32.   The recom-
              mended  size  of this  partition  is  between  100 and 300 MiB.
              Boot-related files are stored here. (Note that GNU Parted  iden-
              tifies such partitions as having the "boot flag" set.)


       *      Some boot loaders for BIOS-based systems make use of a BIOS Boot
              Partition (sgdisk internal code 0xEF02), in which the  secondary
              boot  loader  is stored,  possibly  without  the  benefit  of a
              filesystem. This partition can typically be quite small (roughly
              32 to 200 KiB), but you should consult your boot loader documen-
              tation for details.


       *      If Windows is to boot from a GPT disk, a partition of  type  Mi-
              crosoft  Reserved  (sgdisk internal code 0x0C01) is recommended.
              This partition should be about 128 MiB in  size. It  ordinarily
              follows  the  EFI  System Partition and immediately precedes the
              Windows data partitions. (Note that GNU Parted creates  all  FAT
              partitions  as  this  type,  which  actually makes the partition
              unusable for normal file storage in both Windows and Mac OS X.)


       *      Some OSes' GPT utilities create some blank space (typically  128
              MiB)  after  each partition. The intent is to enable future disk
              utilities to use this space. Such free space is not required  of
              GPT disks, but creating it may help in future disk maintenance.


OPTIONS
       Some  options  take no arguments, others take one argument (typically a
       partition number), and others take compound arguments with colon delim-
       itation.  For instance, -n (--new) takes a partition number, a starting
       sector  number, and  an  ending  sector  number,  as  in   sgdisk   -n
       2:2000:50000  /dev/sdc, which  creates a  new partition, numbered 2,
       starting at sector 2000 an ending at sector 50,000, on /dev/sdc.

       Unrelated options may be combined; however, some such combinations will
       be  nonsense  (such  as deleting a partition and then changing its GUID
       type code).  sgdisk interprets options in the order  in which  they're
       entered,  so  effects can vary depending on order. For instance, sgdisk
       -s -d 2 sorts the partition table entries and then deletes partition  2
       from  the  newly-sorted list;  but sgdisk -d 2 -s deletes the original
       partition 2 and then sorts the modified partition table.

       Error checking and opportunities to correct mistakes in sgdisk are min-
       imal.  Although the  program endeavors to keep the GPT data structures
       legal, it does  not  prompt  for  verification  before  performing  its
       actions.  Unless  you require a command-line-driven program, you should
       use the interactive gdisk instead of sgdisk, since gdisk allows you  to
       quit without saving your changes, should you make a mistake.

       Although  sgdisk  is  based  on the same partition-manipulation code as
       gdisk, sgdisk implements fewer features than its  interactive  sibling.
       Options available in sgdisk are:


       -a, --set-alignment=value
              Set the sector alignment multiple. GPT fdisk aligns the start of
              partitions to sectors that are multiples of  this  value,  which
              defaults to  2048  on  freshly  formatted disks. This alignment
              value is necessary to obtain optimum  performance  with  Western
              Digital  Advanced Format and similar drives with larger physical
              than logical sector sizes, with some types of RAID  arrays,  and
              with SSD devices.


       -A,   --attributes=list|[partnum:show|or|nand|xor|=|set|clear|tog-
              gle|get[:bitnum|hexbitmask]]
              View or set  partition  attributes.  Use list  to  see  defined
              (known)  attribute  values.  Omit the partition number (and even
              the device filename) when using this option. The others  require
              a  partition  number.  The show and get options show the current
              attribute settings (all attributes  or  for  a  particular  bit,
              respectively).  The  or, nand,  xor,  =, set, clear, and toggle
              options enable you to change the attribute bit value.  The  set,
              clear,  toggle, and get options work on a bit number; the others
              work on a hexadecimal bit mask.  For  example,  type  sgdisk  -A
              4:set:2  /dev/sdc  to  set  the  bit  2  attribute  (legacy BIOS
              bootable) on partition 4 on /dev/sdc.


       -b, --backup=file
              Save partition data to a backup file. You can back up your  cur-
              rent in-memory partition table to a disk file using this option.
              The resulting file is a binary file consisting of the protective
              MBR, the main GPT header, the backup GPT header, and one copy of
              the partition table, in that order. Note that the backup is  of
              the current in-memory data structures, so if you launch the pro-
              gram, make changes, and then use this option,  the  backup  will
              reflect  your  changes.  If the GPT data structures are damaged,
              the  backup  may not  accurately  reflect  the  damaged state;
              instead, they will reflect GPT fdisk's first-pass interpretation
              of the GPT.


       -c, --change-name=partnum:name
              Change the GPT name of a partition. This name is encoded  as  a
              UTF-16  string,  but proper entry and display of anything beyond
              basic ASCII values requires suitable locale  and font  support.
              For  the most part, Linux ignores the partition name, but it may
              be important in some OSes. GPT fdisk sets a default  name  based
              on  the  partition  type code.  If  you want to set a name that
              includes a space, enclose it in quotation marks, as in sgdisk -c
              1:"Sample  Name" /dev/sdb. Note that the GPT name of a partition
              is distinct from the filesystem name, which is  encoded  in  the
              filesystem's data structures.


       -C, --recompute-chs
              Recompute  CHS  values  in protective or hybrid MBR. This option
              can sometimes help if a disk utility, OS, or BIOS  doesn't  like
              the  CHS values used  by  the  partitions in the protective or
              hybrid MBR. In particular, the GPT specification requires a  CHS
              value  of  0xFFFFFF  for over-8GiB partitions, but this value is
              technically illegal by the usual standards. Some BIOSes hang  if
              they  encounter  this  value.  This option will recompute a more
              normal CHS value -- 0xFEFFFF for over-8GiB partitions,  enabling
              these BIOSes to boot.


       -d, --delete=partnum
              Delete  a partition. This action deletes the entry from the par-
              tition table but does not disturb the data  within  the  sectors
              originally  allocated  to the partition on the disk. If a corre-
              sponding hybrid MBR partition exists, gdisk deletes it, as well,
              and expands any adjacent 0xEE (EFI GPT) MBR protective partition
              to fill the new free space.


       -D, --display-alignment
              Display current sector alignment value. Partitions will be  cre-
              ated  on multiples of the sector value reported by this option.
              You can change the alignment value with the -a option.


       e, --move-second-header
              Move backup GPT data structures to the end of the disk. Use this
              option  if  you've  added disks to a RAID array, thus creating a
              virtual disk with space that follows the backup GPT data struc-
              tures.  This command moves the backup GPT data structures to the
              end of the disk, where they belong.


       -E, --end-of-largest
              Displays the sector number of the end of the  largest  available
              block  of sectors on the disk. A script may store this value and
              pass it back as part of -n's option to create a partition. If no
              unallocated  sectors  are  available,  this function returns the
              value 0.


       -f, --first-in-largest
              Displays the sector number of the start of the largest available
              block  of sectors on the disk. A script may store this value and
              pass it back as part of -n's option to create a partition. If no
              unallocated  sectors  are  available,  this function returns the
              value 0. Note that this parameter is blind to  partition align-
              ment;  when  you actually  create  a partition, its start point
              might be changed from this value.


       -F, --first-aligned-in-largest
              Similar to -f (--first-in-largest), except  returns  the sector
              number  with  the current alignment correction applied. Use this
              function if you need to compute the actual partition start point
              rather  than a theoretical start point or the actual start point
              if you set the alignment value to 1.


       -g, --mbrtogpt
              Convert an MBR or BSD disklabel disk to a GPT disk. As a safety
              measure, use of this option is required on MBR or BSD disklabel
              disks if you intend to save your changes, in  order  to  prevent
              accidentally damaging such disks.


       -G, --randomize-guids
              Randomize  the disk's GUID and all partitions' unique GUIDs (but
              not their partition type code GUIDs). This function may be  used
              after  cloning  a  disk  in order to render all GUIDs once again
              unique.


       -h, --hybrid
              Create a hybrid MBR. This option takes from one to three parti-
              tion  numbers,  separated  by  colons, as arguments. The created
              hybrid MBR places an EFI GPT (type 0xEE) partition first in  the
              table,  followed by  the  partition(s)  you specify. Their type
              codes are based on the GPT fdisk type codes divided  by  0x0100,
              which   is  usually  correct  for  Windows  partitions.  If  the
              active/bootable flag should be set, you must do  so  in  another
              program, such  as  fdisk.  The  gdisk program offers additional
              hybrid MBR creation options.


       -i, --info=partnum
              Show detailed partition  information.  The  summary  information
              produced by the -p command necessarily omits many details, such
              as the partition's unique GUID and the translation  of  sgdisk's
              internal partition type code to a plain type name. The -i option
              displays this information for a single partition.


       -l, --load-backup=file
              Load partition data from a  backup  file.  This  option  is  the
              reverse  of  the -b  option. Note that restoring partition data
              from anything but the original disk  is  not  recommended.  This
              option  will work even if the disk's original partition table is
              bad; however, most other options on the same command  line  will
              be ignored.


       -L, --list-types
              Display  a  summary of partition types. GPT uses a GUID to iden-
              tify partition types for particular OSes and purposes. For  ease
              of data entry, sgdisk compresses these into two-byte (four-digit
              hexadecimal) values that are related  to their  equivalent  MBR
              codes.  Specifically,  the MBR code is multiplied by hexadecimal
              0x0100. For instance, the code for Linux swap space  in  MBR  is
              0x82,  and  it's 0x8200 in gdisk. A one-to-one correspondence is
              impossible, though. Most notably, the codes for all varieties of
              FAT  and NTFS partition correspond to a single GPT code (entered
              as 0x0700 in sgdisk). Some OSes use a single MBR code but employ
              many  more  codes  in  GPT.  For these, sgdisk adds code numbers
              sequentially, such as 0xa500 for a FreeBSD disklabel, 0xa501 for
              FreeBSD  boot,  0xa502  for  FreeBSD  swap, and so on. Note that
              these two-byte codes are unique to gdisk and sgdisk. This option
              does not require you to specify a valid disk device filename.


       -m, --gpttombr
              Convert disk from GPT to MBR form. This option takes from one to
              four partition numbers, separated by colons, as arguments. Their
              type  codes  are based  on  the GPT fdisk type codes divided by
              0x0100. If the active/bootable flag should be set, you  must  do
              so  in another program, such as fdisk.  The gdisk program offers
              additional MBR conversion options. It is not possible to convert
              more  than  four partitions  from GPT to MBR form or to convert
              partitions that start above the 2TiB mark  or  that  are larger
              than 2TiB.


       -n, --new=partnum:start:end
              Create  a  new partition. You enter a partition number, starting
              sector, and an ending sector. Both start and end sectors can  be
              specified  in  absolute  terms as sector numbers or as positions
              measured in  kibibytes  (K),  mebibytes (M),  gibibytes   (G),
              tebibytes  (T),  or pebibytes (P); for instance, 40M specifies a
              position 40MiB from the start of the disk. You can specify loca-
              tions  relative  to  the start  or end of the specified default
              range by preceding the number by a '+' or '-' symbol, as in  +2G
              to specify a point 2GiB after the default start sector, or -200M
              to specify a point 200MiB before the last  available  sector.  A
              start  or  end  value of 0 specifies the default value, which is
              the start of the largest available block for  the  start sector
              and  the end  of  the  same block for the end sector. A partnum
              value of 0 causes the program to use the first available parti-
              tion number.


       -N, --largest-new=num
              Create a new partition that fills the largest available block of
              space on the disk. Note that if used on a completely blank disk,
              this  is likely to result in a sector-moved warning, since the
              first available sector (normally 34) doesn't fall on a 2048-sec-
              tor  boundary  (the  default  for alignment). You can use the -a
              (--set-alignment) option to adjust the alignment, if desired.  A
              num  value  of  0  causes the program to use the first available
              partition number.


       -o, --clear
              Clear out all partition data. This includes GPT header data, all
              partition  definitions,  and  the protective MBR. Note that this
              operation will, like most other operations, fail on  a  damaged
              disk.  If  you want to prepare a disk you know to be damaged for
              GPT use, you should first wipe it with -Z and then partition  it
              normally. This option will work even if the disk's original par-
              tition table is bad; however, most other options  on  the  same
              command line will be ignored.


       -p, --print
              Display  basic  partition  summary data. This includes partition
              numbers, starting and ending sector  numbers,  partition sizes,
              sgdisk's partition  types codes, and partition names. For addi-
              tional information, use the -i (--info) option.


       -P, --pretend
              Pretend to make specified changes. In-memory GPT data structures
              are  altered  according to other parameters, but changes are not
              written to disk.


       -r, --transpose
              Swap two partitions' entries in the partition table. One or both
              partitions  may be empty, although swapping two empty partitions
              is pointless. For  instance,  if partitions  1-4  are  defined,
              transposing  1 and 5 results in a table with partitions numbered
              from 2-5. Transposing partitions in this way has no  effect  on
              their  disk  space allocation; it only alters their order in the
              partition table.


       -R, --replicate=second_device_filename
              Replicate the main device's partition  table  on the  specified
              second  device. Note that the replicated partition table is an
              exact copy, including all GUIDs; if the device should  have  its
              own unique GUIDs, you should use the -G option on the new disk.


       -s, --sort
              Sort partition entries. GPT partition numbers need not match the
              order of partitions on the disk. If you want them to match,  you
              can use this option.  Note that some partitioning utilities sort
              partitions whenever they make  changes.  Such  changes  will  be
              reflected  in  your  device  filenames,  so you may need to edit
              /etc/fstab if you use this option.


       -t, --typecode=partnum:{hexcode|GUID}
              Change a single partition's type code. You enter the  type  code
              using  either  a two-byte hexadecimal number, as described ear-
              lier,   or   a   fully-specified   GUID   value,    such    as
              EBD0A0A2-B9E5-4433-87C0-68B6B72699C7.


       -T, --transform-bsd=partnum
              Transform  BSD partitions into GPT partitions. This option works
              on BSD disklabels held within GPT (or converted MBR) partitions.
              Converted  partitions'  type  codes  are likely to need manual
              adjustment. sgdisk will attempt to convert BSD disklabels stored
              on the main disk when launched, but this conversion is likely to
              produce first and/or last partitions that are unusable. The many
              BSD  variants  means that the probability of sgdisk being unable
              to convert a BSD disklabel is high compared to the likelihood of
              problems with an MBR conversion.


       -u, --partition-guid=partnum:guid
              Set  the partition unique GUID for an individual partition. The
              GUID may be a complete GUID or 'R' to set a random GUID.


       -U, --disk-guid=guid
              Set the GUID for the disk. The GUID may be a  complete  GUID  or
              'R' to set a random GUID.


       --usage
              Print a brief summary of available options.


       -v, --verify
              Verify  disk. This option checks for a variety of problems, such
              as incorrect CRCs and mismatched main  and  backup  data.  This
              option does not automatically correct most problems, though; for
              that, you must use options  on  the  recovery  & transformation
              menu.  If no problems are found, this command displays a summary
              of unallocated disk space. This option will  work  even  if  the
              disk's  original partition  table  is  bad; however, most other
              options on the same command line will be ignored.


       -V, --version
              Display program version information. This  option  may  be  used
              without specifying a device filename.


       -z, --zap
              Zap  (destroy)  the  GPT data structures and then exit. Use this
              option if you want to repartition a GPT disk using fdisk or some
              other  GPT-unaware  program.  This  option destroys only the GPT
              data structures; it leaves the MBR intact. This makes it useful
              for  wiping out GPT data structures after a disk has been repar-
              titioned for MBR using a GPT-unaware utility; however, there's a
              risk  that  it will damage boot loaders or even the start of the
              first or end of the last MBR partition. If you use it on a valid
              GPT  disk,  the  MBR  will be left with an inappropriate EFI GPT
              (0xEE) partition definition, which you can delete using  another
              utility.


       -Z, --zap-all
              Zap  (destroy)  the  GPT and MBR data structures and then exit.
              This option works much like -z, but as it wipes the MBR as  well
              as the GPT, it's more suitable if you want to repartition a disk
              after using this option, and  completely unsuitable  if you've
              already repartitioned the disk.


       -?, --help
              Print a summary of options.


RETURN VALUES
       sgdisk returns various values depending on its success or failure:


       0      Normal program execution


       1      Too few arguments


       2      An error occurred while reading the partition table


       3      Non-GPT disk detected and no -g option


       4      An error prevented saving changes


       5      An  error  occurred  while  reading standard input (should never
              occur with sgdisk, but may with gdisk)


       8      Disk replication operation (-R) failed


BUGS
       As of May 2012 (version 0.8.5), sgdisk should be considered beta  soft-
       ware. Known bugs and limitations include:


       *      The  program  compiles correctly only on Linux, FreeBSD, and Mac
              OS X. Linux versions for x86-64 (64-bit), x86 (32-bit), and Pow-
              erPC  (32-bit)  have been tested, with the x86-64 version having
              seen the most testing.


       *      The FreeBSD version of the program can't write  changes  to  the
              partition  table to a disk when existing partitions on that disk
              are mounted. (The same problem exists with  many other  FreeBSD
              utilities,  such as gpt, fdisk, and dd.) This limitation can be
              overcome by typing sysctl  kern.geom.debugflags=16  at  a  shell
              prompt.


       *      The  fields used to display the start and end sector numbers for
              partitions in the -p option are 14 characters wide. This trans-
              lates to a limitation of about 45 PiB. On larger disks, the dis-
              played columns will go out of alignment.


       *      The program can load only up to 128 partitions (4 primary parti-
              tions  and 124 logical partitions) when converting from MBR for-
              mat.  This  limit  can  be  raised  by  changing  the   #define
              MAX_MBR_PARTS line in the basicmbr.h source code file and recom-
              piling;  however,  such  a   change   will   require   using   a
              larger-than-normal partition table. (The limit of 128 partitions
              was chosen because that number equals the  128  partitions  sup-
              ported by the most common partition table size.)


       *      Converting  from MBR format sometimes fails because of insuffi-
              cient space at the start or (more commonly) the end of the disk.
              Resizing the  partition table  (using  the  's'  option in the
              experts' menu) can sometimes overcome this problem; however,  in
              extreme  cases  it  may be necessary to resize a partition using
              GNU Parted or a similar tool prior to conversion with gdisk.


       *      MBR conversions work only if the disk has correct LBA  partition
              descriptors.  These  descriptors should be present on any disk
              over 8 GiB in size or on smaller disks partitioned with any  but
              very ancient software.


       *      BSD  disklabel  support  can create first and/or last partitions
              that overlap with the GPT data structures. This can sometimes be
              compensated  by  adjusting  the  partition  table  size, but in
              extreme cases the affected partition(s) may need to be deleted.


       *      Because of the highly variable nature of BSD  disklabel struc-
              tures,  conversions  from  this form may be unreliable -- parti-
              tions may be dropped, converted in a way that  creates  overlaps
              with  other partitions, or converted with incorrect start or end
              values. Use this feature with caution!


       *      Booting after converting an MBR or BSD disklabel disk is likely
              to  be disrupted. Sometimes re-installing a boot loader will fix
              the problem, but other times you may need to switch  boot  load-
              ers.  Except  on EFI-based  platforms, Windows through at least
              Windows 7 RC doesn't support booting from GPT disks. Creating  a
              hybrid  MBR  (using the 'h' option on the recovery & transforma-
              tion menu) or abandoning GPT in favor of MBR may be  your  only
              options in this case.


AUTHORS
       Primary author: Roderick W. Smith (rodsmith@rodsbooks.com)

       Contributors:

       * Yves Blusseau (1otnwmz02@sneakemail.com)

       * David Hubbard (david.c.hubbard@gmail.com)

       * Justin Maggard (justin.maggard@netgear.com)

       * Dwight Schauer (dschauer@ti.com)

       * Florian Zumbiehl (florz@florz.de)



SEE ALSO
       cfdisk  (8),  cgdisk  (8),  fdisk (8), gdisk (8), mkfs (8), parted (8),
       sfdisk (8) fixparts (8)

       http://en.wikipedia.org/wiki/GUID_Partition_Table

       http://developer.apple.com/technotes/tn2006/tn2166.html

       http://www.rodsbooks.com/gdisk/


AVAILABILITY
       The sgdisk command is part of the GPT fdisk package  and  is  available
       from Rod Smith.




CGDISK(8)         GPT fdisk Manual        CGDISK(8)



NAME
       cgdisk - Curses-based GUID partition table (GPT) manipulator

SYNOPSIS
       cgdisk device


DESCRIPTION
       GPT  fdisk is a text-mode family of programs for creation and manipula-
       tion of partition tables. The cgdisk member of this  family  employs  a
       curses-based  user  interface for interaction using a text-mode menuing
       system. It will automatically convert an old-style Master  Boot Record
       (MBR)  partition  table or BSD disklabel stored without an MBR carrier
       partition to the newer Globally Unique Identifier (GUID) Partition  Ta-
       ble (GPT) format, or will load a GUID partition table. Other members of
       this program family are gdisk (the most feature-rich  program  of  the
       group,  with  a non-curses-based interactive user interface) and sgdisk
       (which is driven via command-line options for  use  by  experts or  in
       scripts).   FixParts  is  a related program for fixing a limited set of
       problems with MBR disks.

       For information on MBR vs. GPT, as well as GPT terminology  and struc-
       ture,  see  the extended  GPT  fdisk documentation at http://www.rods-
       books.com/gdisk/ or consult Wikipedia.

       The cgdisk program employs a user interface similar to that of  Linux's
       cfdisk, but cgdisk modifies GPT partitions. It also has the capability
       of transforming MBR partitions or BSD disklabels into  GPT  partitions.
       Like  the  original  cfdisk program, cgdisk does not modify disk struc-
       tures until you explicitly write them to disk, so if you  make  a  mis-
       take,  you can exit from the program with the Quit option to leave your
       partitions unmodified.

       Ordinarily, cgdisk operates on disk device files, such as  /dev/sda  or
       /dev/hda  under Linux, /dev/disk0  under  Mac OS  X, or /dev/ad0 or
       /dev/da0 under FreeBSD. The program can also  operate  on  disk  image
       files,  which  can  be  either copies of whole disks (made with dd, for
       instance) or raw disk images used by emulators such as QEMU or  VMWare.
       Note  that  only  raw  disk images are supported; cgdisk cannot work on
       compressed or other advanced disk image formats.

       Upon start, cgdisk attempts to identify the partition type  in  use  on
       the  disk.  If  it  finds valid GPT data, cgdisk will use it. If cgdisk
       finds a valid MBR or BSD disklabel but no GPT data, it will attempt  to
       convert the MBR or disklabel into GPT form. (BSD disklabels are likely
       to have unusable first and/or final  partitions because  they  overlap
       with  the  GPT  data  structures,  though.)  Upon  exiting with the 'w'
       option, cgdisk replaces the MBR or disklabel with a GPT. This action is
       potentially dangerous! Your system may become unbootable, and partition
       type codes may become corrupted if  the disk  uses  unrecognized  type
       codes. Boot  problems are particularly likely if you're multi-booting
       with any GPT-unaware OS. If you mistakenly  launch  cgdisk  on  an  MBR
       disk,  you  can safely exit the program without making any changes by
       using the Quit option.

       When creating a fresh partition table, certain considerations may be in
       order:


       *      For data (non-boot) disks, and for boot disks used on BIOS-based
              computers with GRUB as the boot loader, partitions may  be  cre-
              ated in whatever order and in whatever sizes are desired.


       *      Boot disks for EFI-based systems require an EFI System Partition
              (GPT fdisk internal code 0xEF00) formatted as FAT-32.  The  rec-
              ommended size  of  this partition  is between 100 and 300 MiB.
              Boot-related files are stored here. (Note that GNU Parted  iden-
              tifies such partitions as having the "boot flag" set.)


       *      The  GRUB  2  boot  loader for BIOS-based systems makes use of a
              BIOS Boot Partition (GPT fdisk internal code 0xEF02),  in  which
              the  secondary  boot  loader is stored, without the benefit of a
              filesystem. This partition can typically be quite small (roughly
              32  KiB to 1 MiB), but you should consult your boot loader docu-
              mentation for details.


       *      If Windows is to boot from a GPT disk, a partition of  type  Mi-
              crosoft  Reserved  (GPT  fdisk  internal code 0x0C01) is recom-
              mended. This partition should be about 128 MiB in size. It ordi-
              narily follows the EFI System Partition and immediately precedes
              the Windows data partitions. (Note  that old  versions  of  GNU
              Parted  create  all  FAT partitions as this type, which actually
              makes the partition unusable for normal  file  storage  in  both
              Windows and Mac OS X.)


       *      Some  OSes' GPT utilities create some blank space (typically 128
              MiB) after each partition. The intent is to enable  future  disk
              utilities  to use this space. Such free space is not required of
              GPT disks, but creating it may help in future disk  maintenance.
              You  can use  GPT fdisk's relative partition positioning option
              (specifying the starting sector as  '+128M',  for  instance)  to
              simplify creating such gaps.


OPTIONS
       Interactions  with  cgdisk  occur with its interactive text-mode menus.
       The display is broken into two interactive parts:


       *      The partition display area, in which partitions and gaps between  
              them (marked as "free space") are summarized.


       *      The option selection area, in which buttons for the main options
              appear.


       In addition, the top of the display shows the program's name  and  ver-
       sion  number,  the  device  filename  associated with the disk, and the
       disk's size in both sectors and IEEE-1541 units (GiB, TiB, and so on).

       You can use the following keys to move among the various options and to
       select among them:


       up arrow
              This key moves the partition selection up by one partition.


       down arrow
              This key moves the partition selection down by one partition.


       Page Up
              This key moves the partition selection up by one screen.


       Page Down
              This key moves the partition selection down by one screen.


       right arrow
              This key moves the option selection to the right by one item.


       left arrow
              This key moves the option selection to the left by one item.


       Enter  This  key  activates the currently selected option. You can also
       activate an option by  typing  the  capitalized  letter  in  the
       option's name  on the keyboard, such as a to activate the Align
       option.


       If more partitions exist than can be displayed in one screen,  you  can
       scroll between screens using the partition selection keys, much as in a
       text editor.

       Available options are as described below. (Note that cgdisk provides  a
       much more limited set of options than its sibling gdisk. If you need to
       perform partition table recovery,  hybrid  MBR  modifcation,  or  other
       advanced operations, you should consult the gdisk documentation.)


       Align  Change  the sector alignment value. Disks with more logical sec-
       tors than physical  sectors  (such  as  modern  Advanced Format
       drives), some  RAID  configurations,  and many SSD devices, can
       suffer performance problems if partitions are not aligned  prop-
       erly for their internal data structures. On new disks, GPT fdisk
       attempts to align partitions on 2048-sector (1MiB) boundaries by
       default, which  optimizes  performance  for  all  of these disk
       types. On pre-partitioned disks, GPT fdisk attempts to  identify
       the  alignment  value  used  on that disk, but will set 8-sector
       alignment on disks larger than 300 GB even if  lesser  alignment
       values  are detected. In either case, it can be changed by using
       this option.


       Backup Save partition data to a backup file. You can back up your  cur-
       rent in-memory partition table to a disk file using this option.
       The resulting file is a binary file consisting of the protective
       MBR, the main GPT header, the backup GPT header, and one copy of
       the partition table, in that order. Note that the backup is  of
       the current in-memory data structures, so if you launch the pro-
       gram, make changes, and then use this option,  the  backup  will
       reflect your changes.


       Delete Delete  a partition. This action deletes the entry from the par-
       tition table but does not disturb the data  within  the  sectors
       originally  allocated  to the partition on the disk. If a corre-
       sponding hybrid MBR partition exists, gdisk deletes it, as well,
       and expands any adjacent 0xEE (EFI GPT) MBR protective partition
       to fill the new free space.


       Help   Print brief descriptions of all the options.


       Info   Show detailed partition  information.  The  summary  information
              shown  in  the  partition  display  area necessarily omits many
              details, such as the partitions' unique  GUIDs  and  the parti-
              tions'  sector-exact  start and end points. The Info option dis-
                plays this information for a single partition.


       Load   Load partition data from a  backup  file.  This  option  is  the
              reverse of the Backup option. Note that restoring partition data
              from anything but the original disk is not recommended.


       naMe   Change the GPT name of a partition. This name is encoded  as  a
              UTF-16  string,  but proper entry and display of anything beyond
              basic ASCII values requires suitable locale  and font  support.
              For  the most part, Linux ignores the partition name, but it may
              be important in some OSes. GPT fdisk sets a default  name  based
              on  the partition type code. Note that the GPT partition name is
              different from the filesystem name,  which  is  encoded  in  the
              filesystem's  data  structures.  Note also that to activate this
              item by typing its alphabetic equivalent, you must  use  M,  not
              the  more  obvious  N,  because  the  latter is used by the next
              option....


       New    Create a new partition. You enter a starting sector, a  size,  a
              type  code,  and a  name.  The start sector can be specified in
              absolute terms as a sector number or as a position  measured  in
              kibibytes  (K),  mebibytes (M), gibibytes (G), tebibytes (T), or
              pebibytes (P); for instance, 40M specifies a position 40MiB from
              the start of the disk. You can specify locations relative to the
              start or end of the specified default  range  by preceding  the
              number  by a '+' symbol, as in +2G to specify a point 2GiB after
              the default start sector. The size value can use the K, M, G, T,
              and P suffixes, too. Pressing the Enter key with no input speci-
              fies the default value, which is the start of the largest avail-
              able  block for the start sector and the full available size for
              the size.


       Quit   Quit from the program without saving  your  changes.   Use  this
              option  if  you just wanted to view information or if you make a
              mistake and want to back out of all your changes.


       Type   Change a single partition's type code. You enter the  type  code
              using  a two-byte hexadecimal number. You may also enter a GUID
              directly, if you have one and cgdisk doesn't  know  it.  If  you
              don't  know  the type code for your partition, you can type L to
              see a list of known type codes.


       Verify Verify disk. This option checks for a variety of problems,  such
              as  incorrect  CRCs  and mismatched  main and backup data. This
              option does not automatically correct most problems, though; for
              that, you must use gdisk. If no problems are found, this command
              displays a summary of unallocated disk space.


       Write  Write data. Use this command to save your changes.


BUGS
       As of May 2012 (version 0.8.5), cgdisk should be considered beta  soft-
       ware.  Although the  underlying  partition  manipulation  code is much
       older, the cgdisk ncurses user interface is brand new  with  GPT  fdisk
       version 0.8.0. Known bugs and limitations include:


       *      The  program  compiles correctly only on Linux, FreeBSD, and Mac
              OS X. In theory, it should compile under Windows if the  Ncurses
              library  for  Windows  is  installed, but I have not tested this
              capability. Linux versions for x86-64  (64-bit), x86  (32-bit),
              and  PowerPC  (32-bit) have been tested, with the x86-64 version
              having seen the most testing. Under FreeBSD,  32-bit  (x86)  and
              64-bit  (x86-64) versions have been tested. Only 32-bit versions
              for Mac OS X has been tested by the author.


       *      The FreeBSD version of the program can't write  changes  to  the
              partition  table to a disk when existing partitions on that disk
              are mounted. (The same problem exists with  many other  FreeBSD
              utilities,  such as gpt, fdisk, and dd.) This limitation can be
              overcome by typing sysctl  kern.geom.debugflags=16  at  a  shell
              prompt.


       *      The program can load only up to 128 partitions (4 primary parti-
              tions and 124 logical partitions) when converting from MBR  for-
              mat.   This   limit  can be  raised  by changing  the  #define
              MAX_MBR_PARTS line in the basicmbr.h source code file and recom-
              piling; however,   such   a   change   will  require  using  a
              larger-than-normal partition table. (The limit of 128 partitions
              was  chosen  because  that number equals the 128 partitions sup-
              ported by the most common partition table size.)


       *      Converting from MBR format sometimes fails because  of  insuffi-
              cient space at the start or (more commonly) the end of the disk.
              Resizing the partition  table  (using  the  's'  option  in  the
              experts' menu  in  gdisk)  can sometimes overcome this problem;
              however, in extreme cases it may be necessary to resize a parti-
              tion using GNU Parted or a similar tool prior to conversion with
              GPT fdisk.


       *      MBR conversions work only if the disk has correct LBA  partition
              descriptors.  These  descriptors should be present on any disk
              over 8 GiB in size or on smaller disks partitioned with any  but
              very ancient software.


       *      BSD  disklabel  support  can create first and/or last partitions
              that overlap with the GPT data structures. This can sometimes be
              compensated  by  adjusting  the  partition  table  size, but in
              extreme cases the affected partition(s) may need to be deleted.


       *      Because of the highly variable nature of BSD  disklabel struc-
              tures,  conversions  from  this form may be unreliable -- parti-
              tions may be dropped, converted in a way that  creates  overlaps
              with  other partitions, or converted with incorrect start or end
              values. Use this feature with caution!


       *      Booting after converting an MBR or BSD disklabel disk is likely
              to  be disrupted. Sometimes re-installing a boot loader will fix
              the problem, but other times you may need to switch  boot  load-
              ers.  Except  on EFI-based  platforms, Windows through at least
              Windows 7 doesn't support booting from  GPT  disks.  Creating  a
              hybrid  MBR  (using the 'h' option on the recovery & transforma-
              tion menu in gdisk) or abandoning GPT in favor  of  MBR  may  be
              your only options in this case.


       *      The  cgdisk  Verify  function  and  the  partition  type listing
              obtainable by typing L in the Type function (or when  specifying
              a  partition type while creating a new partition) both currently
              exit ncurses mode. This limitation is a minor  cosmetic  blemish
              that does not affect functionality.


AUTHORS
       Primary author: Roderick W. Smith (rodsmith@rodsbooks.com)

       Contributors:

       * Yves Blusseau (1otnwmz02@sneakemail.com)

       * David Hubbard (david.c.hubbard@gmail.com)

       * Justin Maggard (justin.maggard@netgear.com)

       * Dwight Schauer (dschauer@ti.com)

       * Florian Zumbiehl (florz@florz.de)



SEE ALSO
       cfdisk  (8),  fdisk  (8),  gdisk  (8), mkfs (8), parted (8), sfdisk (8)
       sgdisk (8) fixparts (8)

       http://en.wikipedia.org/wiki/GUID_Partition_Table

       http://developer.apple.com/technotes/tn2006/tn2166.html

       http://www.rodsbooks.com/gdisk/


AVAILABILITY
       The cgdisk command is part of the GPT fdisk package  and  is  available
       from Rod Smith.




FIXPARTS(8)   FixParts Manual      FIXPARTS(8)



NAME
       fixparts - MBR partition table repair utility

SYNOPSIS
       fixparts device


DESCRIPTION
       FixParts  (aka fixparts) is a text-mode menu-driven program for repair-
       ing certain types of problems with Master Boot Record  (MBR)  partition
       tables. The  program has three design goals, although a few additional
       features are supported, as well:


       *      It can remove stray GUID Partition Table (GPT) data,  which  can
              be  left behind on a disk that was once used as a GPT disk but
              then incompletely converted to the more common (as of 2011)  MBR
              form.


       *      It can repair mis-sized extended partitions -- either partitions
              that extend beyond the physical end of the disk or that  overlap
              with  nearby  primary partitions. FixParts is designed in such a
              way that this type of repair occurs automatically,  so  if  it's
              the  only problem with your disk, you can launch the program and
              then immediately save the  partition  table,  making  no manual
              changes, and the program will fix the problem.


       *      You  can change primary  partitions into logical partitions or
              vice-versa, within constraints imposed by the  MBR  data struc-
              tures.


       Additional  features include the ability to change partition type codes
       or boot/active flags, to delete partitions, and to recompute  CHS  val-
       ues.  With the possible exception of recomputing CHS values, these sec-
       ondary features are better  performed  with  fdisk,  because  fixpart's
       design  means  that  it's likely to alter partition numbering even when
       such changes are not requested.

       The fixpart program employs a user interface similar to that of Linux's
       fdisk,  but  fixpart  is  much  more specialized. Most importantly, you
       can't create new partitions with fixpart, although you can change  pri-
       mary/logical assignment.

       In the MBR scheme, partitions come in three varieties:


       primary
              These  partitions  are  defined  in the first sector of the hard
              disk and are limited in number to four. Some OSes, such as  Win-
              dows and FreeBSD, must boot from a primary partition.


       extended
              Extended partitions  are  specialized  primary partitions. They
              serve as holding areas for logical partitions.


       logical
              A disk can contain an arbitrary  number  of  logical  partitions
              (fixpart,  however,  imposes a limit of 124 logical partitions).
              All the logical partitions reside inside a single extended  par-
              tition, and are defined using a linked-list data structure. This
              fact means that every logical partition be preceded by at  least
              one sector of unallocated space to hold its defining data struc-
              ture (an Extended Boot Record, or EBR).


       These distinctions mean that primary and logical partitions  cannot  be
       arbitrarily  interspersed. A disk can contain one to three primary par-
       titions, a block of one or more logical partitions, and one  to  three
       more  primary  partitions (for a total of three primary partitions, not
       counting the extended partition). Primary partitions may not  be  sand-
       wiched between logical partitions, since this would mean placing a pri-
       mary partition within an extended partition (which is just  a  specific
       type of primary partition).

       Unlike  most  disk utilities, fixpart's user interface ignores extended
       partitions. Internally, the program discards  the  information  on  the
       original  extended partition and, when you tell it to save its changes,
       it generates a new extended partition to contain the then-defined logi-
       cal  partitions. This is done because most of the repairs and manipula-
       tions the tool performs require generating a fresh extended  partition,
       so keeping the original in the user interface would only be a complica-
       tion.

       Another unusual feature of fixpart's user interface is  that  partition
       numbers do  not  necessarily correlate with primary/logical status. In
       most  utilities,  partitions  1-4  correspond  to  primary  partitions,
       whereas partitions  5  and  up are logical partitions. In fixpart, any
       partition number may be assigned primary or logical status, so long  as
       the  rules  for layout described earlier are obeyed. When the partition
       table is saved, partitions will be  assigned  appropriately  and  then
       tools  such  as the Linux kernel and fdisk will give them conventional
       numbers.

       When it first starts, fixpart performs a scan for GPT data. If the disk
       looks like a conventional GPT disk, fixpart refuses to run. If the disk
       appears to be a conventional MBR disk but GPT signatures are present in
       the  GPT  primary  or  secondary header areas, fixpart offers to delete
       this extraneous data. If you tell it to do so, the program  immediately
       wipes  the  GPT header or headers. (If only one header was found, only
       that one header will be erased, to minimize the risk of damaging a boot
       loader  or  other  data that might have overwritten just one of the GPT
       headers.)

       With the exception of optionally erasing  leftover  GPT data  when  it
       first starts, fixpart keeps all changes in memory until the user writes
       changes with the w command. Thus, you can adjust your partitions in the
       user interface and abort those changes by typing q to quit without sav-
       ing changes.


OPTIONS
       The fixparts utility supports no command-line options, except for spec-
       ification of the target device.

       Most  interactions  with  fixparts occur with its interactive text-mode
       menu. Specific functions are:


       a      Toggle the active/boot flag. This flag is required by some  boot
              loaders and OSes.



       c      Recompute  the  cylinder/head/sector (CHS) values for all parti-
              tions. CHS addressing mode is largely obsolete,  but  some  OSes
              and  utilities  complain if they don't like the CHS values. Note
              that fixparts' CHS values are likely to be  incorrect  on  disks
              smaller than about 8 GiB except on Linux.


       l      Change  a  partition's  status to logical. This option will only
              work if the current partition layout  supports  such  a  change.
              Note  that  if  changing a partition's status in this way is not
              currently possible, making some other change may make it possi-
              ble. For instance, omitting a partition that precedes the target
              partition may enable converting a partition to logical  form  if
              there had been no free sectors between the two partitions.


       o      Omit  a partition. Once omitted, the partition will still appear
              in the fixpart partition list, but it will be flagged  as  omit-
              ted.  You can subsequently convert it to primary or logical form
              with the r or l  commands,  respectively.  When  you  save  your
              changes with w, though, the partition will be lost.


       p      Display  basic partition summary data. This includes partition's
              number, the boot/active flag's status, starting and ending  sec-
              tor  numbers, primary/logical/omitted status, whether or not the
              partition may be converted to logical form, and the  partition's
              MBR types code.


       q      Quit  from  the  program without saving your changes.  Use this
              option if you just wanted to view information or if you  make  a
              mistake and want to back out of all your changes.


       r      Change  a  partition's  status to primary. This option will only
              work if the current partition layout  supports  such  a  change.
              Note  that  every  partition  can theoretically become a primary
              partition, although in some configurations, making  this change
              will  require  omitting some partitions. If fixparts refuses to
              allow changing a partition to primary, you may need  to  convert
              other partitions to logical form or omit them entirely.


       s      Sort  partition  entries.  This  option orders partitions in the
              display to match their on-disk positions, which can make under-
              standing the  disk layout easier in some cases. This option has
              no effect on the ultimate ordering of logical partitions,  which
              are  sorted  before being saved. The order of primary partitions
              in the final saved partition  table  may be  affected  by  this
              option.  In  both cases, as already noted, the partition numbers
              displayed by fixparts may not be the same as those used  by  the
              kernel or displayed by other partitioning tools.


       t      Change  a partition's type code. You enter the type code using a
              one-byte hexadecimal number.


       w      Write data. Use this command to save your changes and exit  from
              the program.


       ?      Print  the  menu.  Type  this command (or any other unrecognized
              command) to see a summary of available options.


BUGS
       As of May 2012 (version 0.8.5), fixparts  should  be  considered  beta
       software. Known bugs and limitations include:


       *      The program compiles correctly only on Linux, FreeBSD, Mac OS X,
              and Windows.  Linux versions for x86-64 (64-bit), x86  (32-bit),
              and  PowerPC  (32-bit) have been tested, with the x86-64 version
              having seen the most testing. Under FreeBSD,  32-bit  (x86)  and
              64-bit  (x86-64) versions have been tested. Only 32-bit versions
              for Mac OS X and Windows have been tested.


       *      The FreeBSD version of the program can't write  changes  to  the
              partition  table to a disk when existing partitions on that disk
              are mounted. (The same problem exists with  many other  FreeBSD
              utilities,  such as gpt, fdisk, and dd.) This limitation can be
              overcome by typing sysctl  kern.geom.debugflags=16  at  a  shell
              prompt.


       *      The program can load only up to 128 partitions (4 primary parti-
              tions and 124 logical partitions). This limit can be  raised  by
              changing the #define MAX_MBR_PARTS line in the basicmbr.h source
              code file and recompiling.


       *      The program can read partitions only if the disk has correct LBA
              partition  descriptors.  These  descriptors should be present on
              any disk over 8 GiB in size or on smaller disks partitioned with
              any but very ancient software.


       *      The  program makes no effort to preserve partition numbers. This
              can have consequences for boot loaders and for mounting filesys-
              tems  via  /etc/fstab. It may be necessary to edit configuration
              files or even to re-install your boot loader.


       *      The program may change the order of partitions in the  partition
              table.


AUTHORS
       Primary author: Roderick W. Smith (rodsmith@rodsbooks.com)

       Contributors:

       * Yves Blusseau (1otnwmz02@sneakemail.com)

       * David Hubbard (david.c.hubbard@gmail.com)

       * Justin Maggard (justin.maggard@netgear.com)

       * Dwight Schauer (dschauer@ti.com)

       * Florian Zumbiehl (florz@florz.de)



SEE ALSO
       cfdisk  (8),  cgdisk  (8),  fdisk (8), mkfs (8), parted (8), sfdisk (8)
       gdisk (8) sgdisk (8)

       http://en.wikipedia.org/wiki/Master_boot_record

       http://www.rodsbooks.com/fixparts/


AVAILABILITY
       The fixparts command is part of the GPT fdisk package and is  available
       from Rod Smith.



Roderick W. Smith       0.8.5      FIXPARTS(8)
