HOWTO - attach drives by serial number

Matthew Dillon dillon at
Thu Aug 27 10:39:25 PDT 2009

    The upcoming release will have automatic recognition of drive serial
    numbers incorporated into DEVFS.  Here is a quick how-to on how to
    modify your boot and other files to recognize a drive by serial number.

    In /boot/loader.conf you want to specify a kenv that tells the kernel
    where the root filesystem is.  You can specify a devfs-relative
    serial number path instead of a drive name.  Note that devtab labels
    cannot be used in /boot/loader.conf as the boot loader does not parse
    the devtab:


    In /etc/fstab the device can be specified by serial number, but
    that can result in long lines.  It is easier to set up a label in
    /etc/devtab and then reference the label in /etc/fstab. 

    So in /etc/devtab you could say:

	fumach          serno   L41JYE0G

    And then in /etc/fstab you could say:

	# Device       Mountpoint      FStype  Options   Dump    Pass#
	fumach.s1d     /               hammer  rw        1       1
	fumach.s1b     none            swap    sw        0       0
	fumach.s1a     /boot           ufs     rw        1       1

    In /etc/rc.conf a dumpdev is typically set.  This can simply be pointed
    to the drive by serial number or by label.  Example:


    And that is it.  If you've done it correctly you can move the drive
    to almost any attachment, NATA, AHCI, SILI, firewire, whatever, and
    the system won't care.  USB is a bit more problematic as serial
    numbers cannot usually be probed via USB attachments, which is why
    we made USB start attaching at 'da8' (so it would be more deterministic)
    instead of 'da0', but other then that the actual device the drive
    attaches through (da0, da1, ad4, etc) becomes irrelevant.

    I have booted up test boxes on multiple occassions without realizing
    they had attached to NATA instead of AHCI because I hadn't set AHCI
    mode in the BIOS.  It's really quite nice when the attachment doesn't
    care where the drive sits in the system.

					Matthew Dillon 
					<dillon at>

More information about the Users mailing list