Using EFI labels on FreeBSD

A quick post since this isn’t well covered: FreeBSD on EFI systems still will hard-code the name enumerated at install time (like da0p2). There is a better way than using glabel (which injects itself into the last block of the partition, which can be problematic). Instead, you can use GPT labels, which are cross-platform and well-known.

First, replacing da1 with your disk, use gpart show to see what indices you need:

$ sudo gpart show da1
=>       40  501253056  da1  GPT  (239G)
         40     409600    1  efi  (200M)
     409640  492421120    2  freebsd-ufs  (235G)
  492830760    8388608    3  freebsd-swap  (4.0G)
  501219368      33728       - free -  (16M)

Then, run gpart modify to add labels, then you can run show with the -l flag to show labels:

$ sudo gpart modify -l illswap -i 3 da1
da1p3 modified
$ sudo gpart modify -l illroot -i 2 da1
da1p2 modified
$ sudo gpart show -l da1
=>       40  501253056  da1  GPT  (239G)
         40     409600    1  (null)  (200M)
     409640  492421120    2  illroot  (235G)
  492830760    8388608    3  illswap  (4.0G)
  501219368      33728       - free -  (16M)

The disks will appear in /dev/gpt, but they won’t appear right away. You can modify /etc/fstab though, and your changes (the enumeration by label and the new mount points) will work on reboot.

# Device	Mountpoint	FStype	Options	Dump	Pass#
/dev/gpt/illroot	/		ufs	rw,noatime	1	1
/dev/gpt/illswap	none		swap	sw	0	0

Leave a Reply

Your email address will not be published. Required fields are marked *