Date: Fri, 14 Feb 2014 18:16:10 +0100 From: Roland Smith <rsmith@xs4all.nl> To: B J <va6bmj@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: Can't Mount USB Drive As User Under FreeBSD 10 Message-ID: <20140214171610.GA58795@slackbox.erewhon.net> In-Reply-To: <CAP7QzkPx8Q1V8U1wAdBGZkDu-d94wPBZtfYV-R7XHewyCi_SmQ@mail.gmail.com> References: <CAP7QzkPx8Q1V8U1wAdBGZkDu-d94wPBZtfYV-R7XHewyCi_SmQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140214171610.GA58795>