| Tutorial details | |
|---|---|
| Difficulty | Intermediate (rss) |
| Root privileges | Yes |
| Requirements | FreeBSD |
Under FreeBSD unprivileged users may mount and unmount file systems based on CDROMs or DVDs or USB devices by setting a special kernel variable called vfs.usermount. You need to run the following command as root user
sysctl -w vfs.usermount=1
Next, you need to add and set a device permissions in /etc/devfs.conf file for users.
Example
Edit /etc/sysctl.conf, enter:
# vi /etc/sysctl.conf
Append the following variable so that it can load persist across reboots:
vfs.usermount=1
Save and close the file. Type the following command for current session:
# sysctl -w vfs.usermount=1
Sample outputs:
vfs.usermount: 0 -> 1
Find device names
Use camcontrol devlist or egrep 'ad[0-9]|cd[0-9]' /var/run/dmesg.boot commands to find out CD/DVD/USB device names under FreeBSD:
# camcontrol devlist
OR
# egrep 'ad[0-9]|cd[0-9]' /var/run/dmesg.boot
Update /etc/devfs.conf
The device owner and permissions will be reset the next time the system is restarted, in order to make this change permanent you need to edit /etc/devfs.conf. In this example, I need to allow user vivek to mount my cdrom called /dev/cd0. Edit /etc/devfs.conf, enter:
# vi /etc/devfs.conf
Add the following two line so that all users can mount a USB drive if they are in operator group:
own /dev/da0 root:operator
perm /dev/da00 0666
Also, add the following two line so that all users can mount a /dev/cd0 drive if they are in operator group:
## allow member of operator to mount cdrom
own /dev/cd0 root:operator
perm /dev/cd0 0660
Save and close the file. Feel free to replace /dev/cd0 and /dev/da0 as per your system configuration. You need to add user to a group called operator using the pw command, run:
# pw groupmod operator -m vivek
Verify new group membership, run:
# id vivek
Sample outputs:
uid=1001(vivek) gid=1001(vivek) groups=1001(vivek),0(wheel),5(operator)
User command to mount devices
Normal users can now mount devices they could read onto a directory that they own such as $HOME using the mount_cd9600 command:
% mkdir ~/cdrom
% mount_cd9660 /dev/cd0 ~/cdrom
% mount
Sample outputs:
/dev/ada0p2 on / (ufs, local, journaled soft-updates) devfs on /dev (devfs, local, multilabel) /dev/cd0 on /usr/home/vivek/cdrom (cd9660, local, nosuid, read-only, mounted by vivek)
User command to unmount devices
Unmounting the device is simple:
% umount ~/cdrom
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop










![Linux: Find Out Open Files [ Descriptors ] Command](http://s13.cyberciti.org/images/shared/rp/3/12.jpg)



{ 2 comments… read them below or add one }
I think it’s better take instruction for USB drive from handbook
#This is accomplished by adding these lines to /etc/devfs.rules:
[localrules=5]
add path ‘da*’ mode 0660 group operator
#You also have to enable your devfs.rules(5) ruleset in your /etc/rc.conf file:
devfs_system_ruleset=”localrules”
reason:
The devfs.conf file provides an easy way to set ownership and permis-
sions, or create links for devices available at boot.
It does not work for devices plugged in and out after the system is up
and running, e.g. USB devices. See devfs.rules(5) for setting ownership
and permissions for all device nodes, and devd.conf(5) for actions to be
taken when devices are attached or detached.
You can also add the mount command in /etc/fstab with
noauto so that users could do mount filedirectory without
spelling out the specific device.
In my case for usb:
# device Mountpoint FStype options Dump Pass#
/dev/da0s1 /mnt/juanjo msdosfs rw,noauto 0 0