Managing consistent mounting of external USB hard drives in Linux (CentOS 5)

Solution 1:

I think what you want is mounting in fstab by UUID. I swiped this info (and example text) from here.

First, find out your device's UUID:

$ ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 348ea9e6-7879-4332-8d7a-915507574a80 -> ../../hda4
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 610aaaeb-a65e-4269-9714-b26a1388a106 -> ../../hda2
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 857c5e63-c9be-4080-b4c2-72d606435051 -> ../../hda5

The UUID of each device is the big string of hex numbers and dashes. Once you have that, just put "UUID=857c5e63-c9be-4080-b4c2-72d606435051" into your fstab in place of the device name. Now your USB drive will always be mounted in the same place, even if you plug it into a different USB hub or have other USB devices.

Solution 2:

Udev is going to be your friend. You are able to setup rules so that each particular drive is assigned to your specified name for it. Then your mounting scripts can handle putting each named drive into the right spot.

A good tutorial on how to do this: rename a USB drive.