Mount various USB devices


USB external hard disk

A USB hard disk uses the USB EHCI (or OHCI) driver and the SCSI subsystem. You first have to compile the right kernel modules so that you get some lines like below in your /var/log/syslog file:

kernel: usb 1-3: new high speed USB device using ehci_hcd and address 10
kernel: usb 1-3: New USB device found, idVendor=067b, idProduct=2506
kernel: usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
kernel: usb 1-3: Product: Mass Storage Device
kernel: usb 1-3: Manufacturer: Prolific Technology Inc.
kernel: usb 1-3: SerialNumber: 000000000000
kernel: usb 1-3: configuration #1 chosen from 1 choice
kernel: usbcore: registered new interface driver libusual
kernel: Initializing USB Mass Storage driver...
kernel: scsi0 : SCSI emulation for USB Mass Storage devices
kernel: usbcore: registered new interface driver usb-storage
kernel: USB Mass Storage support registered.
kernel: usb-storage: device found at 10
kernel: usb-storage: waiting for device to settle before scanning
kernel: scsi 0:0:0:0: Direct-Access     Hitachi  HTS541616J9AT00  SB4O PQ: 0 ANSI: 0
kernel: usb-storage: device scan complete
kernel: sd 0:0:0:0: [sda] 312581808 512-byte logical blocks: (160 GB/149 GiB)
kernel: sd 0:0:0:0: [sda] Write Protect is off
kernel: sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
kernel: sd 0:0:0:0: [sda] Assuming drive cache: write through
kernel: sd 0:0:0:0: [sda] Assuming drive cache: write through
kernel:  sda: sda1
kernel: sd 0:0:0:0: [sda] Assuming drive cache: write through
kernel: sd 0:0:0:0: [sda] Attached SCSI disk

Usually, you should now just have to mount your /dev/sda device so as to access your hard disk. But if you have more than just one external drive, its path (/dev/sdX) may change. Now comes udev to help you.

If your hard disk is /dev/sda, you have to type the command udevadm info -a -p $(udevadm info -q path -n /dev/sda) as root user. The output prints out the configuration of many peripherals. You may get some like below:

  • the block memory device
  • the SCSI device (the hard disk)
  • the SCSI target (internal configuration of SCSI subsystem)
  • the host configuration (telling something is plugged somewhere)
  • the usb-storage driver
  • the USB hub or plug
  • the *HCI controller
  • the USB peripheral
  • the PCI system on which the USB chip is plugged

The important section is the SCSI device one. And in this section, please read the ATTRS{model} value.

Now you can configure udev to recognise your specific hard disk. In your /etc/udev/rules.d/local.rules, add the following line:

KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRS{model}=="HTS541616J9AT00 ", SYMLINK+="mobiledisk"

Now your hard disk is recognised as /dev/sda but also as /dev/mobiledisk. You can end your configuration by creating the directory (the mountpoint) /mnt/mobiledisk and by editing your /etc/fstab file and add a line like:

/dev/mobiledisk /mnt/mobiledisk auto    user,noauto,nodev,nosuid 0 0

Now, when you plug your external hard disk, whatever other USB or SCSI memory devices you have, you can access your disk by mounting /mnt/mobiledisk.

USB key

A USB key is exactly the same thing as an external USB hard disk. So the above section can be used. A configuration example could be:

/etc/udev/rules.d/local.rules:
KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRS{model}=="RunDisk         ", SYMLINK+="rundisk-key"

/etc/fstab:
/dev/rundisk-key /mnt/rundisk-key auto  user,noauto,nodev,nosuid 0 0

USB CD/DVD burner

This device is slightly the same device as a memory one like described above, but the kernel driver is different. So you will have to apply nearly the same procedure as written above, but with just one modification in the udev configuration file, the KERNEL parameter:

KERNEL=="sr*", SUBSYSTEMS=="scsi", ATTRS{model}=="CDDVDW SE-S224Q ", SYMLINK+="toaster"

PCMCIA modem

I have a PCMCIA 3G modem card: the option one.

This device has two subdevices: a modem and a GSM. These devices are not /dev/sdX devices but /dev/ttyXXX one. But the configuration is the same as described above, and the two devices can be easily accessed with this udev configuration:

/etc/udev/rules.d/local.rules:
DRIVERS=="option", ATTRS{bInterfaceNumber}=="00", SYMLINK+="ttyModem", SYMLINK+="modem"
DRIVERS=="option", ATTRS{bInterfaceNumber}=="02", SYMLINK+="ttyGSM"

USB Serial Converter

This peripheral is the same as described in the above section PCMCIA modem. Just add the following line into your /etc/udev/rules.d/local.rules file:

DRIVERS=="ftdi_sio", ATTRS{interface}=="   USB Serial Converter", SYMLINK+="ttyUSBSerial"

Canon Powershot SX 210 IS

This digital camera does not emulate a USB key system, but uses the PTP (Picture Transfer Protocol) protocol. So to mount it as a memory device you will have to use the kernel pseudo-memory driver called fuse and a software called gphotofs.

First you have to get the gphotofs software. Get and compile the sources, or look into your OS software repository (APT, URPMI…) if it is present. Please make sure that the module fuse is compiled into your kernel (try to modprobe it for example).

Now the configuration is easy. You have to load the kernel module (by hand: modprobe fuse or automatically by adding a line « fuse » in the /etc/modules file). You have to create a directory (mountpoint) and add the following line into your /etc/fstab file:

gphotofs    /mnt/canonSX210is fuse  user,noauto,allow_other 0 0

Now you end up by adding the line « user_allow_other » in the /etc/fuse.conf file and everything will work fine.


Laissez un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *