LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 02-24-2011, 09:41 AM   #1
someshpr
Member
 
Registered: Jul 2009
Location: CA, USA
Distribution: Debian, RHEL5.4, CentOS 5.4, 6.2, Ubuntu 11.04,12.04
Posts: 107

Rep: Reputation: 26
enable users to mount external usb hard drives w/o changing fstab


Hi,
I always have trouble with this one!
In our office we have some machines running CentOS 5, some running CentOS 4, and one running WinXP! We have external usb hard drives some are formatted ext2, some ext3, some fat32, and some NTFS. I tried to tweak with the fstab so that hard drives will be mounted automatically. But given the different file systems and OSs, I couldn't find a common and generic way to do it, unless I put all possible usb drives and their mount commands in the fstab file. I tried to do it using mount by labels, but realized that there are hard drives with same label but different file systems. So in a nitshell, its complicated!

Till now I have been manually mounting by changing the fstab as root for a particular machine whenever any user needs to connect their hard drives.

But I was wondering if there is a way to give all the users the permission to use the 'mount' and 'umount' command without tweaking the fstab file?

TIA,
 
Old 02-24-2011, 07:14 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,805

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
Quote:
Till now I have been manually mounting by changing the fstab as root for a particular machine whenever any user needs to connect their hard drives.
Editing fstab shouldn't be necessary to mount the drives. When you plug the drive in, it's assigned a to a device file in /dev, for example: /dev/sdc. Then you mount it: mount -t ext2 /dev/sdc /mnt (the mount command, followed by the filesystem type, the drive device, and the mount point). Fstab is not involved.

Quote:
But I was wondering if there is a way to give all the users the permission to use the 'mount' and 'umount' command without tweaking the fstab file?
To give users permission to mount/umount drives, investigate setting up /etc/sudoers to give individual users permission to mount/umount. Note that to edit the sudoers config file, you must use the visudo editor: visudo /etc/sudoers (run as root).
 
1 members found this post helpful.
Old 02-24-2011, 10:04 PM   #3
jefro
Guru
 
Registered: Mar 2008
Posts: 12,087

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
Isn't there some user permission setting for removable media or something like that? Just enable it and users simply plug in and it gets automounted. Pretty sure it is in the gui but ought to be able to access in command line maybe. Dunno, just thinking.
 
Old 02-24-2011, 11:30 PM   #4
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,246

Rep: Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579
Quote:
Isn't there some user permission setting for removable media or something like that? Just enable it and users simply plug in and it gets automounted. Pretty sure it is in the gui but ought to be able to access in command line maybe. Dunno, just thinking.
Would it be plugdev in users and groups?
 
Old 02-25-2011, 12:16 AM   #5
someshpr
Member
 
Registered: Jul 2009
Location: CA, USA
Distribution: Debian, RHEL5.4, CentOS 5.4, 6.2, Ubuntu 11.04,12.04
Posts: 107

Original Poster
Rep: Reputation: 26
Quote:
Originally Posted by bigrigdriver View Post
Editing fstab shouldn't be necessary to mount the drives. When you plug the drive in, it's assigned a to a device file in /dev, for example: /dev/sdc. Then you mount it: mount -t ext2 /dev/sdc /mnt (the mount command, followed by the filesystem type, the drive device, and the mount point). Fstab is not involved.


To give users permission to mount/umount drives, investigate setting up /etc/sudoers to give individual users permission to mount/umount. Note that to edit the sudoers config file, you must use the visudo editor: visudo /etc/sudoers (run as root).
These machines have multiple users none of whom have or should have root/superuser privileges. If I do not change fstab, only I can mount as root using the "mount" command. It doesn't really help the user as user has access and permission problems when the external drive is mounted as root. But if I change the fstab, add a line with proper mount parameters giving user rw permission, and do a "mount -a" as root, then user can mount it by himself without any permission problem.

Playing with sudoers seems a good idea. I'll work on that.

Quote:
Originally Posted by jefro View Post
Isn't there some user permission setting for removable media or something like that? Just enable it and users simply plug in and it gets automounted. Pretty sure it is in the gui but ought to be able to access in command line maybe. Dunno, just thinking.
I have no idea where this user permission settings are for removable media. Also I need a command not a gui tool, I do not have a desktop environment in all the machines!
 
Old 02-25-2011, 01:50 AM   #6
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,805

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
Another approach to consider is to setup udev rules to automount the usb drives with appropriate mount options. There would be a set of rules for each filesystem type that might be plugged in.

The Arch Linux wiki has a good example of the type of rule sets you would need.
https://wiki.archlinux.org/index.php...ng_USB_devices
 
Old 02-25-2011, 02:06 AM   #7
LlNUX
Member
 
Registered: Oct 2007
Location: Sydney, Australia
Distribution: Debian
Posts: 63

Rep: Reputation: 15
Hi, have you considered to install and configure autofs?
 
Old 03-15-2011, 12:26 PM   #8
someshpr
Member
 
Registered: Jul 2009
Location: CA, USA
Distribution: Debian, RHEL5.4, CentOS 5.4, 6.2, Ubuntu 11.04,12.04
Posts: 107

Original Poster
Rep: Reputation: 26
Changed sudoers files and seems to work as I wanted. Added these two lines:
Code:
Cmnd_Alias MOUNT = /sbin/fdisk, /sbin/sfdisk, /bin/mount, /bin/umount

%access.workstations ALL=NOPASSWD:MOUNT
access.workstations is the group all users belong to.

And since this seems to work didn't try with autofs. Also setting up udev posed difficulty for older machines (CentOS 3) and didn't dig deeper on that line.

Thanks,

Last edited by someshpr; 03-15-2011 at 12:30 PM.
 
  


Reply

Tags
fstab, mount


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fstab problem with external USB hard disk Szkarbek Linux - General 3 05-31-2009 12:32 PM
Help editing fstab to mount hard drives ChootarLaal Ubuntu 22 03-08-2008 03:43 PM
USB external hard disk and fstab sblantipodi Linux - General 8 01-06-2008 02:14 PM
Changing permissions on USB external drives theufman Linux - Hardware 9 11-29-2005 10:08 PM
USB External Hard drives lukepiewalker Fedora 2 08-03-2005 10:14 AM


All times are GMT -5. The time now is 10:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration