# Mounting UFS partition by lable using dsbmd



## sprock (Jul 3, 2022)

Hello,

I have a portable USB drive that I would like to use for backup.  I have on it a UFS partition labeled "Backup".  I have been using dsbmd to mount removable media.  By default it mounts them as /media/da0p1 etc, i.e using the geom/partition names.  I want to mount my portable drive by label as /media/Backup so that I can move it between multiple machines and have a consistent mount point.  I looked through dsbmd but found no info on how to do this for as UFS filesystem.  Can it be done?  If so could someone share an example?

Thanks,
sprock


----------



## Erichans (Jul 3, 2022)

What command did you use to label the UFS partition?


----------



## sprock (Jul 3, 2022)

tunefs -L Backup /dev/da0p1


----------



## Erichans (Jul 3, 2022)

I am not familiar with dsbmd. After the tunefs command you should see the label with `glabel list`, like here on my `da0p4` in the code below. glabel(8) can only _change_ glabel labels but it can show various other types, including UFS labels. It shows up at the entry `1. Name: ufs/Backup`; that is the name that is being provided to the OS. The sequence below starts with the partition unmounted. When unmounted, you' ll be able to see both entries /dev/ufs/Backup and /dev/da0p4. When you mount the partition as `/dev/da0p4` the UFS label is being hidden by the OS: see command [7]. This is called GEOM withering. When you unmount, the label appears again at /dev/ufs/ (see command [9]). Mounting it by the UFS label entry /dev/ufs/Backup gives the desired result. Adapt your values for fstab accordingly.

```
[1] # glabel list da0p4
Geom name: da0p4
Providers:
1. Name: ufs/Backup
   Mediasize: 69206016 (66M)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 202395648
   Mode: r0w0e0
   secoffset: 0
   offset: 0
   seclength: 135168
   length: 69206016
   index: 0
Consumers:
1. Name: da0p4
   Mediasize: 69206016 (66M)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 202395648
   Mode: r0w0e0

[2] # ls /dev/da0*
/dev/da0    /dev/da0p1    /dev/da0p2    /dev/da0p3    /dev/da0p4
[3] # ls /dev/ufs/
Backup
[4] # mount -w -t ufs /dev/da0p4 /tmp
[5] # mount | grep /tmp
/dev/da0p4 on /tmp (ufs, local)
[6] # ls /dev/da0*
/dev/da0    /dev/da0p1    /dev/da0p2    /dev/da0p3    /dev/da0p4
[7] # ls /dev/ufs/
ls: /dev/ufs/: No such file or directory
[8] # umount /tmp
[9] # ls /dev/ufs/
Backup
[10] # mount -w -t ufs /dev/ufs/Backup /tmp
[11] # mount | grep /tmp
/dev/ufs/Backup on /tmp (ufs, local)
[12] # ls /dev/ufs/
Backup
```

I don't know if you have a specific reason to want to use UFS labels but, you might also consider using GPT labels. Those are universal and not tied to any particular filesystem (or even OS); the only prerequisite is that you create the partition as a GPT partition of course.


----------



## sprock (Jul 4, 2022)

Hello,

Thanks for the response.

I don't want the have an entry for this removeable device in /etc/fstab.  I was hoping that dsbmd would be capable of using the label to create a mountpoint and mount the disk.  Having labeled the partition using gpart modify I can see the entry in /dev/gpt but dsbmd ignores it.  Indeed, based on my experiments dsbmd seems not to read its own config file.

Oh well.

Thanks agian,
sprock


----------

