GPT Documentation

GUID Partition Table

Introduction

GUID Partition Table or GPT is a replacement for the traditional MBR partition table scheme used on PCs. Traditional MBR partition schemes only support 4 partitions on a disk whereas GPT supports up to 128. As a workaround for the limited partition size, BSD systems have the concept of labels to break up a large partition into several smaller chunks. Similarly, Microsoft Windows systems have the concept of primary and extended partitions to allow additional logical separation on disks. On a GPT setup, you no longer need labels or extended partitions. SImply create a partition for each mount point you wish to use.

GPT has an additional benefit. It supports large hard drives greater than 2TB. It is recommended for systems with large hard drives, especially if one wishes to boot of the disk.

GPT also has some limitations. Some PC BIOS manufacturers do not properly support booting off GPT disks or require workarounds to do so. GPT was developed for UEFI, the replacement for historic BIOS on the PC. Most operating systems create a very small boot partition that is around 64k with a MBR in it to allow these systems to operate. That partition must be marked active or the BIOS will fail to boot the OS. This is know to be an issue with Intel motherboards using Award BIOS for instance.

Prepairing

You will need a MidnightBSD LiveCD or USB Flash drive in order to partition the disk. sysinstall does not support this configuration at this time. All existing data on the disk should be wiped and you should not use this approach on systems that will be dual booting another operating system such as Microsoft Windows or Linux. This requires 0.4-CURRENT from October 19, 2011 or higher. You will need copies of /boot/pmbr and /boot/gptboot which should be available on the recent Live CD.

Creating GUID Partitions

This assumes your disk is /dev/ad0

Clear the existing partition table and create a new GPT table:
gpt create -f ad0 This will automatically create the 64k boot partition (not to be confused with /boot)

Create root partition (512MB):
gpt add -t ufs -s 1048576 ad0
Verify your work with
gpt show ad0
Note that -s is the size in sectors. Choose the size that makes the sense for your setup. I'd recommend at least 512MB.

Create /var and /tmp (512MB):
gpt add -t ufs -s 1048576 ad0
gpt add -t ufs -s 1048576 ad0

Create swap (4GB):
gpt add -t swap -s 10485760 ad0

Use the remaining free space for /usr:
gpt add -t ufs ad0

Please note that we're specifying the type of filesystem with the -t flag. There are several other file systems available. For instance, you can use ZFS for /usr, etc. Remember that / must be on UFS2 because we don't support ZFS booting of MidnightBSD at this time.

Finally, format the partitions:
newfs -nL root /dev/ad0p2
newfs -nUL var /dev/ad0p3
newfs -nUL tmp /dev/ad0p4
newfs -nUL usr /dev/ad0p6
using glabels. These will be available as /dev/ufs/root, /dev/ufs/var, etc.

You're fstab will have entries like this:
/dev/ufs/root / ufs rw 1 1