Solved How to use UUID to identify partitions on FreeBSD

Hello to everyone.

Actually on my PC I have more USB disks where I have installed FreeBSD mapped as you see below,that can't boot if I attach another disk before to boot one of them,because the enumeration of the daX disks changes :

Code:
=>       40  625142368  da0  GPT  (298G)
         40     532480    1  efi  (260M)
532520  616030208    2  freebsd-ufs  (294G)
616562728    8388608    3  freebsd-swap  (4.0G)
624951336     191072       - free -  (93M)

=>       40  156301408  da2  GPT  (75G)
         40     532480    1  efi  (260M)
532520  148365312    2  freebsd-ufs  (71G)
148897832    7403616    3  freebsd-swap  (3.5G)

For this reason I would like to map them using the uuid number,which are the following :

Code:
# gpart list da0 | grep rawuuid

rawuuid: 87e7b403-f0de-11ed-8f63-e0d55ee21f22
rawuuid: 87e98cd1-f0de-11ed-8f63-e0d55ee21f22
rawuuid: 87ec5c5b-f0de-11ed-8f63-e0d55ee21f22


# gpart list da2 | grep rawuuid

rawuuid: 46d1d6aa-b17d-11ed-914d-e0d55ee21f22
rawuuid: 46dc3c5d-b17d-11ed-914d-e0d55ee21f22
rawuuid: 46ea53be-b17d-11ed-914d-e0d55ee21f22

I'm trying to understand how to do it. I've found this guide and I tried to repeat the steps suggested :


according with the disks that I should remap,I have changed the respective /etc/fstab files like this :

Code:
nano /mnt/da0p2/etc/fstab :

# Device                        Mountpoint        FStype        Options        Dump    Pass#

/dev/gptid/87e7b403-f0de-11ed-8f63-e0d55ee21f22         /            ufs        rw        1    1
/dev/gptid/87e98cd1-f0de-11ed-8f63-e0d55ee21f22         /boot/efi        msdosfs        rw        2    2
/dev/gptid/87ec5c5b-f0de-11ed-8f63-e0d55ee21f22         /none            swap        sw        0    0

nano /mnt/da2p2/etc/fstab :

# Device                        Mountpoint        FStype        Options        Dump    Pass#

/dev/gptid/46d1d6aa-b17d-11ed-914d-e0d55ee21f22         /            ufs        rw        1    1
/dev/gptid/46dc3c5d-b17d-11ed-914d-e0d55ee21f22         /boot/efi        msdosfs        rw        2    2
/dev/gptid/46ea53be-b17d-11ed-914d-e0d55ee21f22         /none            swap        sw        0    0

problem is that these disks aren't still recognized : it means that FreeBSD does not boot from them. It seems the system can't find the /dev/gptid directory ; Dunno why. I don't understand where the error could be.
 
If you look at gpart list closely, you will notice the partitions are listed numerically:
Code:
da0p1 = efi partition
da0p2 = freebsd-ufs partition
da0p3 = freebsd-swap partition
Code:
# gpart list da0 | grep rawuuid

rawuuid: 46d1d6aa-b17d-11ed-914d-e0d55ee21f22   efi partition
rawuuid: 46dc3c5d-b17d-11ed-914d-e0d55ee21f22   freebsd-ufs partition
rawuuid: 46ea53be-b17d-11ed-914d-e0d55ee21f22   freebsd-swap partition

Interchange the uuids in /etc/fstab for " / " and "/boot/efi" on both disks, da0 and da2.

Besides, it would be easier to label the disks then use uuids (gpart modify -i <index> -l <label> geom)
 
Manipulating
Code:
kern.geom.label.gptid.enable
kern.geom.label.disk_ident.enable
kern.geom.label.ufsid.enable
won't do any good here. The root " / " and "/boot/efi" uuids are set wrong.
 
Default installation adds kern.geom.label.gptid.enable="0" to /boot/loader.conf; try commenting that line.

Code:
kern.geom.label.gptid.enable="1"
kern.geom.label.disk_ident.enable="1"
kern.geom.label.ufsid.enable="1"

is that correct ?
 
For the users that will jump to this question. On FreeBSD 14.0 at today,we can't do :

Code:
kern.geom.label.disk_ident.enable="1"
kern.geom.label.gptid.enable="1"

otherwise,we get this kernel panic :

WhatsApp Image 2023-05-21 at 22.45.13.jpeg


instead,this argument works ok :

Code:
kern.geom.label.ufsid.enable="1"

and it will enable the mapping of the disks using the UUID method.
 
Back
Top