From owner-freebsd-questions@FreeBSD.ORG Mon Feb 17 02:43:32 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2E7B95DA for ; Mon, 17 Feb 2014 02:43:32 +0000 (UTC) Received: from mail-vc0-x233.google.com (mail-vc0-x233.google.com [IPv6:2607:f8b0:400c:c03::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DDDC5171D for ; Mon, 17 Feb 2014 02:43:31 +0000 (UTC) Received: by mail-vc0-f179.google.com with SMTP id lh14so10952250vcb.24 for ; Sun, 16 Feb 2014 18:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0a2y3YxbadXi1c4Ofp2k8LyR/k+AeXRAV/fA1sEyYtI=; b=b4Uq3BAW06+9P5CdaqY8IwUsUXGZ90FqV0NwQt30WYuKe8IWc+4Z7YojwhATsrZD5n 8/5OgxdY/EKu6Lbhor5F+60uIUFE62IbvINJFDoyLHIM+C309443sKRkIfM7hIkXxTeR 09Lw61MEGBZC5aicRT561SnpN+65gVIsFacJ8Rpb0XhJpR1b45q4ttL3V8hBJiZ1uqST gh0sMSb2btDI+IGjE2wxxeFaqcI55/2Nihj3tGxnKX1kkG9ZreEM24hKZ2ZTlBVcNyW1 wOa79UINB4KwJwMMR7t732DLqCAWE5qryvieRd0MYVhMae2DQ6Pdrx63s8+0tI521EYy RBVA== MIME-Version: 1.0 X-Received: by 10.52.189.33 with SMTP id gf1mr9466867vdc.26.1392605010989; Sun, 16 Feb 2014 18:43:30 -0800 (PST) Received: by 10.59.13.226 with HTTP; Sun, 16 Feb 2014 18:43:30 -0800 (PST) In-Reply-To: <20140214171610.GA58795@slackbox.erewhon.net> References: <20140214171610.GA58795@slackbox.erewhon.net> Date: Mon, 17 Feb 2014 02:43:30 +0000 Message-ID: Subject: Re: Can't Mount USB Drive As User Under FreeBSD 10 From: B J To: Roland Smith Content-Type: text/plain; charset=ISO-8859-1 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: Mon, 17 Feb 2014 02:43:32 -0000 On 2/14/14, Roland Smith wrote: > 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. >> >> I recently installed FreeBSD 10 on a T42 Thinkpad. The configuration >> uses Gnome as the desktop. >> >> I've had problems configuring the machine to mount external USB >> drives. I can mount USB thumb drives when logged in as root using: >> >> mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /mnt/root >> >> 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=1 > > 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 > > I've chosen. > > So, in /etc/devfs.rules I've put the following; > > [my_usb=10] > 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="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 > done > 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="/media" > USERUMOUNT="YES" > USER="your_name_here" > ATIME="NO" > REMOVEDIRS="YES" > > The directory '/media' has to be created. Under this directory, > 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 '/media/da0s1' owned 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! I got something to work. As we used to say while I worked in industry, if it works, don't fix it. Here's what I did: - installed automount - added the commands listed above (spelling things correctly helps! ;-)) - put "mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /media" in a file (I called it mountusb) - put "umount /media" in another file (I called it unmountusb), and - make a link to /media and put it on the desktop. I created identical files in my user account. Putting those commands into files saves me the headache of typing them each time. While operating as root, I: - mounted the USB drive by typing "source mountusb" - clicked on the link, the contents of the USB drive appeared, and - umounted the USB drive by typing "source unmountusb" While operating in my personal account, I: - changed to the C shell, and - used "source mountusb" and "source unmountusb" as before. I copied files from the USB onto my desktop without any problems. Anyway, it works and it's good enough for my purposes. Thanks for the information. B.M. Jatzeck