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.
In the second diagram we use GPT labels. If the name of the disk changed after John added a new disk, the labels stayed the same and the system is able to function properly.
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.
Types of labels:
There are two types of labels:
GPT GUID Labels (GPT Unified Identifier) are assigned automatically by the system. 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:
For the user to be able to access a partition and create files inside for example, the partition -after formatting- needs to be associated (mounted) with a directory in the system.
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 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 ID label is assigned automatically to the GPT partitions, but you can change these labels manually into more recognizable names using the GPT labels discussed in the next chapter.
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/gptdirectory.
Create a partition ada1p2 with label "home" :
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.
In the example below we add a partition without assigning a label to it:
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.
In the example below we assign the permanent GEOM label "home" to the ada1p1 partition :
UFS labels :
UFS labels are filesystem-specific and will be created in /dev/ufs in the case of the FreeBSD UFS system, -/dev/ufs/home- in this example):