LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 08:41 AM   #1
someshpr
Member
 
Registered: Jul 2009
Location: WI, USA
Distribution: Debian 8, Ubuntu 16.04, CentOS 7
Posts: 143

Rep: Reputation: 28
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, 06:14 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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, 09:04 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,996

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
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, 10:30 PM   #4
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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-24-2011, 11:16 PM   #5
someshpr
Member
 
Registered: Jul 2009
Location: WI, USA
Distribution: Debian 8, Ubuntu 16.04, CentOS 7
Posts: 143

Original Poster
Rep: Reputation: 28
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, 12:50 AM   #6
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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, 01: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, 11:26 AM   #8
someshpr
Member
 
Registered: Jul 2009
Location: WI, USA
Distribution: Debian 8, Ubuntu 16.04, CentOS 7
Posts: 143

Original Poster
Rep: Reputation: 28
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 11:30 AM.
 
  


Reply

Tags
fstab, mount



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 11:32 AM
Help editing fstab to mount hard drives ChootarLaal Ubuntu 22 03-08-2008 02:43 PM
USB external hard disk and fstab sblantipodi Linux - General 8 01-06-2008 01:14 PM
Changing permissions on USB external drives theufman Linux - Hardware 9 11-29-2005 09:08 PM
USB External Hard drives lukepiewalker Fedora 2 08-03-2005 09:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:21 AM.

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
Open Source Consulting | Domain Registration