[plug] Statically Mounting USB Drives

Jim Householder nofixed at westnet.com.au
Wed May 28 20:06:44 WST 2008


Daniel Pittman wrote:
> Jason Posavec <jasonposavec at iinet.net.au> writes:
> 
>> I can't seem to solve this problem, so I'm trying to find out if it
>> *can* actually be solved. 
> 
> Yes.
> 
>> I want to have USB drives as a permanent part of fstab. More
>> specifically, a USB thumb drive connected on one of the internal
>> motherboard connecters to run as my swap drive. Problem seems to be
>> that depending on what external USB drives may or may not be switched
>> on at boot time, Linux (and presumably any OS) seems to be a bit
>> random in the order it mounts USB drives.
> 
> It is, in large part because scanning the USB bus is an asynchronous
> process and, so, multiple devices will report differently on alternate
> boots.
> 
>> Anyone know of a way it can be done statically?
> 
> Yes.  Assuming you are running a relatively recent distribution you
> should have a number of persistent names for your device created by the
> udev process.
> 
> That creates symbolic links from /dev/disk/by-{id,label,path,uuid} to
> the device node assigned.  So, it doesn't matter if your USB disk is
> /dev/sda, /dev/sdz, or /dev/magic-unicorn, you can refer to one of those
> persistent names.
> 
> 
> Better still, your mount command almost certainly supports the same sort
> of persistence.  You should be able to specify, in fstab, a device of:
> 
>     UUID=aoeui....
>     LABEL=hello
> 
> That will (depending on the version of mount) either scan available
> devices to find the matching hardware, or simply use those udev created
> aliases.
> 
> 
> As an aside, this is a good policy for *all* your drives, not just the
> USB or other "dynamic" disks.  Your SATA and PATA disks can renumber if,
> say, you connect a USB disk at boot, or plug in an additional controller
> card, or even frob random BIOS options in many cases.
> 
> Using a persistent name rather than a hardware name makes your system
> independent of that renumbering, and makes you happier in the long run.
> 
> 
> Most distributions, these days, actually use this sort of persistent
> name mounting when you install, also.
> 

 From this discussion, I now see that there are advantages to using 
labels or names.  However they hide the physical location of the data. 
I don't like that, so I change to /dev/hd* and /dev/sd* after a new 
install.  I don't reorder my drives.

Jim



More information about the plug mailing list