USB drives and device names
John Abreau
jabr at blu.org
Fri Jan 25 16:58:25 EST 2008
On Fri, January 25, 2008 4:30 pm, Dan Coutu said:
> On Linux a USB connected hard drive appears as a SCSI device. But the
> naming of the device seems to 'float' based on who-knows-what criteria.
>
> So for example yesterday I saw an USB drive device change from being
> /dev/std to /dev/stc. Talk about unique! I've seen the letter increment
> before when you disconnect a drive and reconnect it (the USB connection
> is what I'm referring to here) but never have I seen it decrement.
>
> Is there any kind of algorithm that could be used, perhaps within a
> shell script, in order to reliably mount a USB drive without fail and
> without having to guess at the device name?
>
You can always mount the drive based on its label. For instance,
if the partition is labeled "FamilyPhotos", you can mount it via
sudo mkdir /mnt/temp
sudo mount -L FamilyPhotos /mnt/temp
Gnome already does something similar; when it automounts a usb drive,
a cdrom, etc., it creates a mount point for it under /media, based
on its label, and then mounts it there. It also adds an entry for it
to /etc/fstab, with the attribute "managed".
If the filesystem on the usb drive is ext3, you can label it with
the command "e2label"; if it's a dos vfat filesystem, you can label
it with the "mlabel" command from the mtools package.
--
John Abreau / Executive Director, Boston Linux & Unix
IM: jabr at jabber.blu.org / abreauj at AIM / abreauj at Yahoo / zusa_it_mgr at Skype
Email jabr at blu.org / WWW http://www.abreau.net / PGP-Key-ID 0xD5C7B5D9
PGP-Key-Fingerprint 72 FB 39 4F 3C 3B D6 5B E0 C8 5A 6E F1 2C BE 99
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the gnhlug-discuss
mailing list