[SOLVED] enable users to mount external usb hard drives w/o changing fstab
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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).
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.
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.
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
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!
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.