4

I'm trying to set a custom udev to set the /dev/sd** mount point for all 6 HDDs on my system.

I've been trying to get it to work, but it just wont. I need to get this sorted because my drives seem to randomly change messing with my links and libraries. 5 of my drives are truecrypt encrypted and as such i can`t use UUID to mount to specific points.

This is what i`ve been trying to use. Im running Ubuntu 13.04 ans have saved the file in /lib/udev/rules.d/65-persistent-hdd.rules

# These are the rules to force all drives into specific /dev/sd** slots for truecrypt mounting
#
KERNEL=="sd*", SUBSYSTEMS==" block", ATTRS{serial}=="3PK0R7AD", SYMLINK+="sda%n"
KERNEL=="sd*", SUBSYSTEMS==" block", ATTRS{serial}=="S1UVJ1LZ401091", SYMLINK+="sdb%n"
KERNEL=="sd*", SUBSYSTEMS==" block", ATTRS{serial}=="S1VSJ1KS202775", SYMLINK+="sdc%n"
KERNEL=="sd*", SUBSYSTEMS==" block", ATTRS{serial}=="W1F08BLH", SYMLINK+="sdd%n"
KERNEL=="sd*", SUBSYSTEMS==" block", ATTRS{serial}=="S1Y6J90SA14564", SYMLINK+="sde%n"
KERNEL=="sd*", SUBSYSTEMS==" block", ATTRS{serial}=="S13PJDWS223047", SYMLINK+="sdf%n"

So as you see, im trying to force {serial}=="3PK0R7AD" to /dev/sda, {serial}=="S1UVJ1LZ401091"to /dev/sdb, etc, etc

1
  • Did you eventually solve this ? (get back to me with @Cbhihe)
    – Cbhihe
    Oct 10, 2015 at 14:08

1 Answer 1

3

I'm not 100% certain but I think the problem is SYMLINK+= will use the default /dev/NAME and only add an additional symbolic link. So you probably can't create symbolic links to devices that already exist?

Instead use NAME="sda"

From http://www.reactivated.net/writing_udev_rules.html

After you have used a series of match keys to precisely match a device, udev gives you fine control over what happens next, through a range of assignment keys. For a complete list of possible assignment keys, see the udev man page. The most basic assignment keys are introduced below. Others will be introduced later in this document. NAME - the name that shall be used for the device node SYMLINK - a list of symbolic links which act as alternative names for the device node

As hinted above, udev only creates one true device node for one device. If you wish to provide alternate names for this device node, you use the symbolic link functionality. With the SYMLINK assignment, you are actually maintaining a list of symbolic links, all of which will be pointed at the real device node. To manipulate these links, we introduce a new operator for appending to lists: +=. You can append multiple symlinks to the list from any one rule by separating each one with a space.

KERNEL=="hdb", NAME="my_spare_disk"

The above rule says: match a device which was named by the kernel as hdb, and instead of calling it hdb, name the device node as my_spare_disk. The device node appears at /dev/my_spare_disk.

KERNEL=="hdb", DRIVER=="ide-disk", SYMLINK+="sparedisk" The above rule says: match a device which was named by the kernel as hdb AND where the driver is ide-disk. Name the device node with the default name and create a symbolic link to it named sparedisk. Note that we did not specify a device node name, so udev uses the default. In order to preserve the standard /dev layout, your own rules will typically leave the NAME alone but create some SYMLINKs and/or perform other assignments.*

It's not working for me, but I'm not sure where my problem is in my udev rules as debugging doesn't show them even being processed. Hopefully this helps you

I'm trying to do the same thing and force my devices to be specific /dev/sdX and I know people wonder why do it but some people want that level of control over their devices.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .