Tech Support > Operating Systems > Linux / Variants > USB Pen Drives and Linux
USB Pen Drives and Linux
Posted by paul on February 23rd, 2004


hey everyone,
I am having sort of a problem using multiple usb pen drives with
redhat linux (kernel 2.4.18-14).

The problem is that when I mount a pen drive, the device I mount is
/dev/sda1. everything works great and it's all good. if I unmount and
mount a different pen drive, I have to mount /dev/sdb1. a third pen
drive is /dev/sdc1, etc. etc yougettheidea.

the issue is that I am going to be using a great many pen drives on
this machine, and it really is much easier if my code can just mount
/dev/sda1 every single time, instead of incrementing the letter every
time. anyone know how to do this?

thanks in advance!

--paul

Posted by Christopher Browne on February 23rd, 2004


Clinging to sanity, paul <pcsanwaldNOSPAM@pobox.com> mumbled into her beard:
You need to define a volume label for the partitions, and mount based
on volume labels.

Thus, if you're using ext2 on the volume, then you might use
# mke2fs -L PEN1 /dev/sda3

Which allows you to put an entry into /etc/fstab like

LABEL=PEN1 /mnt/pen1 ext2

ext2, ext3, JFS, XFS and probably numerous other filesystems support
the "-L" option in this manner.
--
select 'cbbrowne' || '@' || 'acm.org';
http://cbbrowne.com/info/fs.html
Rules of the Evil Overlord #157. "Whenever plans are drawn up that
include a time-table, I'll post-date the completion 3 days after it's
actually scheduled to occur and not worry too much if they get
stolen." <http://www.eviloverlord.com/>

Posted by Dances With Crows on February 23rd, 2004


On 23 Feb 2004 18:52:39 GMT, Christopher Browne staggered into the Black
Sun and said:
FAT doesn't, though there is a space in the FAT superblock for a volume
label. Most USB storage devices are shipped with FAT filesystems
because that's the lowest common denominator; every machine can read and
write FAT. Tools for reading and writing ext[23], JFS, XFS, and
ReiserFS are limited/unavailable on non-Linux systems. If the OP is
only going to be using his USB devices on Linux systems, using ext2 and
-L with mount may work. If not, he'll have to find another solution.

I've written a patch for mount that allows it to use the -L option with
FAT. Looks like it works, but I've only tested it on my own machines.
Wonder if the util-linux maintainer would be interested....

--
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong
http://www.brainbench.com / Hire me!
-----------------------------/ http://crow202.dyndns.org/~mhgraham/resume

Posted by paul on February 23rd, 2004


On 23 Feb 2004 19:46:30 GMT, Dances With Crows
<danSPANceswitTRAPhcrows@usa.net> wrote:
I think I'm going to have to find another solution, unfortunately. The
pen drives I'll be using are pretty much random, and most of them (as
you pointed out) will come with a FAT filesystem.

all I'm really looking to do is mount a pen drive from /dev/sda1, then
umount it and be able to mount a different pen drive from the same
device label (/dev/sda1).

I take it there is no quick and dirty way to do this?

--paul

Posted by Jim Richardson on February 23rd, 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 23 Feb 2004 15:34:50 -0500,
paul <pcsanwaldNOSPAM@pobox.com> wrote:

I am not sure I follow the problem. I have 3 USB mem devices, a
cardreader, a digicam that shows up as a usb storage device, and a
pendrive. If I plug them in one at a time, they are all registered as
/dev/sda, if I plug more than one in at a time, the second one, is
/dev/sdb, I haven't plugged in all three at once (only have 2 usb ports
here

Are you saying that the device number (sda, sdb) increments for each
time one of them is plugged in? that's odd. I'd say that something is
wonky with your usb config, unless I am misunderstanding something.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAOnp1d90bcYOAWPYRAqLgAJ4uTs+0peb3shbVeKMEpA w30LUk+wCdEFMI
ffHmvVw7sKPS/jhZr5Z72Oc=
=S/hA
-----END PGP SIGNATURE-----

--
Jim Richardson http://www.eskimo.com/~warlock
" ... a language is just an dialect with an army and a navy."
-- Paul Tomblin, in a.s.r.

Posted by Christopher Browne on February 23rd, 2004


paul <pcsanwaldNOSPAM@pobox.com> wrote:
Well, the "LABEL=" option is intended to be the Right Way to do this.
--
If this was helpful, <http://svcs.affero.net/rm.php?r=cbbrowne> rate me
http://www.ntlug.org/~cbbrowne/languages.html
REALITY is a crutch for people who can't face ITS.

Posted by Christopher Browne on February 23rd, 2004


Clinging to sanity, Jim Richardson <warlock@eskimo.com> mumbled into her beard:
It wouldn't surprise me if the counter has a hard time decrementing.

Thus, plug one in, and get sda.

Plug another, and get sdb.

Take out the sda one and replace it, and you may get sdc, not sda.

And what is, of course, most attractive, is the notion of labelling
the devices so that you could plug them in however you like, and find
that they are mounted on the labelled directory, irrespective of the
device name...
--
let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;;
http://cbbrowne.com/info/lisp.html
Rules of the Evil Overlord #36. "I will not imprison members of the
same party in the same cell block, let alone the same cell. If they
are important prisoners, I will keep the only key to the cell door on
my person instead of handing out copies to every bottom-rung guard in
the prison." <http://www.eviloverlord.com/>

Posted by Dances With Crows on February 24th, 2004


On 23 Feb 2004 23:35:21 GMT, Christopher Browne staggered into the Black
Sun and said:
The OP said in message-ID spok309vb3idpi1d507p1jjm4o13fj92f8@4ax.com
that most of his pen drives are FAT. Current versions of mount have no
support for labels on FAT. This gives the OP a rather nasty choice:
Re-format the drives as ext2, making the pen drives practically unusable
on non-Linux machines, or deal with the drives being on different SCSI
device nodes.

There's another thing the OP might want to try: devlabel, at
http://linux.dell.com/devlabel/ . It might work. I can't really test
it, because my Archos 6000 has died and my iRiver390 isn't seen as a
USB mass storage device. HTH,

--
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong
http://www.brainbench.com / Hire me!
-----------------------------/ http://crow202.dyndns.org/~mhgraham/resume

Posted by paul on February 24th, 2004


On Mon, 23 Feb 2004 14:11:01 -0800, Jim Richardson
<warlock@eskimo.com> wrote:


yes, that's the problem exactly. one pen drive uses sda, a different
one on the same physical port uses sdb, and so on. I am beginning to
think something is weird with my usb config (ehci).

--paul

Posted by Stephen Cornell on February 24th, 2004


paul <pcsanwaldNOSPAM@pobox.com> writes:

There was a thread on this a while back - try

http://groups.google.com/groups?hl=e...k%26rnum %3D1

or search Google Groups for my email address and LEXR.

Among other things, there's a link to `devlabel' (which may be a good
solution) and a hacky script suitable for a small number of drives.

--
Stephen Cornell cornell@zoo.cam.ac.uk Tel/fax +44-1223-336644
University of Cambridge, Zoology Department, Downing Street, CAMBRIDGE CB2 3EJ

Posted by Jim Richardson on February 24th, 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 24 Feb 2004 10:14:56 -0500,
paul <pcsanwaldNOSPAM@pobox.com> wrote:
Well, I can't offer much help, except to note that it can work right

One thing you might try, is booting from a knoppix CD, and trying that.
See if you have the same problem. If not, take a look at the usb config
there, and see what is different.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAO52qd90bcYOAWPYRArU1AJ9wFKBAUREbikB3jPwMa3 xNYgW0nwCgtm/P
jQKc4yXP5nVICpb4XFoRGh8=
=TcDa
-----END PGP SIGNATURE-----

--
Jim Richardson http://www.eskimo.com/~warlock
There are entirely too many dumbasses in this world who don't know they
are dumbasses. We have a duty to enlighten them.

Posted by paul on February 24th, 2004


On 24 Feb 2004 01:52:54 GMT, Dances With Crows
<danSPANceswitTRAPhcrows@usa.net> wrote:
so it looks like devlabel will work, as soon as I figure out how I
managed to hose my hotplug manager while patching the file
/etc/hotplug/usb.agent

thanks for the help everyone.

--paul

Posted by paul on February 25th, 2004


On Tue, 24 Feb 2004 10:53:30 -0800, Jim Richardson
<warlock@eskimo.com> wrote:

hi jim, what kernel are you using? I just tried using multiple pen
drives on a 2.4.20-8 kernel, and had the same "problem", of the device
letter incrementing for each new attached device.

--paul


Posted by paul on February 25th, 2004


On 24 Feb 2004 15:32:22 +0000, Stephen Cornell <cornell@zoo.cam.ac.uk>
wrote:


thanks! devlabel looked like it was going to work, but I followed the
install instructions and now my hotplug util is completely hosed and I
can't mount anything .

--paul

Posted by Jim Richardson on February 26th, 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 25 Feb 2004 16:41:57 -0500,
paul <pcsanwaldNOSPAM@pobox.com> wrote:

2.4.24, and 2.6.1, both worked fine. But to be clear, if you have one of
the devices plugged in, then plug in another, it will increment. The op
was referring to removing, one, and inserting another, so that there's
only one in at one time, but still seeing the device ID increment.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAPWSsd90bcYOAWPYRAhx2AKCiYESg4y2MBcwOZQWgLw d7A4eYMQCfbugd
Js/t71PBuzCxMhYmHeh3exQ=
=OupC
-----END PGP SIGNATURE-----

--
Jim Richardson http://www.eskimo.com/~warlock
Silence is one of the most effective forms of communication.