Mounting USB devices with stable names

Mikkel L. Ellertson mikkel at infinity-ltd.com
Fri Nov 10 22:51:49 UTC 2006


Mike McCarty wrote:
> Mikkel L. Ellertson wrote:
> 
>> As far as mounting goes, you may want to give the file system
>> labels, and let HAL auto-mount them. The drive then gets mounted on
> 
> Then again, I might not :-)
> 
> Labels do not particularly appeal to me.
> 
That is the nice thing about Linux - you have a choice on how you do
things. Labels for USB drives and SD cards work well for me. But I
did have to turn off auto-mounting for my CF/SM reader because it
can not tell if there is a SM card inserted or not so there was a
long delay when I plugged it in while reads to the SM card timed out.
>> /media/<label> when it is plugged in. If there is more then one
>> partition on the drive, then each gets mounted off of /media. If the
>> partitions are not labeled, then HAL has some other rules it uses to
>> construct the names. The auto-mounting will normally make FAT file
>> systems owned by the user who "owns" the console. You can also turn
>> off auto-mounting in the GUI.
> 
> That sounds good. I like configurable, especially for mounting.
> There are some real issues I have with my CDROMs auto starting
> the CDCREATER stuff. I'd just as soon that nothing got auto-
> mounte ever.
> 
I can understand that. I do not have anything done when inserting a
CD or DVD, but I do let USB drives get auto-mounted.

>> If you have special requirements for how the drive gets mounted,
>> then you can ether write HAL rules to cover it, or you can have udev
>> create a special device name or symlink based on the device. Vendor
>> ID and device ID are usually enough, but you can also use the serial
>> number.
> 
> That sounds good, also, though such may start to get complicated to
> do initial setup.
> 
It can. But if you plug in the device, and then look at the /sys
file system entry or the /proc/bus/usb/devices info for the device,
it gives you the information needed to match the device.

>> I can give better advice if I know exactly what you are after. I am
>> not an expert on this. But I have played around enough that I can
>> probably point you in the right direction.
> 
> 
> Thanks so much for the kind offer. At present, I probably need to
> read more about udev before making any sort of try at it. Umm,
> some questions which I might ask now...
> 
> [1] I suppose that there is a version for Fedora, no? (I use FC2.)
I know FC5 uses it. I have not run FC2. I know it works with the
2.6.11 kernels. I don't remember the first kernels I used it with.
There is documentation as part of the udev package on how to migrate
to using it.
> [2] I suppose that it "takes over" once installed, no?
Yes. It mounts a pseudo file system on top of /dev, so it ends up
managing all devices nodes that were not opened before udev was
started. The default rules should work the same as what you have.
The main difference is that if you create a device manually, it will
not survive a reboot.
> [3] Is there an easy means to revert to the more conventional
> system which is currently used on my machine?
All the origional /dev entries are still there. If you are not using
devfs, then just don't start udev at boot, and device management is
back to what it was. If you are using devfs, then you have to start
devfs instead of udev. I think most distributions ether have moved,
or are moving to udev.
> [4] I suppose that the actual mount points are configurable, no?
Udev does not control the mount points, but it will create /dev
entries or symlinks according to rules that you set. For example,
you could set your pen drive to always be /dev/pen and partitions
become /dev/pen#. (For example, /dev/pen1 for the first partition.)
You can then have /etc/fstab entries that use /dev/pen# inplave of
/dev/sda#. How you match the device is up to you. For example, if
you have several of the same PEN drives, can have them all use the
same device name, (If you will only use one at a time.) or you can
have a rule for each. There is a lot of flexibility when it comes to
matching. Just remember that the order of the rules is important.
The first match is processed. With later versions of udev, you can
control if later matches are also processed.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!




More information about the fedora-list mailing list