Debian – Mount hard drives in the same order in debian

debianhard-diskmount

How can I mount the hard drives always on the same /dev/sd? node? For example, how can I make the hard drive with the UUID xyz to be mounted always on the node dev/sda?

The reason why I want to do this is that sometimes I change hard drives, and the only easy way to identify them is the node name, if one of them has a problem, I can easily find it among the 12 hard drives in the system (so far I have been using the serial number). If I change an hard disk, I simply assign the node to the new uuid or create a new node.

I am running Debian 8.

Best Answer

I think that you are talking about assigning stable, persistent names to the hard drive device nodes, not about mounting them:

make the hard drive with the UUID xyz to be mounted always on the node dev/sda?

You cannot control which hard disk /dev/sda corresponds to at mount time. Once you are at the point of mounting a hard drive (or partition), the device node (in /dev) must have already been assigned.

You can control the names of the device nodes assigned to hard drives at the point when they are detected and added, using udev. In fact, the default rules of udev in Debian and most other Linux distributions already does this for you! Those default rules assign names like this:

  • The kernel-assigned name which is typically sd<something> (and which you cannot control) is made available directly in /dev. It is recommended that you leave such names as is to avoid confusion since the kernel-assigned name will appear in, e.g., kernel logs no matter what. But you don't have to use this /dev/sd<something name for mounting.
  • Symlinks to the "main" name are created in /dev/disk/by-id based on the vendor, model, and serial number of the hard drive. The same hard drive with the same vendor, model, and serial number will thus always have the same predictable name in /dev/disk/by-id. Furthermore, this information is obtained quickly from the hard drive as soon as it is connected and does not require spinning up the drive to read anything off it.
  • Symlinks to the "main" name are created in /dev/disk/by-uuid based on the UUID of the hard drive. Like those in /dev/disk/by-id, they are meant as predictable, persistent names for the device, but unlike /dev/disk/by-id these UUIDs are not really an intrinsic property of the hard drive itself, they are just pieces of metadata that some from such places as file system superblocks.

In summary, your requirement to address disks/partitions based on UUID can be met by ignoring the kernel-assigned /dev/sd<something> names and using a name from /dev/disk/by-uuid instead. Instead of UUIDs, you can also use a name like /dev/disk/by-id/ata-<vendor>-<model>-<serial>-part2 to access the second partition on a hard disk with the given vendor, model, and serial number.

Related Question