Solved Adding a label to a live partition

I've read a number of posts about how to add a label to a live partition, but not fully understood how to do it. The instructions I've read such as Thread 69250 referred to GPT partitions, but I am interested in MBR.

I have a USB attached hard disk which is sometimes da0 and sometimes something else which can cause mountroot problems. I know I need to go into single user mode to change things, but the steps are confusing to me.

Can someone elucidate or point me to clear instructions?
 
See tunefs(8).

Code:
     -L volname
             Add/modify an optional file system volume label.  Legal
             characters are alphanumerics, dashes, and underscores.
 
There is no step-by-step manual exists.

For MBR you may try to use 'UFS labels'. It is about 'tunefs -L'.
But the affected partition must be unmounted first (as far as I know).

If you have a possibility to boot from FreeBSD liveCD/liveUSB or connect your USB-disk to another FreeBSD system
just use 'tunefs -L' to setup the labels for every partition on your disk.
tunefs -L usbrootfs /dev/da0s1a for example.
After that, you must to change all /etc/fstab entries with your 'da0'.
New names will be like '/dev/ufs/LABELs'.
Doublecheck, reboot, enjoy!

# grep /dev/ufs /etc/fstab
/dev/ufs/sataflash / ufs rw 1 1

tunefs -p /dev/ada0s1a
...
tunefs: volume label: (-L) sataflash

Another way is using geom label or singledrive gmirror for your USB-drive, but it require additional setup for preloading of kernel module at boot..
 
As I said, I get confused by the instructions I read.... On boot, I do into single user mode, put in the correct mountroot, ie

ufs:/dev/da3s3a instead of the /etc/fstab entry of /dev/da0s3a which allows me to enter the single user shell, at which point I enter:-
tunefs -L S05p3 /dev/da3sa
then mount -a and update /etc/fstab. On reboot I get a mountroot error saying that ufs:/dev/ufs/S05p3 does not exist.
I don't see a /dev/ufs/ although there is a /dev/ufsid/.

How do I check if the label has been created correctly?
 
How do I check if the label has been created correctly?
tunefs -p /dev/daXsYz
Look at an example under the spoiler within my previous post.

tunefs -L S05p3 /dev/da3sa
Are you sure you have /dev/da3sa instead of /dev/da3s3a ?
Please show the output of:
ls -al /dev/da*

All UFS labels appear inside /dev/ufs/ in a moment.
 
tunefs -p /dev/daXsYz
Look at an example under the spoiler within my previous post.


Are you sure you have /dev/da3sa instead of /dev/da3s3a ?
Please show the output of:
ls -al /dev/da*

All UFS labels appear inside /dev/ufs/ in a moment.
Well spotted that you found a typo, I was typing from memory, however if I had entered things wrongly the command would have failed...

I just noticed that if I am in the single user shell, the file /dev/ufs/S05p3 actually does exist. When I run mount -a it disappears.
I'm sure there is a trick to this, but it escapes me at the moment...
 
I just noticed that if I am in the single user shell, the file /dev/ufs/S05p3 actually does exist. When I run mount -a it disappears.
I'm sure there is a trick to this, but it escapes me at the moment...
This probably has to do with the kern.geom.label.disk_ident.enable sysctl.
 
The trick is to reboot immediately from single user mode, so I guess you should change /etc/fstab independently of adding a label...
 
Back
Top