geekvenue.net

Welcome to Chucktips Hardware HELP WITH DEAD OS Installing FreeBSD Miscellaneous
 faq
 search
 add article
 cool-stuff
 how-to
 main
 tips


HOWTO: Allow users to mount filesystems
Miscellaneous Posted by Jason on Saturday April 14, @10:55AM
from the System-Control dept.
*** Revised Post ***
The sysctl utility allows you to view and set system variables. For example you can view how much memory the system has, or set the maximum number of kernel processes. I use it to give standard users the ability to mount floppy disks and cdroms.

Example I
To view all the sysctl parameters try:
sysctl -a

Example II
To view how much memory is installed in your system try:
sysctl | grep hw.physmem

There are four steps to allowing a regular user to mount a filesystem.
  1. Set the vfs.usermount variable with sysctl.
  2. Set permissions for the actual device.
  3. Create a mount point that the user can use for mounting the filesystem.
  4. Mount the filesystem.

[Set the vfs.usermount variable]
Like many FreeBSD system parameters, sysctl variables are set in a configuration file in the /etc directory. In this case it's /etc/sysctl.conf. By default the vfs.usermount parameter is set to 0, by setting it to one you are allowing users to mount filesystems. Login as root and create or edit this file with your favorite editor (ee or vi).

# cd /etc
# ee sysctl.conf

Add the statement:
vfs.usermount=1

Save the file and reboot the system.

[Set Permissions for the Device]
In order for a user to use a device, they will need to have the read and execute permission. Here is how to set the permissions for the floppy disk drive and cdrom devices. You will need to login as root

# chmod o+rx /dev/cdrom
# chmod o+rwx /dev/fd0

[Create a Mount Point for the Users]
Login as root, create the mount point directories and set their permissions. In order for users to mount a filesystem, they must own the mount point. You may want to have mount points in your users home directories (jason in my case).

# mkdir /usr/home/jason/floppy
# mkdir /usr/home/jason/cdrom

# chown jason /usr/home/jason/floppy
# chown jason /usr/home/jason/cdrom

# chmod 775 /usr/home/jason/floppy
# chmod 755 /usr/home/jason/cdrom

[Mounting the filesystem]
Here is how a regular user can mount a floppy diskette (msdos formatted for this example), and a cdrom (cd9660).

Login: someuser
Password: ********

$ mount -t cd9660 /dev/cdrom /usr/home/jason/cdrom
$ mount -t msdos /dev/fd0 /usr/home/jason/floppy

That's all there is to it. If you would like more information on the sysctl command, try the man pages.

man sysctl


<  |  >

 

Related Links
  • Articles on Miscellaneous
  • Also by Jason
  • Contact author

    Lilliput Mini USB Computer Monitor

    If you have ever wanted to learn about Cisco Routers, check out my new book "Cisco Routers for the Small Business" - it's Cisco CLI for the Regular Guy!

  • Sponsors

    The Fine Print: The following comments are owned by whoever posted them.
    ( Add a Reply )

    Re: HOWTO: Allow users to mount filesystems
    by Santhosh Joseph on Tuesday October 30, @11:17PM
    How about using sudo to do the dirty job? With sudo, one can permit any combination of users to perform any root activity like mounting CDROM and FLOPPY on a common mount point like /CDROM and /FLOPPY respectively.
    Apart from mounting CD and FLOPPY, I have been using sudo for many applications, for eg. XMMS allows root user to play tracks from /CDROM. Obviously, normal users can't access it directly as the root user. I have setup my box to run XMMS with sudo and all users can play audio CD by just opening the /CDROM dircetory.
    [ Add a Reply to this ]
    • Re: HOWTO: Allow users to mount filesystems
      by Andrew on Friday November 23, @11:21AM
      "Sudo" doesn't sound so wise. Why compromise such a secure operating system like that?
      [ Reply to this ]
    • Re: HOWTO: Allow users to mount filesystems
      by Martin Klaffenboeck on Tuesday May 28, @04:15PM
      If you want to use a real secure system, you don't want to install sudo. Martin
      [ Reply to this ]
    Re: HOWTO: Allow users to mount filesystems
    by Juan on Friday January 02, @12:59AM
    so if i want users to mount smbfs ?
    [ Add a Reply to this ]
    Re: HOWTO: Allow users to mount filesystems
    by thegeekster on Wednesday March 29, @02:19PM
    When setting the vfs.usermount variable, it is not necessary to reboot the system to update the variable. You merely need to run the 'sysctl' command with the same variable statement you place in the sysctl.conf file, like so:

    sysctl vfs.usermount=1

    This command will update the system immediately without having to rebooot. :-)
    [ Add a Reply to this ]
    The Fine Print: The following comments are owned by whoever posted them.
    ( Article Reply )

    "You never know how many friends you have until you own a Condo on the beach." -- Jason's Postulate

    Powered by Zope  Powered by Apache  Squishdot Powered
    All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest ©2001 Jason Neumann.
    [ main | post article | search ]