FreeBSD 101 : Disk labels, GEOM, GPT, UFS
Disk labels and why do we use them:
FreeBSD gives names to drives as it discovers them at boot time.
In this first diagram, we can see that after John adds the new disk, ada1 is renamed ada2.
This could result in the system not been able to locate data or not being able to function properly.
GPT partitions:
GPT is the new layout of the partition table. Partitions in this new scheme have an identifier called the Global Unified Identifier(GUID) associated with them.
These GUIDs live in /dev/gptid.
Disks have another identifier associated with them called the diskid. it lives in /dev/diskid directory.
Disks have another identifier associated with them called the diskid. it lives in /dev/diskid directory.
Types of labels:
There are two types of labels:
- Generic label.
- Filesystem label.
FreeBSD can use GPT GUID as a generic label (not tied to a filesystem), as you can see below in the example:
GPT ID label for first partition on the disk (ada0p1):
you can find these labels in /dev/gptid directory.

The partition is listed in the /dev folder. FreeBSD keeps all the "logical"device file that represent all the devices that are attached to the system in the /dev directory.
GUID (GPT ID) and /etc/fstab:
In the example above:
- P1 is associated with the directory /dir1.
- P2 is associated with the directory /dir4.
- P3 is associated with the directory /dir3.
- P4 is associated with the directory /dir2.
/etc/fstab:
/etc/fstab is a file that contains a table that tells the system how different disk partition can be used by the system and which read and write permissions they have...
GUIDs are stored in the partition, GPT ID stays the same even if we move the disk to another machine.
By putting the GUID (for example : /dev/gptid/2575c8a0-c698-11ea-b467-705a0f30083d) in the fstab file instead of the partition name, we know that FreeBSD will mount the right partition, even if we add new devices to the system.
GPT Labels:
If you decide to use your own labels (create them manually) instead of using the automatically assigned ones, you need to follow the below steps:
If you decide to use your own labels (create them manually) instead of using the automatically assigned ones, you need to follow the below steps:
- Set the Kernel attribute kern.geom.label.gptid.enable to 0 in /boot/loader.conf to keep the kernel from assigning automatic labels.
The manually created labels are kept inside the partition, if you move the disk, the label moves with it.
GPT label example:
We can assign the GPT label home to the partition ada1p2. After the creation the label will be found in /dev/gpt directory.
We format the UFS partition:

We use the partition label in the /etc/fstab file instead of the gpid or the partition name as below:

If we don't use labels, the system assigns an automatic gptid to the partition.

If we don't use labels, the system assigns an automatic gptid to the partition.
GEOM Labels:
Another type of labels we could use, are the GEOM labels using the glabel command
The GEOM labels are stored in is stored in /dev/label directory.
These labels are not filesystem-specific.

UFS labels :
Another type of labels we could use, are the GEOM labels using the glabel command
The GEOM labels are stored in is stored in /dev/label directory.
These labels are not filesystem-specific.
We have two types of GEOM labels:
- Temporary labels: created with "glabel create"command and are destroyed after a reboot.
- Permanant labels: created with the "glabel label" command.

UFS labels :
Diagrams 1 and 2 appear identical, should be different.
ReplyDeleteThank you for the heads-up Fuzzy, we updated the diagram.
Delete