Daemon

Check their manualpages and you'll see. tunefs is a tool specifically meant to tune an UFS filesystem. So obviously it has little to do with partitions / slices. glabel is used to (quote): "GEOM provider labelization". This should of course raise the question "What is a GEOM class?". Well, check geom(8). You'll notice once again that it is filesystem related and not so much with partitions (or slices).

Depending on your setup the best way to apply a label to a partition is by using gpart(8).

New Member

tunefs operates on partitions of ufs, glabel operates on partitions (e.g. /dev/da0p1) and/or entire disk (e.g. /dev/da0)
Below are the steps of labeling a partition using glabel.
1. umount the partition you want to label
2. label the partition using glabel label <label_name> <provider>. where <provider> is the disk partition entry in /dev you want to label, e.g. /dev/ada0p1
After step 1 and step 2, you can see an entry in /dev/label/<label_name>, to which you can then refer in your fstab

Daemon

Just to add extra complication.., there's also gpt labels. (ShelLuser has already mentioned this is likely the best way to label partitions)

If you are creating partitions on a new disk (or the disk is already gpt partitioned), I would highly recommend using gpt over glabel.

gpt labels are stored as part of the partition table. They appear on the system as /dev/gpt/labelname, and are part of the spec. Any other operating system with support for gpt will be able to see/use the labels.

glabel is FreeBSD specific and a bit of a hack. It just stores the label in the last block of the partition, and creates a new device called /dev/label/labelname which is one block smaller than the original. Not that it ever really causes a problem but it does mean the label is part of the active partition if you look at the original device.

It was useful when we only had MBR and you could easily label swap/root etc with glabel and use those labels in fstab, but now you may as well just use gpt (via the gpart() command in FreeBSD) unless you already have existing non-gpt partitions you need to label.

Well-Known Member

Be careful with glabel - it acts as an additional layer and therefore places its own header on the disk/slice/partition, which might interfere with other headers (e.g. gmultipath). I had some headaches with a system that booted from multipath FC targets and GPT/gmultipath/glabel were fighting for the same addresses to put their headers/labels in.

My recommendation is to stick to GPT and its labels if possible, so you don't have to handle multiple types of headers and labels (and multiple tools to manage them).

To make sure FreeBSD uses the gpt labels as primary source for identification (e.g. to show GPT labels in zpool status output), disable the other labeling methods in /boot/loader.conf:

Daemon

tunefs operates on partitions of ufs, glabel operates on partitions (e.g. /dev/da0p1) and/or entire disk (e.g. /dev/da0)
Below is the steps of labeling a partition using glabel.
1. umount the partition you want to label
2. label the partition using glabel label <label_name> <provider>. where <provider> is the disk partition entry in /dev you want to label, e.g. /dev/ada0p1
After step 1 and step 2, you can see an entry in /dev/label/<label_name>, to which you can then refer in your fstab

I have a laptop with two hard disks ada0 and ada1. I want to to put a label of S01 on ada1s3 which is a FreeBSD partition, and I'm booting from ada0 so as not to mount the parttion I want to label. When running gpart show it shows

label/S01

against the correct partition but the directory (ada1s3a)/dev is blank...

Strangely, when I boot from ada1 there is a /dev/label but it contains
S07p3
S07p3a
S07p3b

which must be a throwover from when I last tried to get labels to work.

New Member

I have a laptop with two hard disks ada0 and ada1. I want to to put a label of S01 on ada1s3 which is a FreeBSD partition, and I'm booting from ada0 so as not to mount the parttion I want to label. When running gpart show it shows

label/S01

against the correct partition but the directory (ada1s3a)/dev is blank...

Strangely, when I boot from ada1 there is a /dev/label but it contains
S07p3
S07p3a
S07p3b

which must be a throwover from when I last tried to get labels to work.