published on in Geekyness FreeBSD GEOM Jenny Labels

why you should use disk labels

I recently had a little problem with a new FreeBSD install, and it is one of those times were I sort of appreciate how FreeBSD assigns device handles, yet at the same time hate it :)

The setup is this: The OS was installed on a mirrored hardware raid device (using the mpt(4) driver), and then I had a large RAID6 array attached via a FC controller (using the isp(4) driver). When I installed the OS, the mpt device was showing up as da0. So I went ahead with the install and rebooted the system, so far so good.

What I didn’t realize was the FC device was not seen yet, so after some fiddling, Jenny and I got the large RAID6 array to show up… unfortunately, the isp card was before the mpt card on the PCI bus: isp0@pci0:2:1:0: class=0x0c0400 card=0x01321077 chip=0x63221077 rev=0x03 hdr=0x00 vendor = 'QLogic Corporation' device = 'QLA6322 Fibre Channel Adapter' class = serial bus subclass = Fibre Channel mpt0@pci0:2:3:0: class=0x010000 card=0x30601000 chip=0x00501000 rev=0x02 hdr=0x00 vendor = 'LSI Logic (Was: Symbios Logic, NCR)' device = 'SAS 3000 series, 4-port with 1064 -StorPort' class = mass storage subclass = SCSI and the RAID6 now became da0, and the OS device now became da1.


The system prompted for the / drive, so I had to call out the correct device at the mount> prompt: mount> ufs:/dev/da1s1a After that, the system continue to boot into mult-user mode, which cause some very strange console behavior (it acted like the return key was being held down), and my only option was to SSH in as local user, su to root, and then fix /etc/fstab.

This was not devastating, however, it show the importance of using disk labels instead of device handles in certain use cases. I haven’t fixed the / mount, but to get a comfort level with using GEOM labels I added another drive to the system and called it EXPORT.

You can assign a permanent label in two ways (that I know of). When you newfs the device, you can specify the L flag (BTW, -O2 means to use UFS2, and -U will use Soft-Updates): [root@paper ~]> newfs -O2 -U -L EXPORT /dev/da2s1a OR using glabel (which is what you would have to do for a non UFS filesystem. [root@paper ~]> glabel create EXPORT da2s1a Now we can see our newly labeled device in action: [root@paper ~]> ls /dev/label . .. EXPORT [root@paper ~]> glabel status Name Status Components label/EXPORT N/A da2s1a To add it to /etc/fstab, you can either edit the file, or append the correctly tab-delimited line like so: [root@paper ~]> echo "/dev/label/EXPORT\t/export\tufs\trw\t2\t2" >> /etc/fstab [root@paper ~]> mkdir /export [root@paper ~]> mount export Hurray! ` [root@paper ~]> df Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/da1s1a 60931274 4754540 51302234 8% / devfs 1 1 0 100% /dev tank 10569645824 107237376 10462408448 1% /tank /dev/label/EXPORT 132022788 4 121460962 0% /export

[root@paper ~]> mount /dev/da1s1a on / (ufs, local, soft-updates) devfs on /dev (devfs, local, multilabel) tank on /tank (zfs, NFS exported, local) /dev/label/EXPORT on /export (ufs, local) `

This is now a persistent label. To be safe, I’ll have to boot off of a CD/USB drive and modify the root device.