FreeBSD: Allow Normal Users To Mount CDROMs / DVDs / USB Devices

Posted on in Categories last updated November 5, 2012

How do I allow any ordinary users (such as my son or wife) to mount CD-ROMs, DVDs, USB drives, and other removable media on our home server powered by FreeBSD operating systems?

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.


Edit /etc/sysctl.conf, enter:
# vi /etc/sysctl.conf
Append the following variable so that it can load persist across reboots:


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
# 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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

3 comment

  1. I think it’s better take instruction for USB drive from handbook

    #This is accomplished by adding these lines to /etc/devfs.rules:
    add path ‘da*’ mode 0660 group operator
    #You also have to enable your devfs.rules(5) ruleset in your /etc/rc.conf file:
    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.

  2. 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

Leave a Comment