From owner-freebsd-questions@FreeBSD.ORG Fri Feb 14 17:16:12 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C37C4FE6 for ; Fri, 14 Feb 2014 17:16:12 +0000 (UTC) Received: from smtp-vbr8.xs4all.nl (smtp-vbr8.xs4all.nl [194.109.24.28]) by mx1.freebsd.org (Postfix) with ESMTP id 6C9E21029 for ; Fri, 14 Feb 2014 17:16:11 +0000 (UTC) Received: from slackbox.erewhon.net (a83-162-243-5.adsl.xs4all.nl [83.162.243.5]) by smtp-vbr8.xs4all.nl (8.13.8/8.13.8) with ESMTP id s1EHGB9k042673; Fri, 14 Feb 2014 18:16:11 +0100 (CET) (envelope-from rsmith@xs4all.nl) Received: by slackbox.erewhon.net (Postfix, from userid 1001) id B67BA12375; Fri, 14 Feb 2014 18:16:10 +0100 (CET) Date: Fri, 14 Feb 2014 18:16:10 +0100 From: Roland Smith To: B J Subject: Re: Can't Mount USB Drive As User Under FreeBSD 10 Message-ID: <20140214171610.GA58795@slackbox.erewhon.net> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="45Z9DzgjV8m4Oswq" Content-Disposition: inline In-Reply-To: X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.22 (2013-10-16) X-Virus-Scanned: by XS4ALL Virus Scanner Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Feb 2014 17:16:12 -0000 --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 14, 2014 at 04:39:46AM +0000, B J wrote: > I searched the mailing list archives for an answer to my problem but > didn't find anything. >=20 > I recently installed FreeBSD 10 on a T42 Thinkpad. The configuration > uses Gnome as the desktop. >=20 > I've had problems configuring the machine to mount external USB > drives. I can mount USB thumb drives when logged in as root using: >=20 > mount -t msdosfs -o -m=3D644,-M=3D755 /dev/da0s1 /mnt/root >=20 > after creating the directory /mnt/root. To be able to mount as a user several settings have to be made. First, in /etc/sysctl.conf: vfs.usermount=3D1 Next the permissions for the devices have to be set. Since USB devices can = be plugged in at random, this has to be set in /etc/devfs.rules, not etc/devfs.conf! You can make a choice here; 1) give _everybody_ read/write access by using mode 666 2) restrict r/w access to a group, e.g. a group 'usb'. This is the path= =20 I've chosen. So, in /etc/devfs.rules I've put the following; [my_usb=3D10] add path 'da*' mode 0660 group usb add path 'msdosfs/*' mode 0660 group usb add path 'usb/*' mode 0660 group usb add path 'ugen*' mode 0660 group usb Additionally, in /etc/rc.conf we have to activate this ruleset: devfs_system_ruleset=3D"my_usb" What I like to do is have USB drives mount automatically. To this end I'm using sysutils/automount. This uses devd notifications. Configuration is do= ne with two files; /usr/local/etc/devd/automount_devd.conf: notify 20 { match "system" "DEVFS"; match "type" "CREATE"; match "cdev" "da[0-9]s1$"; action "/usr/local/sbin/automount $cdev attach"; }; notify 20 { match "system" "DEVFS"; match "type" "DESTROY"; match "cdev" "da[0-9]s1$"; action "/usr/local/sbin/automount $cdev detach"; }; N.B.: /usr/local/etc/devd must be named as a directory option in devd.conf(= 5). But this is the default. Next we have /usr/local/etc/automount.conf: MNTPREFIX=3D"/media" USERUMOUNT=3D"YES" USER=3D"your_name_here" ATIME=3D"NO" REMOVEDIRS=3D"YES" The directory =E2=80=98/media=E2=80=99 has to be created. Under this direct= ory, subdirectories named after the device will be created owned by $USER. So if a /dev/da0s1 is detected by devd, it will be mounted at =E2=80=98/media/da0s1=E2=80=99 owne= d by $USER. If the USB cable is unplugged the filesystem will be unmounted. Note that it is better to unmount filesystems by hand before unplugging them! Roland --=20 R.F.Smith http://rsmith.home.xs4all.nl/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) --45Z9DzgjV8m4Oswq Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iEYEARECAAYFAlL+T1oACgkQEnfvsMMhpyXq6gCeNMUM+PihotG4oUzPHNbO/gTd 8boAn3Ek9GrMH1Q+VWJp7Ryw3EFcboQf =uZpi -----END PGP SIGNATURE----- --45Z9DzgjV8m4Oswq--