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

Rajesh

Member

Reaction score: 5
Messages: 73

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.
 

Phishfry

Son of Beastie

Reaction score: 1,528
Messages: 4,438

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.
 
OP
OP
R

Rajesh

Member

Reaction score: 5
Messages: 73

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?
 

Phishfry

Son of Beastie

Reaction score: 1,528
Messages: 4,438

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:

VladiBG

Aspiring Daemon

Reaction score: 264
Messages: 641

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:

Phishfry

Son of Beastie

Reaction score: 1,528
Messages: 4,438

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.
 

kpa

Beastie's Twin

Reaction score: 1,810
Messages: 6,318

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.
 

sidetone

Daemon

Reaction score: 429
Messages: 1,161

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?
 

sidetone

Daemon

Reaction score: 429
Messages: 1,161

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.
 

phoenix

Administrator
Staff member
Administrator
Moderator

Reaction score: 1,264
Messages: 4,099

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.
 

sidetone

Daemon

Reaction score: 429
Messages: 1,161

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.
 

jaymax

Well-Known Member

Reaction score: 1
Messages: 265

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?
 

phoenix

Administrator
Staff member
Administrator
Moderator

Reaction score: 1,264
Messages: 4,099

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
 

k.jacker

Aspiring Daemon

Reaction score: 434
Messages: 738

A bit conflicting or have I missed something?
From the Post 'No' - is that to the labelling or to the fstab addition?
From your tutorial
Sorry, I meant you can of course label your efi partition, but do not add that to /etc/fstab.
 
Top