# Mounting USB Flash and DVD as Non Root user | FreeBSD 10



## john_rambo (Apr 7, 2014)

Hi,
I have implemented sudo and its working.Now I want to enable mount permission for my user account so that I can mount usb flash media and DVD discs using thunar.

I found information and tried them but those didn't work.

Please tell me show to do this.


----------



## SirDice (Apr 7, 2014)

You need to set the sysctl(8) vfs.usermount to 1 to allow non-root users to mount. You will have to restart the machine after making the changes.


----------



## john_rambo (Apr 7, 2014)

SirDice said:
			
		

> You need to set the sysctl(8) vfs.usermount to 1 to allow non-root users to mount. You will have to restart the machine after making the changes.



This is my sysctl.conf

```
$ cat /etc/sysctl.conf 
# $FreeBSD: release/10.0.0/etc/sysctl.conf 112200 2003-03-13 18:43:50Z mux $
#
#  This file is read when going to multi-user and its contents piped thru
#  ``sysctl'' to adjust kernel values.  ``man 5 sysctl.conf'' for details.
#

# Uncomment this to prevent users from seeing information about processes that
# are being run under another UID.
#security.bsd.see_other_uids=0
kern.ipc.shm_allow_removed=1
vfs.usermount=1
```

Rebooted then tried mounting a CD using thunar. It just keeps trying. The busy sign besides the drive stays like that.


----------



## Chris_H (Apr 7, 2014)

john_rambo said:
			
		

> SirDice said:
> 
> 
> 
> ...


Greetings, @john_rambo.
While it may seem counter-intuitive, not all the sysctl() settings can be initiated through sysctl.conf().
Some require loading the settings in loader.conf(). So try moving `vfs.usermount=1` from sysctl.conf to /boot/loader.conf, and see if that doesn't fix it, for you. While I haven't checked `vfs.usermount=1` specifically. You might also be able to get away with simply performing `sysctl vfs.usermount=1`, as root, to get it immediately.

NOTE: that won't necessarily remain set after re-boots, unless you have also declared it within /boot/loader.conf.

UPDATE: I should have also mentioned that you can determine current state of `vfs.usermount` by issuing:
`sysctl vfs.usermount`

--Chris


----------



## Beastie (Apr 7, 2014)

Unless something has changed in FreeBSD 10 (something I very much doubt), the basic configuration is covered in great details in the Handbook.

*vfs.usermount* works fine within /etc/sysctl.conf.

What you may be missing are the right permissions and ownerships for both the device and the mountpoint.


----------



## wblock@ (Apr 7, 2014)

For vfs.usermount to work, the user must be own the mountpoint.

Edit: doh, @Beastie already mentioned that.


----------



## john_rambo (Apr 8, 2014)

I have done the following

`sudo pw usermod user1 -G operator`

/etc/devfs.rules


```
[localrules=5]
own cd0 user1:operator
perm cd* 0660

[localrules=5]
add path 'da*' mode 0660 group operator
add path 'cd*' mode 0660 group operator
```

/etc/rc.conf

`devfs_system_ruleset="localrules"`

/etc/sysctl.conf

`vfs.usermount=1`


```
# mkdir /mnt/user1
# chown user1:operator /mnt/user1
```


----------



## john_rambo (Apr 8, 2014)

Now I can mount my USB flash drive by `mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /mnt/user1` but I cant mount it using thunar.

I have made two scripts, one for mounting and the other for unmounting.


----------



## uzsolt (Apr 11, 2014)

Did you try sysutils/automounter? It's thunar-independent.


----------

