[BL] USB devices
cce.zizkov at volny.cz
Tue Jan 2 18:02:25 EST 2007
I have been trying to make the mounting of USB storage devices
more user-friendly and seem to need some help with scripting.
When I want to mount a floppy the device name is always
the same, i.e. /dev/fd0 . So it is easy to write a script
or an alias in order to mount and unmount the device. e.g.
alias a:='mkdir /A ; mount /dev/fd0 /A'
alias :a='umount /A ; rmdir /A'
With USB storages devices it is a bit more complicated. When I
exchange them they show up at different addresses. When I tested
Sindi's and David's 2.4.31 kernels I realized that the first
deviced plugged in turns up at /dev/sda1 , the second one at
/dev/sdb1 , the third one at /dev/sdc1 and the fourth at /dev/sdd1 .
After that the next device can be mounted from /dev/sda1 again.
I would like to write a script that uses one or more mount points,
but will be able to mount a new device with only one command, eg.
u: (and :u for unmounting). The script, however, must be able to
check where a device is. When I open the 'file' /dev/sda1 in
Midnight commander I get an error message if the device does not
exist and some contents if it exists. How can I check the contents
of these device files automatically? I tried:
cat /dev/sda1 |head -n1|cut -b10 >/dev/null && echo sda1 exists
but this produced a lot of unwanted screen output (error messages
obviously do not come from 'cat') and did not produce the
wanted errorlevel for && in the script.
Which Linux command could I use instead of cat?
Ceskobratrska cirkev evangelicka - Betlemska kaple na Zizkove
Prokopova 4/216, 130 00 Praha 3, Czech Republic
Tel. (+420) 222 78 06 73 / 222 78 20 02 / 603 18 87 53
More information about the BasLinux