How to assign a specific /dev device to a specific external device?

zer0halo zerohalo at gmail.com
Sat Jul 2 18:18:21 UTC 2005


Is it possible to specify which /dev device (ie, /dev/sda1) will be
assigned to a particular USB device (ie, a thumbdrive or external HDD)
when the device is automounted?

For example, when I plug in my thumbdrive, sometimes it's assigned to
/dev/sda1, but other times it might be assigned /dev/sda2 or
/dev/sdb1. So it's not possible to put an entry in my /etc/fstab that
always mount a particular device to the same mount point because I
don't know what /dev that device might get assigned when it gets
plugged in.

For example, I have a problem in that my external HDD and my
thumbdrive both usually get assigned /dev/sda1 when I plug them in. I
want them both to always mount to their respective locations, but I
can't figure out how because I can't put two entries for /dev/sda1 in
my /etc/fstab, ie:

/dev/sda1       /media/thumbdrive
/dev/sda1      /media/externalHD

obviously that won't  work. 

What I would like is for Ubuntu to always assign /dev/sda2 (or
/dev/sdb1) to my externalHD so that my /etc/fstab could read:

/dev/sda1       /media/thumbdrive
/dev/sda2      /media/externalHD

Now of course I could not put any entries into my /etc/fstab for these
devices, and when I do that, they are automatically mounted to
/media/usbdisk, /media/usbdisk-1, etc.That's nice and convenient,
except that the first device plugged in gets /media/usbdisk, the
second one /media/usbdisk-1, etc. Which means that I can't always be
sure that my externalHD will mount at the same place, because it
depends on whether I had plugged in my thumbdrive before then. (Ie, if
the thumbrive is plugged in first, it gets /media/usbdisk, whereas if
the externalHD is plugged in first, it gets /media/usbdisk.) This
becomes important if you have scripts that automatically reference a
certain external device (like a backup script)--it always needs to
mount in the same place.

I hope I explained the issue properly. Thanks for any tips.

-- 
"Impossible is nothing."




More information about the ubuntu-users mailing list