3

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.

2

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.

  • This is a very exhausting explanation. Nevertheless, the problem I am facing is to identify the hard drive through its node name. For example: I see that /dev/sda just got damaged. It would be much easier if /dev/sda1 was mounted in /media/sda1, i could identify it immediately and make a backup, instead I have to find out which is the id or uuid of /dev/sda and then make the backup. All the softwares usually identify the hard disks through their node name from my experience. – giovi321 Sep 3 '15 at 12:04
  • To identify the filesystems of a specific block device, you can start with find -H /sys/block/sda -wholename "*/holders/*", and recurse into the resulting devices. For the leaves (for example dm-2), find -L /dev -xdev -samefile /dev/dm-2 gives you the list of names to look for in the mount list. – Ferenc Wágner Sep 4 '15 at 7:40
0

As root, type blkid |grep sda1: to get the UUID conveniently in one line, along with other useful stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.