Binary Revolution Forums: HOWTO allow users mount external devices - Binary Revolution Forums

Jump to content

Welcome to Binary Revolution Forums

Welcome to the Binary Revolution Forums! You are a guest and are welcome to browse our 7 public forums at the top of the list without registering. All other forums are restricted to registered users only and will give you an "unauthorized" message if you try to browse them. However, if you Register or Sign In (ABSOLUTELY FREE and PRIVATE) you will be able to access many more sections of the site that are reserved for registered members and have lots of other benefits such as bypassing those annoying ads.

  • NO ADS! All of the ads are for GUESTS ONLY!
  • The annoying guest message (this very one) at the top of every page will go away.
  • Access our private messaging system to communicate with other users.
  • Start new topics and reply to others instead of just reading.
  • Subscribe to topics and forums to get automatic updates on watched threads.
  • Add/view events to our community calendar.
  • Customize your profile and see your statistics.
  • Change your preferences such as choosing layouts and tweaking your settings.
  • Contribute your site to our database of links.
  • Access our Gallery and all of its features (instead of just viewing thumbnails) including uploading images of your own.
  • Build up your reputation using our reputation controls.
  • Once again: NO ADS! All of the ads are for GUESTS ONLY! It is all free so Register Now!
Guest Message © 2012 DevFuse
ANNOUNCEMENTS & NEWS:


ANNOUNCEMENT: BinRev is now proud to be hosted and affiliated with lunarpages! See the announcement at the top of the forums for more details.
ANNOUNCEMENT: Follow us on twitter: @binrev @stankdawg

NOTE 2012-03-12: The forums are pretty neglected these days. I still stop in and clean up SPAM every once in a while and ban asshats as the need arises but you MUST USE THE REPORT FEATURE to notify the moderating team! We will not know that there are problems if you do not report it.

-- StankDawg

Subscribe to CETX_var_log        RSS Feed
-----

HOWTO allow users mount external devices

Icon Leave Comment
For quite a while, I was fine with my Slackware system not allowing normal users to mount external drives or optical discs -- because I very rarely used external drives or discs under Slackware. Lately I purchased a small portable drive that I am using to organize and keep my personal data, so I've been moving a lot of stuff from DVD-Rs to this drive, and it started to become bothersome to "sudo mount" everything and then "sudo umount" and enter the passwords and the device locations and mount points. So I decided to figure out how to allow my normal user identity to mount these external devices. This is very poorly documented in the books I have on the subject, so here's how: ''Please note that the # indicates things done as root, and % denote regular user.'' 1. As root, open in a text editor the /etc/fstab file. I use vim, but you can use pico or nano or whatever you like.
# vim /etc/fstab
2. There are already entries here by default, and they look a little something like this:
 /dev/sda1	  /				  ext3	 defaults	 1 1  /dev/hda	   /media/cdrom	   iso9660  user,ro	  0 0
(and so on...) the idea here is that the first column is the device location and the second is the mount point. The third is what kind of filesystem it will default to. The fourth is who gets to mount it. And the fifth and sixth are related to fsck (file system check). Many of the entries in /etc/fstab by default are the mount points of your actual operating system. So there's the root mount point, there's the mount point for proc and maybe a floppy drive (or SD card reader, in the case of my Vaio). You probably won't necessarily need to mess with the root and proc mount points; instead, you'll be either adding or editing the entries for the optical drive, SD card reader, and external hard drive. So if you know your optical drive is located at /dev/hda and you know you want to put it in the /media/cdrom folder when it's mounted, the entry would begin as such:
/dev/hda	  /media/cdrom
Optical discs are pretty much always the filesystem type of iso9660 so that's the third column. The fourth column - the users who get to mount it - is the tricky one. If you want only ROOT to be able to mount that device, then put the word "root" in the fourth column. If you want any USER to be able to mount that device, then put the word "users" (not the username; the actual word "user"!) in the fourth column. And just to be clear about this, the presence of ROOT in the fourth column will make it so that ONLY root will be able to mount it. So if you want a user to be able to mount it, ONLY "users" should be placed in the fourth column, not "users,root". We must assume that if a user can mount a drive, so can root.... but if root can mount it, then only root can mount it. Makes sense if you think about it. If the device is read-only, add the word "ro" in the fourth column. If it's readable and writable then add "rw". The last column you can leave as is. So in the end, my /etc/fstab had this added to its default list:
 /dev/hda	   /media/cdrom	   iso9660  user,ro		  0 0  /dev/sdb1	  /media/hd		  auto	 noauto,user,rw   0 0
This allows the user to mount a cd or dvd as read-only at the mount point /media/cdrom as well as a hard drive plugged into the USB port (regardless of filesystem type, which will simply be auto-detected) as a read-write device at the mount point /media/hd As user, type in simply
% mount /media/hd
and it will be mounted for you. No need to type in % mount /dev/sdb1 /media/hd or anything complex like that. If you do this, you will be prompted for more information because it is assumed that you are attempting to override fstab.Why not use /mnt instead? Simply because, since I sometimes use Konqueror, it's easier to mount things by default to the /media folder, as Konquerer by default checks /media for mounted filesystems. No reboot required, no logout required! It just works right away! That's it!Actually that's not quite it. There MAY be a permissions issue, depending on your distro. If, for instance, you are defining the mount point as /media/hd and the USER has no permission to write to /media/hd then the USER won't be able to copy files on the hard drive. So as root, you'll need to change permissions of the /media/hd directory to something that includes write permission for the everyday user. Like so:
# chmod -hR <USERNAME> /media/hd
Now mount the drive to that directory and watch in amazement as the everyday user is able to read and write to the drive!That's it.

0 Comments On This Entry

 

May 2012

S M T W T F S
  12345
6789101112
13141516 17 1819
20212223242526
2728293031  

Recent Entries

Recent Comments

Search My Blog


  • Time Now: May 17 2012 05:14 AM