More beta-testing, and some "shiney" for mdev users... yes, we now have automount. I have no problem with manually mounting usb drives/keys/cameras/etc, but some people insist on automount. I've worked out how to implement automounting under mdev. I've got it working on a machine at home, but we should have more testing before posting this in the Gentoo mdev wiki.
There are a few preliminary setup steps required first. Everything except part 4) b) is done as root. 4) b) is done by each regular user that needs to unmount USB-plugable devices. 1) If you haven't already done so, install programs "pmount" and "sudo" emerge pmount sudo 2) Create directory /media (It *MUST* be "/media"). 3) Regular user accounts that need to access FAT-formatted USB keys need to be added to group "plugdev". 4) a) In /etc/sudoers.d create a file (if it doesn't exist). To the file add a line like... USERID HOSTNAME = (root) NOPASSWD: /bin/umount /media/* Replace "USERID" and "HOSTNAME" with the actual regular userid and the actual hostname. If you have 2 or more users that need to automount USB devices, add a separate line for each one. 4) b) Yanking out a USB key or external drive, after writing, without unmounting it first, "is not a good thing". Since the USB device is automounted by root, a regular user needs to use sudo to unmount it. That's why we installed sudo. E.g... sudo /bin/umount /media/sdb1 To make things easy for lazy typists, create a 2-line executable script "~/bin/um" in the regular user's home bin directory like so... #/bin/bash sudo /bin/umount /media/${1} It can be executed as "um sdb1" to unmount /media/sdb1 5) In case something goes drastically wrong, you should have a bootable CD or USB stick handy, to recover with. When running with mdev instead of udev under Gentoo, device setup is controlled by /etc/mdev.conf. There is a brief intro to the syntax at http://git.busybox.net/busybox/plain/docs/mdev.txt We will make one change to /etc/mdev.conf and add a script to /lib/mdev/ 1) Make a backup copy of /etc/mdev.conf cp /etc/mdev.conf /etc/mdev.conf.000 If stuff goes terribly wrong, you can boot from recovery media and revert to the previous version, i.e. cp /etc/mdev.conf.000 /etc/mdev.conf 2) Change a line in /etc/mdev.conf from sd[a-z].* root:disk 660 */lib/mdev/usbdisk_link to sd[a-z].* root:disk 660 */lib/mdev/usbdisk_automount 3) Take the file "usbdisk_automount" (listedbelow) and copy it to /lib/mdev/usbdisk_automount and remember to set it executable, e.g. chmod 744 /lib/mdev/usbdisk_automount Automounting should work now; rebooting is not required. Plug in USB keys/hard-drives/card-readers/direct-connection-to-cameras and play around with them. NOTES ===== 1) Sorry, pmount is hard-coded to mount in /media, e.g. /media/sdb1, and similar. If you want it mounting elsewhere, please submit patches to upstream. 2) If you connect a device (key or hard drive) formatted with a posix filesystem (ext2/3/4, reiserfs, btrfs, etc) file permissions will apply as usual. I.e. a regular user won't be able to modify/delete files owned by other users (including root). The various FAT variants do not support posix file permissions. pmount arbitrarily assigns user:root and group:plugdev to all files+directories on FAT-based filesystems. By using the "--umask 007" option in pmount, all files on FAT-based devices can be read+written by root and members of the plugdev group. 3) For the beta testing, I've enabled debug logging to a temporary log file /dev/shm/mdevlog.txt 4) Does anyone have a USB key or memory card that has the pathological setup where the entire stick is a FAT partition, without a partition table? If so, can you please let me know if automounting works with it? If not please... * unplug the device * delete the file /dev/shm/mdevlog.txt * plug the device in * wait a few seconds and unplug it * email me the contents of /dev/shm/mdevlog.txt 5) usbdisk_automount begins below #!/bin/bash # # At bootup, "mdev -s" is called. It does not pass any environmental # variables other than MDEV. If no ACTION variable is passed, exit # the script. if [ "X${ACTION}" == "X" ] ; then exit 0 ; fi # # Execute only if the device already exists; otherwise exit if [ ! -b ${MDEV} ] ; then exit 0 ; fi # # Also only execute for partitions, not the underlying disks. if [ "X${DEVTYPE}" != "Xpartition" ] ; then exit 0 ; fi # Debug data dump. exec 3>> /dev/shm/mdevlog.txt echo "=============== * ${SEQNUM}" >&3 /usr/bin/printenv >&3 exec 3>&- # # The "add" action. if [ "X${ACTION}" == "Xadd" ] ; then # # Create the directory in /media mkdir -p /media/${MDEV} # # Mount the directory in /media pmount --umask 007 --noatime /dev/${MDEV} # # The "remove" action. elif [ "X${ACTION}" == "Xremove" ] ; then # # Unmount the directory in /media umount /media/${MDEV} # # Delete the directory in /media rm -rf /media/${MDEV} fi -- Walter Dnes <waltd...@waltdnes.org>