[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Automatically using a USB key



On Mon, 2005-01-17 at 13:18 +0100, Bob Alexander wrote:
> When I insert my USB key, I see the definition of a new /dev/sda1 device.
> 
> Questions:
> 
> 1) is hotplug responsible for detecting and configuring the whole thing ?

Yes.

> 2) How is udev involved ?

It isn't.

> 3) Can I always make that when the USB is inserted it is also 
> automatically mounted on a known path (e.g. /usbkey) ?

Yes.

Use an app like usbview (in the package of the same name) to
find out what the flash drive's serial number is.

Next, install udev.

Next, create the file /etc/udev/rules.d/10-local.rules that has 
this in it:
BUS="usb", KERNEL="sd?1", SYSFS{serial}="<whatever>", NAME="thumb"
where <whatever> is your key's serial number.
Note the wildcard in "sd?1"
This will make udev create a device named /dev/thumb.

Then, no matter what SCSI device that hotplug assigns to your
drive, udev will see that it's "your" drive, and assign it to
/dev/thumb.

Lastly, add this to /etc/fstab:
  /dev/thumb  /media/usbkey  vfat <blah blah> 0 2
Note the /media.  Apparently, that's the new convention.

Thus, next time you insert your thumb drive:
  mount -v /media/usbkey

> See below for syslog output
> 
> TIA,
> Bob
> 
> Jan 17 13:14:17 localhost kernel: usb 2-2: new full speed USB device 
> using uhci_hcd and address 2
> Jan 17 13:14:18 localhost kernel: SCSI subsystem initialized
[snip]
> Jan 17 13:14:24 localhost kernel: sda: assuming Write Enabled
> Jan 17 13:14:24 localhost kernel: sda: assuming drive cache: write through
> Jan 17 13:14:24 localhost kernel: SCSI device sda: 127840 512-byte hdwr 
> sectors (65 MB)
> Jan 17 13:14:24 localhost kernel: sda: assuming Write Enabled
> Jan 17 13:14:24 localhost kernel: sda: assuming drive cache: write through
> Jan 17 13:14:24 localhost kernel:  sda: sda1
> Jan 17 13:14:24 localhost kernel: Attached scsi removable disk sda at 
> scsi0, channel 0, id 0, lun 0
> Jan 17 13:14:24 localhost udev[9580]: configured rule in 
> '/etc/udev/rules.d/z_hal-plugdev.rules' at line 2 applied, 'sda' becomes 
> '%k'
> Jan 17 13:14:24 localhost udev[9580]: creating device node '/dev/sda'
> Jan 17 13:14:24 localhost udev[9598]: configured rule in 
> '/etc/udev/rules.d/z_hal-plugdev.rules' at line 2 applied, 'sda1' 
> becomes '%k'
> Jan 17 13:14:24 localhost udev[9598]: creating device node '/dev/sda1'
> 
> 

-- 
-----------------------------------------------------------------
Ron Johnson, Jr.
Jefferson, LA USA
PGP Key ID 8834C06B I prefer encrypted mail.

"People had to leave everything, from photos of their
grandparents to cars. Their clothes, cash and passports has been
changed by state authorities. This is incredible, people lived,
had homes, country houses, garages, motorcyles, cars, money,
friends and relatives, people had their life, each in own niche
and then in a matter of hours this world fall in pieces and
everything goes to dogs and after few hours trip with some army
vehicle one stands under some shower, washing away radiation and
then step in a new life, naked with no home, no friends, no
money, no past and with very doubtful future."
http://www.angelfire.com/extreme4/kiddofspeed/page14.html

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: