[Tfug] mount and umount a usb stick

jblais joe.blais at pti-instruments.com
Thu Sep 13 17:16:16 MST 2007


Hello -

Running Fedora 5 --

I'm trying to programatically mount and unmount a USB stick - probably using
2 scripts like

MountScript
  mount -t vfat -o rw,....  /dev/sdc1  /home/me/project/USBStick

UnMountScript
  umount /dev/sdc1


Seems simple enough --however..

Currently I have some automount thing is running.  After booting the system,
and before I initially put the stick into the socket, the mount command does
not show the thing -- but it does show some automount stuff -- which I'll
probably remove at some time --  Unless someone says I shouldn't (don't need
CD, only have one HD on the machine and some USB ports for the sticks and
mouse and kbd)

Anyway.  After the first time I put in the stick, the mount command comes
back with the following as the last item...
  /dev/sdc1  /media/disk  ......

from this info, I manually did
  umount  /dev/sdc1
and magically everything went away.

I then did
  mount  -t vfat -o rw,....   /dev/sdc1  /home/me/project/USBStick
and it worked - I could see everything on the stick as expected, at the new
desired location.

Then I umounted it and everything was gone.

I then removed the stick, waited a few moments and inserted the thing again.
Automount did it's thing, but this time it was different.
Running mount, didn't show anything about the mounted device.  It was
mounted in the same place /media/disk  and I could go there and see stuff,
but when I tried
  umount  /dev/sdc1
I got an error about it wasn't valid, so I tried a whole slew of /dev/sdxx
stuff ..
Then
  umount  /media/disk
worked as expected

SO I thought /dev/sdc1 was invalid -- but
  mount -f vfat -o .... /dev/sdc1  /home/me/project/USBStick
worked !

Everything kind of worked, but it seems iffy, without a warm fuzzy feeling
that my scripts will work repeatedly.

Do USB sticks just show up wherever they want to?
Is there enough 'magic' that the mount command will work no matter which USB
port the stick is in (couldn't find anything in fstab) ?
Is automount doing this, or will all the luck just go as soon as automount
goes?

Thanks

Joe











More information about the tfug mailing list