Re: What determines which /dev/sd* a USB device becomes?
On Monday 02 August 2004 10:16, Adam Funk wrote:
> I unplugged my USB SmartMedia card reader and plugged in a different
> brand of the same thing. It now shows up as /dev/sdb (and /dev/sdb1)
> but /dev/sda is still present (although useless). This is a minor
> nuisance as I had to change /etc/fstab so I could mount it as a normal
> user. What causes this and is there any way to control it?
The way to solve this is to use udev. It creates the devices dynamically as
the devices are plugged in.
The default rules will still create the /dev/sd? and /dev/sd?1 files - but you
can easily write special rules to detect the device which is being plugged in
and also create something like /dev/smartmedia which is what you put
in /etc/fstab
There is a good write up on how to do this at
http://www.reactivated.net/udevrules.php
Here is part of a file I have made (I haven't properly dealt with partions on
the "camera" devices yet - see c) below)).
I am doing several things here
a) defining my two ide cd roms as /dev/cdrw and /dev/dvd correctly
b) detecting when I connect in my jumpdrive so I can mount it on /dev/flash
(I then have a "floppy disk" device icon on my kde desktop to mount/unmount
it when I want to use it).
c) detecting a camera smartmedia card plugged into a reader, or one of two
seperate digital cameras plugged in (this works and creates the /dev/camera
files - but I think I propably have to change this in the same what as b) -
ie detect sd?1 and sd? on two lines and only assign devices on the first)
kanger:/home/alan# more /etc/udev/rules.d/01-akcspecial.rules
# Created 26 Jul 2004 AKC First creation (needs other to be
filled in)
# Define specific devices for CDs
BUS="ide", KERNEL="hdc", NAME="cdrw", SYMLINK="cdroms/cdrom0"
BUS="ide", KERNEL="hdd", NAME="dvd", SYMLINK="cdroms/cdrom1"
# Portable Flash Storage
BUS="usb", SYSFS{manufacturer}="LEXAR MEDIA", SYSFS{product}="JUMPDRIVE
ELITE", KERNEL="sd?1" NAME="flash"
# Hopeing this will stop the create of and sd nodes for this device
BUS="usb", SYSFS{manufacturer}="LEXAR MEDIA", SYSFS{product}="JUMPDRIVE
ELITE", KERNEL="sd*" NAME=""
# Smartmedia reader should look like a camera, but will be placed first so
that a real
# camera can override it
BUS="usb", SYSFS{model}="SmartMedia", NAME="camera", SYMLINK="smartmedia"
# Digital Camera (either the C745UZ or the C220Z)
BUS="usb", SYSFS{idVendor}="07b4", SYSFS{idProduct}="0102", NAME="camera",
SYMLINK="olympus_c220z"
BUS="usb", SYSFS{idVendor}="07b4", SYSFS{idProduct}="0105", NAME="camera",
SYMLINK="olympus_c745uz"
--
Alan Chandler
alan@chandlerfamily.org.uk
First they ignore you, then they laugh at you,
then they fight you, then you win. --Gandhi
Reply to: