DUIDs and /etc/fstab

All OpenBSD platforms use the disklabel to identify partitions and other information about a disk. When you label a disk (as we did in Chapter 3 and will do by hand later this chapter), disklabel adds a disklabel unique identifier, or DUID, to the disk label. The DUID is a unique hexadecimal number that lets OpenBSD identify a specific disk.

To find a disk’s DUID, pass the device name to disklabel and look for the duid entry:

# disklabel sd0
…
duid: 55128c3700af5491
…

The disk currently attached as sd0 has a DUID of 55128c3700af5491. Even if you physically move the disk so that it becomes sd9 or sd18, OpenBSD can use the DUID to uniquely identify this disk.

OpenBSD uses the filesystem table /etc/fstab to map filesystems on a disk to mount points using either the disk location or the DUID. Each filesystem appears on its own line in /etc/fstab, as shown here:

1 55128c3700af5491.b 2none 3swap 4sw
55128c3700af5491.a / ffs rw 1 1
55128c3700af5491.k /home ffs rw,nodev,nosuid 1 2
55128c3700af5491.d /tmp ffs rw,nodev,nosuid 1 2
…

We’ll focus on the first entry to explore what’s going on here. The first field, 55128c3700af5491.b 1, is the location of the partition. Whereas older systems used the disk device name and the partition letter (such as /dev/sd0a), newer systems can use the DUID, a period, and the partition letter (as in 55128c3700af5491.a). By using DUIDs in the filesystem table, OpenBSD can always mount the same disk at the same location, no matter how it’s attached.

The second field, none 2, lists the mount point, which is the directory where the filesystem is attached to the directory tree. Every partition you can write files to is attached to a mount point (such as /usr, /var, and so on), with one partition being the root partition (/). Swap space uses a mount point of none.

Next, swap 3, is the filesystem type. The standard OpenBSD partition uses type ffs, the UNIX Fast File System. Other options include, but are not limited to, msdos (Microsoft-style FAT partitions), mfs (Memory File System), and cd9660 (CD).

The fourth field, sw 4, shows the mount options used for this filesystem. I’ll cover mount options in more detail in FFS Mount Options, but here are a few that frequently appear in /etc/fstab:

  • ro . The filesystem is mounted read-only. Not even root can write to it.

  • rw . The filesystem is mounted read-write.

  • nodev . Device nodes are not interpreted.

  • nosuid setuid files are forbidden.

  • noauto . OpenBSD won’t automatically mount the filesystem at boot or when running mount -a. This option is useful for removable media drives that might not have media in them, such as CD and USB flash drives.

The fifth field indicates whether dump(8) should back up this filesystem. If this field is 0 (or absent), dump doesn’t routinely back up the filesystem. Otherwise, the number given is the minimum dump level needed to back up the filesystem.

The last field is the pass number. It tells fsck when to check the filesystem during boot. Filesystems with a pass number of 1 are checked first, filesystems with a pass number of 2 are checked second, and so on. A pass number of 0 tells fsck to not check the filesystem during boot. If a filesystem doesn’t have a pass number, it’s equivalent to 0.

I strongly recommend using DUIDs in /etc/fstab and anywhere else, rather than using device node names. While a device node name might change, a DUID will not.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.62.94