I just added another external hard drive to my Linux system, and now I’m wondering about a few potential issues. At this point I have one permanently attached external hard drive, one backup hard drive that I only hook up occasionally, my iPod (which I mostly use on my Windows laptop because I don’t want to miss out on iTunes, but which I want to be able to occasionally hook up to my Linux box to transfer files, etc.), and a USB thumb drive.

Linux does a nice job of recognizing and mounting my drives whenever I attach them, but it seems to assign device names based on the order that the drives are connected. In my case for example, “dev/sda” and “dev/sdb” are used by two internal drives. “dev/sdc” is generally assigned to my permanently attached external drive. The next drive I attach after that (whether it is my backup drive, my iPod, or my USB thumb drive) gets assigned to “dev/sdd”.

This obviously is not ideal, as I want to be able to auto-mount all my drives based on appropriate entries in the fstab, i.e. “/media/ipod”, “/media/backup”, etc. My initial Google searches have been fruitless, but it really seems like there should be some way of permanently associating a particular drive with a device name. I’m not sure what kind of unique identifiers hard drives have, but there’s got to be something suitable. If nothing else, even basing this association on the drive model (as it is displayed in “/proc/scsi/scsi” on my Ubuntu system) would work for me, although this would generally be a less ideal solution since one might own several drives of the same model.

Anyway, if anybody is aware of any elegant solutions to this problem, please leave a comment.

Update: I was able to get this working. It turns out that there are actually several different ways to configure this:

  • In the fstab, specify LABEL=Label_Name instead of a device name. One downside of this approach is that volume labels aren't guaranteed to be unique, so you could get some unexpected results, particularly if you hook up somebody else's external drive.
  • Instead of a label, you can also specify a UUID. Simply call the "blkid" command to print the UUIDs for all your drives, and then add UUID=Your_UUID to your fstab. This is what I ended up doing and it works like a charm.
  • Use the "devlabel" script to set up symbolic links to devices that automatically get updated when the actual device changes. Then add an entry to fstab that uses the new symbolic device name.

You can find additional information here and here.

Thanks to Carl for pointing me in the right direction.