Forcing GUID Partition Table on a disk with CentOS 6

CentOS 6 is now out so I can finally build up a new HP ProLiant Microserver that I purchased for a new home server. Amongst many new features, CentOS 6 ships a GRUB bootloader that can boot from a disk with a GUID Partition Table (GPT for short). Despite not having EFI, the HP BIOS can boot from GPT disks so there’s no limitation with disk sizes that I can use.

However, before I tore down my current home server I wanted to test all of this really did work so I popped a “small” 500 GB disk in the HP. The trouble is the CentOS installer won’t use GPT if the disk is smaller than 2 TB. Normally this wouldn’t be a problem with a single disk apart from I want to specifically test GPT functionality but this can cause complications if your disk is in fact a hardware RAID volume because most RAID controllers allow the following scenario:

  1. You have a RAID 5 volume comprising 4x 500 GB disks, so the OS sees ~ 1.5 TB raw space.
  2. Pull one 500 GB disk, replace with a 1 TB disk, wait for RAID volume to rebuild.
  3. Rinse and repeat until all disks are upgraded.
  4. Grow RAID volume to use the extra space, OS now sees ~ 3 TB raw space.
  5. Resize partitions on the volume, grow filesystems, etc.

You’ll find your volume will have a traditional MBR partition scheme as it fell below the 2 TB limit so you can’t resize the partitions to fully use the new space. While it might be possible to non-destructively convert MBR to GPT, I wouldn’t want to risk it with terabytes of data. It would be far better to just use GPT from the start to save painting myself into a corner later.

If you’re doing a normal install, start the installer until you get to what’s known as stage 2 such that on (ctrl+)alt+F2 you have a working shell. From here, you can use parted to create an empty GPT on the disk:

# /usr/sbin/parted -s /dev/sda mklabel gpt

Return to the installer and keep going until you reach the partitioning choices. Pick the “use empty space” option and the installer will create new partitions within the new GPT. If you choose the “delete everything” option, the installer will replace the GPT with MBR again.

If like me you’re using kickstart to automate the install process, you can do something similar in your kickstart file with the %pre section, something like the following:

%pre
/usr/sbin/parted -s /dev/sda mklabel gpt
%end

Then make sure your kickstart contains no clearpart instructions so it will default to just using the empty space. The only small nit I found after the install is that the minimal install option only includes fdisk and not parted as well so if you want to manage the disk partitions you’ll need to add that either at install time or afterwards as fdisk doesn’t support GPT.

Tags: , , , ,

9 Responses to “Forcing GUID Partition Table on a disk with CentOS 6”

  1. jonty says:

    Ta very much. I’m just about to install CentOS 6 and wanted to know exactly this. I owe you a coffee/tea/beer/liquid based refreshment of your preference.

  2. Jamie says:

    Ditto. Thanks for posting this. It was driving me crazy not being able to partition more than 2TB.

    Only issue was that it dropped out of the graphical installation process and hung after executing parted. I went back to the console executed “sync” just to be safe and rebooted. Then I just restarted the install, making sure to use the “freespace” option.

    • matt says:

      Glad it was useful, although odd about the hanging, although I had to install using the “nomodeset” boot option otherwise the install would wedge when it tried to prod the graphics, although that happened way before I got to any disk partitioning.

  3. Mark Yelka says:

    The “return to the installer” instruction should tell people that this can be accomplished by pressing CTRL+ALT+F6. Who would have guessed that?! 🙂

  4. […] I found this article that discusses the setup under CentOS 6 but much of it should still apply. The article’s titled: Forcing GUID Partition Table on a disk with CentOS 6. […]

  5. Vince says:

    I wanted to use GPT instead of MSDOS. Works perfectly!

Leave a Reply