From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SZ8J9-00026Q-Ow for garchives@archives.gentoo.org; Mon, 28 May 2012 22:21:00 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1305DE0777; Mon, 28 May 2012 22:20:45 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E7C18E0667 for ; Mon, 28 May 2012 22:19:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 79E3B1B400E for ; Mon, 28 May 2012 22:19:14 +0000 (UTC) X-Virus-Scanned: by amavisd-new using ClamAV at gentoo.org X-Spam-Flag: NO X-Spam-Score: -2.536 X-Spam-Level: X-Spam-Status: No, score=-2.536 tagged_above=-999 required=5.5 tests=[AWL=0.065, BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=no Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yU0w8EcJHC2q for ; Mon, 28 May 2012 22:19:08 +0000 (UTC) Received: from ironport2-out.teksavvy.com (ironport2-out.teksavvy.com [206.248.154.182]) by smtp.gentoo.org (Postfix) with ESMTP id 719341B4017 for ; Mon, 28 May 2012 22:19:07 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgoKAG6Zu0/O+IMW/2dsb2JhbABCArJ2A4EYgQiCVhxsBiYlJBOIDguYR6E3iwpYgUALgjViA40+h1yFX4g6gViDBYE6CRE X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="183291185" Received: from 206-248-131-22.dsl.teksavvy.com (HELO waltdnes.org) ([206.248.131.22]) by ironport2-out.teksavvy.com with SMTP; 28 May 2012 18:19:05 -0400 Received: by waltdnes.org (sSMTP sendmail emulation); Mon, 28 May 2012 18:18:02 -0400 From: "Walter Dnes" Date: Mon, 28 May 2012 18:18:02 -0400 To: Gentoo Users List Subject: [gentoo-user] Automount under mdev; looking for testers Message-ID: <20120528221802.GA4369@waltdnes.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Archives-Salt: 64f53d94-075f-4fc9-9540-fe742e9efdad X-Archives-Hash: 0428da4045883b93862cc34529cbbb71 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