Random Post: Bacula for Mac OS X
RSS .92| RSS 2.0| ATOM 0.3
  • Home
  •  

    Permanent Device Nodes with udev

    I recently converted from Arkeia (a horribly overpriced and buggy piece of software) to Bacula (a free, stable, higher performance alternative). At the same time I upgraded my backup server to Debian Etch and started having a problem where my tape library would alternatively show up as either /dev/sg0 or /dev/sg2 depending on what order things were powered up. Obviously that presents a problem if certain pieces of software expect your auto changer to located at a certain device node in /dev.

    This can be fixed by making a custom udev rule…

    So, I knuckled down and figured out how to get udev to set up a symlink on each reboot that points to my auto changer regardless of what SCSI generic device it is assigned on boot up. As with most things in life, it seems quite simple in retrospect ;-)

    Use udevinfo to get all the properties of the device in question:

    root@silicon: ~ # udevinfo -a -p /sys/class/scsi_generic/sg0

    This will return all the properties you could ever want to know about that device, conveniently provided in udev rule format.

    You can now form a udev rule using the attributes of the device and the attributes from one single parent device. In my case, it looked like this:

    SUBSYSTEM=="scsi_generic", ATTRS{model}=="MagFile         ", ATTRS{vendor}=="M4 DATA ", SYMLINK+="changer"

    The important thing to note here is the SYMLINK+=”changer” part. This is what symlinks the device that matches this rule with /dev/changer on each bootup.

    Now just put that rule into the approriate init file with a sensible name. I placed mine in /etc/udev/rules.d/z25_persistent-scsi.rules

    Thats it! After every reboot you’ll have a /dev/changer device that always points to the same physical piece of hardware, no matter what /dev entry it is given during boot up.

    Leave a Reply