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 1SZBxs-0006lf-Fq for garchives@archives.gentoo.org; Tue, 29 May 2012 02:15:16 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 665CEE0774; Tue, 29 May 2012 02:14:55 +0000 (UTC) Received: from svr-us4.tirtonadi.com (svr-us4.tirtonadi.com [69.65.43.212]) by pigeon.gentoo.org (Postfix) with ESMTP id 7D386E072D for ; Tue, 29 May 2012 02:13:28 +0000 (UTC) Received: from mail-vc0-f181.google.com ([209.85.220.181]) by svr-us4.tirtonadi.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.69) (envelope-from ) id 1SZBw8-003kt4-9o for gentoo-user@lists.gentoo.org; Tue, 29 May 2012 09:13:28 +0700 Received: by vcbf1 with SMTP id f1so2111700vcb.40 for ; Mon, 28 May 2012 19:13:25 -0700 (PDT) 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 Received: by 10.220.242.6 with SMTP id lg6mr11101806vcb.18.1338257605002; Mon, 28 May 2012 19:13:25 -0700 (PDT) Received: by 10.220.81.202 with HTTP; Mon, 28 May 2012 19:13:24 -0700 (PDT) Received: by 10.220.81.202 with HTTP; Mon, 28 May 2012 19:13:24 -0700 (PDT) In-Reply-To: <20120528221802.GA4369@waltdnes.org> References: <20120528221802.GA4369@waltdnes.org> Date: Tue, 29 May 2012 09:13:24 +0700 Message-ID: Subject: Re: [gentoo-user] Automount under mdev; looking for testers From: Pandu Poluan To: gentoo-user@lists.gentoo.org Content-Type: multipart/alternative; boundary=14dae9ccd4882a060704c1236113 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - svr-us4.tirtonadi.com X-AntiAbuse: Original Domain - lists.gentoo.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - poluan.info X-Archives-Salt: a0d7c1b1-8c3e-4388-ae5e-04bc8ae630c7 X-Archives-Hash: dc0af9dc5b40e5214cf8a3222faf1e91 --14dae9ccd4882a060704c1236113 Content-Type: text/plain; charset=UTF-8 On May 29, 2012 5:23 AM, "Walter Dnes" wrote: > > 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 > > A quick question : for automounting to work, do you need to do sysctl -w kernel.hotplug=/sbin/mdev , or is it optional? Rgds, --14dae9ccd4882a060704c1236113 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On May 29, 2012 5:23 AM, "Walter Dnes" <waltdnes@waltdnes.org> wrote:
>
> =C2=A0More beta-testing, and some "shiney" for mdev users...= yes, we now
> have automount. =C2=A0I have no problem with manually mounting usb
> drives/keys/cameras/etc, but some people insist on automount. =C2=A0I&= #39;ve
> worked out how to implement automounting under mdev. =C2=A0I've go= t it
> working on a machine at home, but we should have more testing before > posting this in the Gentoo mdev wiki.
>
> =C2=A0There are a few preliminary setup steps required first. =C2=A0Ev= erything
> except part 4) b) is done as root. =C2=A04) 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&q= uot; 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 ne= ed
> to be added to group "plugdev".
>
>
> 4) a) In /etc/sudoers.d create a file (if it doesn't exist). =C2= =A0To the file
> add a line like...
>
> USERID =C2=A0HOSTNAME =3D (root) NOPASSWD: /bin/umount /media/*
>
> Replace "USERID" and "HOSTNAME" with the actual re= gular userid and the
> actual hostname. =C2=A0If you have 2 or more users that need to automo= unt USB
> devices, add a separate line for each one.
>
> 4) b) Yanking out a USB key or external drive, after writing, without<= br> > unmounting it first, "is not a good thing". =C2=A0Since the = USB device is
> automounted by root, a regular user needs to use sudo to unmount it. > That's why we installed sudo. =C2=A0E.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 directo= ry 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 bootabl= e
> CD or USB stick handy, to recover with.
>
>
> =C2=A0When running with mdev instead of udev under Gentoo, device setu= p is
> controlled by /etc/mdev.conf. =C2=A0There is a brief intro to the synt= ax at
> http://= git.busybox.net/busybox/plain/docs/mdev.txt
>
> =C2=A0We will make one change to /etc/mdev.conf and add a script to /l= ib/mdev/
>
> 1) Make a backup copy of /etc/mdev.conf
>
> cp /etc/mdev.conf /etc/mdev.conf.000
>
> =C2=A0If stuff goes terribly wrong, you can boot from recovery media a= nd
> 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].* =C2=A0 =C2=A0 =C2=A0 root:disk 660 */lib/mdev/usbdisk_link >
> to
>
> sd[a-z].* =C2=A0 =C2=A0 =C2=A0 root:disk 660 */lib/mdev/usbdisk_automo= unt
>
>
> 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. =C2=A0Plug in= USB
> keys/hard-drives/card-readers/direct-connection-to-cameras and play > around with them.
>
> NOTES
> =3D=3D=3D=3D=3D
>
> 1) Sorry, pmount is hard-coded to mount in /media, e.g. /media/sdb1, a= nd
> similar. =C2=A0If you want it mounting elsewhere, please submit patche= s to
> upstream.
>
> 2) If you connect a device (key or hard drive) formatted with a posix<= br> > filesystem (ext2/3/4, reiserfs, btrfs, etc) file permissions will appl= y
> as usual. =C2=A0I.e. a regular user won't be able to modify/delete= files
> owned by other users (including root). =C2=A0The various FAT variants = do not
> support posix file permissions. =C2=A0pmount arbitrarily assigns user:= root
> and group:plugdev to all files+directories on FAT-based filesystems. = =C2=A0By
> using the "--umask 007" option in pmount, all files on FAT-b= ased 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? =C2=A0If so, can you please let me know if automounting works w= ith 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. =C2=A0It does not pass any= environmental
> # variables other than MDEV. =C2=A0If no ACTION variable is passed, ex= it
> # the script.
> if [ "X${ACTION}" =3D=3D "X" ] ; then exit 0 ; fi<= br> > #
> # 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}" !=3D "Xpartition" ] ; then exit= 0 ; fi
>
> # Debug data dump.
> exec 3>> /dev/shm/mdevlog.txt
> echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * ${SEQNUM}&q= uot; >&3
> /usr/bin/printenv >&3
> exec 3>&-
>
> #
> # The "add" action.
> if [ "X${ACTION}" =3D=3D "Xadd" ] ; then
> #
> # Create the directory in /media
> =C2=A0 mkdir -p /media/${MDEV}
> #
> # Mount the directory in /media
> =C2=A0 pmount --umask 007 --noatime /dev/${MDEV}
> #
> # The "remove" action.
> elif [ "X${ACTION}" =3D=3D "Xremove" ] ; then
> #
> # Unmount the directory in /media
> =C2=A0 umount /media/${MDEV}
> #
> # Delete the directory in /media
> =C2=A0 rm -rf /media/${MDEV}
> fi
>
>

A quick question : for automounting to work, do you need to do sysctl -w= kernel.hotplug=3D/sbin/mdev , or is it optional?

Rgds,

--14dae9ccd4882a060704c1236113--