Adverts

While it might seem like a really simple thing to do Linux makes it suprisingly hard to work with things like USB keyring drives. The problem is not that you can't mount them but that regular users can't mount them and every time a drive is plugged in it takes on a different device node. You can search for the device node that it has taken but it is a pain and removes a lot of the transparency.

The solution to this problem is udev which makes it possible for devices to be mounts and unmounted automatically at a pre-determined postion in the file system. This location is typically /media/device-type.

How to Set-Up udev

Install the Right Kernel

The first thing that you need is a 2.6.12 or later kernel as anything earlier won't have the necessary features for udev to work. At the time of writting this is the latest kernel in Debian. Note: the naming scheme for the kernel images has changed. Kernel images 2.6.12 and beyond will now be called linux-image-2.x.y rather than kernel-image-2.x.y. This is to make way for new kernel types in the repository such as Hurd.

Install udev

Once you have the 2.6.12+ kernel installed install udev

apt-get install udev

since udev is playing with some fairly fundamental stuff in the system it is highly recommended that you reboot. I believe you can get away without a reboot on most machines but is it worth the risk?

Once udev is installed make sure that it is running with

ps aux | grep udevd

Plugging in a Device

At a console run

tail -f /var/log/messages

This will show you system messages and give you information about the device. Now plug the device in. You should see information similar to that shown below. This information is for a USB keyring drive. I've broken a couple of the longer lines to make it fit the page better.

Aug 17 13:23:21 localhost kernel: usb 1-8.1: new full speed USB \
	device using ohci_hcd and address 9
Aug 17 13:23:21 localhost kernel: scsi9 : SCSI emulation for USB Mass Storage devices
Aug 17 13:23:22 localhost usb.agent[8356]:      usb-storage: already loaded
Aug 17 13:23:26 localhost kernel:   Vendor: Generic   Model: USB Flash Drive   Rev: %%z!Y
Aug 17 13:23:26 localhost kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Aug 17 13:23:26 localhost kernel: SCSI device sda: 128640 512-byte hdwr sectors (66 MB)
Aug 17 13:23:26 localhost kernel: sda: Write Protect is off
Aug 17 13:23:26 localhost kernel: SCSI device sda: 128640 512-byte hdwr sectors (66 MB)
Aug 17 13:23:26 localhost kernel: sda: Write Protect is off
Aug 17 13:23:26 localhost kernel:  /dev/scsi/host9/bus0/target0/lun0: p1
Aug 17 13:23:26 localhost kernel: Attached scsi removable disk sda at scsi9, channel 0, id 0, lun 0
Aug 17 13:23:26 localhost scsi.agent[8401]:      sd_mod: loaded successfully (for disk)
Aug 17 13:23:27 localhost usbmount[8461]: executing command: mount -tvfat \
	-osync,noexec,nodev,noatime /dev/sda1 /media/usb0
Aug 17 13:23:28 localhost usbmount[8461]: executing command: run-parts /etc/usbmount/mount.d

The line "Attached scsi removable disk sda at scsi9" shows us that the device has been recognized and placed at /sda the partition on it /dev/sda1 has been mounted at /media/usb0 (which is symlinked to /media/usb) as shown by the second to last line.

It is not necessary to watch the messages if the device is already known to udev. If udev doesn't recognise the device though you can use the message information to create a rule for udev that will allow it to automatically mount the revice in the future.

Automounting

Resources

Adverts

Donate and Help

Please support this site and
Bandwidth doesn't grow on trees y' know :o)

Adverts

Get Adsense