Gnuru.org
Productive Linux


Subscribe

 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Login
Login:
Password:



Don't have an account?
Sign up to Gnuru.org
Forgot your password?

USB Pen Drives - the UDEV Automounting Secrets
24 March 2011 @ 14:30 GMT
by Paul

You run Debian Sid. You're on the cutting edge. It's where you like to be.

Recently, you found that USB pen drives and hard disks weren't being mounted, or if they were, no user other than root was able to write to them.

You wonder why. HAL, that mainstay of Linux over the last few years, is gone. ivman still appears in the package list, but is not used. The trusty gnome-volume-manager too has disappeared.

You know it's all udev. It's shiny. It's new. It controls the /dev directory and almost all hardware events.

If it's udev that is making your usb disks mount read-only. why?

You turn on 'debug' level logging:

sudo udevadm control --log-priority=debug

More information is now reported to /var/log/syslog. You see lines containing /lib/udev/rules.d/60-persistent-storage.rules and /lib/udev/rules.d/usbmount.rules. You conclude that the udev rules are in /lib/udev

You examine, in particular /lib/udev/rules.d/usbmount.rules which calls the usbmount script to handle the mounting of usb devices. You become concerned that the usbmount package is no longer maintained. But you check the source code. You are relieved to find out that usbmount is a simple script that even you could maintain. You continue to use it.

You read the usbmount documentation, and the configuration options. You realise that the problem is VFAT, an extremely limited and quite rubbish format, that doesn't deal with permissions properly and that, therefore, no one in their right mind should use. Unfortunately, pen drives always use VFAT. You remember the proper way to mount VFAT disks.

You make the following changes to /etc/usbmount/usbmount.conf.

You replace the line:

MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime"

With this one:

MOUNTOPTIONS="noexec,nodev,noatime,nodiratime"

And you add this line:

FS_MOUNTOPTIONS="-fstype=vfat,gid=plugdev,dmask=0007,fmask=0117"

Users in the plugdev group can now write to pen drives and other usb VFAT formatted hard drives. You make sure you are in the plugdev group.




Comments disabled