UFS Is it possible to use disk labels instead of /dev/adaXX in /etc/fstab?

Hi,

Recently, I faced a problem with my 11.2 installation, were adding additional disks before the already existing disk is causing the system to run into mountroot> prompt or reboot.

The issue is straight forward. The /etc/fstab entry has the disk name as /dev/ada0p1. When additional disk are added before the existing disk, new disk seems to be named ada0 the existing disk is changed to ada1. So, when try to mount root as /dev/ada0p1 it fails and runs to mountroot> prompt or reboots.

So, few questions?
1) Is it possible to use labels instead of disk names in /etc/fstab? Like linux has the UUID labels in /etc/fstab?
2) I see sometimes the machine is rebooting and sometimes running to mountroot> prompt? Is there any configuration which defines this behavior?
3) Overall, what is the best way to add disk seamlessly to FreeBSD system with the naming changes not impacting the system?

Thanks,
Rajesh.
 
Please notice the oversized text in the handbook. You need to run tunefs unmounted. Not mounted when ran..

So you can reboot and at the Beastie Menu go into Single User Mode and use tunefs from there.
You can check what the drive letter is by calling up ls /dev.
 
Hi Phishfry, Thanks for your answers. It helps.

Another question here. Is there any specific reason why the /etc/fstab entry will be having the regular device name (rather than label) by default. If labeling is the default way, it would be helpful right? Also, seems like manual partitioning during Install provides an option "Label". If a valid label is provided, will that be used in /etc/fstab instead of regular names?

Overall, is there any config which can be used to label disk during install and use that label in /etc/fstab by default?
 
If labeling is the default way, it would be helpful right?
It is only useful for people using removable storage. Most users are not swapping disks around.

Also, seems like manual partitioning during Install provides an option "Label". If a valid label is provided, will that be used in /etc/fstab instead of regular names?
Yes this setting is also available on a FreeBSD GPT installation using Automatic disk setup. The trick is at the end of the partitioning you (M)odify your partitions and with GPT, the "label" field is available. Right below "mount point" setting.
Not available on an automatic MBR install.
 
Last edited:
it’s better to use UUID (GPTID) instead of /dev/da# because if there’s additional device added or removed from the IDE/SCSI controller the ‘daN’ will change and the OS will fail to boot. To do this get the rawuuid number using “gpart list” and edit the fstab to match /dev/gptid/

gpart list | grep -A 11 'ada0p2\|ada0p3' | grep 'rawuuid\|type\|Name'
 
Last edited:
GPT UUID are definitely superior to GPT Labels.
I GPT Labeled all my 24 storage drives and used the serial number for the label.
Silly me did not catch that is was parsing the last characters as the serial number was too long.
So that was an early lesson for me with glabel(8)
There is a rather small character limit on glabel GPT Label name length.
 
I don't recommend using the actual GEOM labels that write their own metadata at the end of the provider, they are incompatible with wide varieties of other types of metadata and may cause conflics. Use GPT labels when GPT partitioning is used and UFS labels with MBR partitioned disks. The swap is a bit of a problem with UFS labels because the swap partition has no actual filesystem, it's just a storage of data blocks, you'll have to live with using a device name for swap in that case.
 
Use GPT labels when GPT partitioning is used and UFS labels with MBR partitioned disks. The swap is a bit of a problem with UFS labels because the swap partition has no actual filesystem, it's just a storage of data blocks, you'll have to live with using a device name for swap in that case.
Handbook said:
For example, UFS2 file system labels will be created in /dev/ufs. Generic permanent labels can be created with glabel label. These are not file system specific and will be created in /dev/label.
It showed /dev/ufs/ entries being created with tunefs, and /dev/label/ entries being created with gpart.

Phishfry mentioned that filesystems must be unmounted when using tunefs, and said label mounting is only useful for swapping disks. In the Handbook, there's an example of glabel using permanent labeling for the root partition, and can do so from single user mode.

Can I mix glabel(8) and tunefs(8) together? To use glabel for the root partition and swap, and use tunefs for other UFS specific filesystems?
 
So, I must use a FreeBSD install cd to label the root directory with tunefs. According to its manpage, tunefs(8) requires the filesystem to be unmounted or read only. It implies at the very end of the manpage that, tunefs can be used on the root filesystem, provided it's read only or unmounted, and will require a reboot.

I still want a means to mount swap as a label.
 
So, I must use a FreeBSD install cd to label the root directory with tunefs. According to its manpage, tunefs requires the filesystem to be unmounted or read only. It implies at the very end of the manpage that, tunefs can be used on the root filesystem, provided it's read only or unmounted, and will require a reboot.

I still want a means to mount swap as a label.

Partition the disks using GPT and you can label the partitions, regardless of what filesystem you use. You can even label the boot loader partition and swap this way. The labels create links under /dev/gpt/ that can be used anywhere a disk device can be used.
 
I found what I wanted: http://www.wonkity.com/~wblock/docs/html/labels.html
It used glabel for swap, and tunefs for UFS file systems. I fixed all of them that could be umounted and turned off swap using multi-user mode. Then, I used tunefs on the root filesystem from single user mode, because single user mode mounted everything as read only.

I used geli .eli at the end of a swap label entry in /etc/fstab, but not to create the partition label.

The information from swapinfo is not aligned, because of the long name of the mountpoint, but it will do.
 
Now I have the following partition / slices:
da2p1 efi filesystem
da2p2 freebsd-ufs
da2p3 freebsd-swap

should I label as below without applicable labeling to the efi system

da2p2 freebsd-ufs ==> gptrootfs
da2p3 freebsd-swap ==> gptswap
Now, should I put a label e.g. ''gptboot" on the efi system on the da2p1 partition should I add this to the fstab file?
 
I like to use the following pattern when naming things: Xpart for the partition, Xfs for the filesystem (although this is generally only used on my Linux systems; for FreeBSD I tend to just stick with GPT partition labels). So, for your layout:

da2p1 --> efipart
da2p2 --> rootpart
da2p3 --> swappart

Then, you could label the UFS filesystem as rootfs.

Giving you the following choices for mounting (pick one from each grouping to use):
/dev/da2p1
/dev/gpt/efipart

/dev/da2p2
/dev/gpt/rootpart
/dev/ufs/rootfs

/dev/da2p3
/dev/gpt/swappart
 
Back
Top