I am running a server on AWS that requires a storage volume to be mounted on an as-needed basis. I need 'normal' users (those without any sudo privileges etc.) to be able to mount this drive and perform necessary actions.

To do so, I did:

  1. Create a group called xyz: sudo groupadd xyz
  2. Added my user to this group: sudo usermod -a -G xyz sriram
  3. Edited /etc/sudoers file like so:

    %xyz ALL=/bin/mount /dev/xvdg, /bin/umount /dev/xvdg

However, when I try to mount the drive with:
mount /dev/xvdg data

I get the error:

only root can do that...

Adding sudo to the above command did not solve issues as user sriram is not part of the wheel group either.

I also read through some posts online that suggest adding user details in /etc/fstab. That would allow me to mount this drive without sudo. However, this is not my use case. I want to be able to mount the drive on an as-needed basis

How do I solve this? Where am I going wrong?


sudo expects to match the full path of the command. So try

sudo /bin/mount /dev/xvdg /data

(You will need to add the " /data" part to your sudo line also).

  • sudo does the PATH lookup, sudo mount /dev/xvdg /data would work. The missing /data in the sudo configuration is the problem. – Gilles Mar 8 '16 at 22:48
  • @Uditha: Thank you for your reply. I was missing the destination folder. – Sriram Mar 9 '16 at 6:06

You should add a line in /etc/fstab which describes how to mount volumes. Reading the page displayed with man fstab you should take a look at the user option. This solution does not use sudo, but I assume your ultimate goal is to allow regular users to mount the drive.

  • Thanks for replying. This drive is not mounted with /etc/fstab at all. I am using AWS. – Sriram Mar 8 '16 at 13:10
  • 1
    From what I read on AWS documentation, point 7, fstab is used as well. The user option should probably be added after defaults,nofail in their example. The file fstab is not only meant for volumes mounted at startup, it can also describe mounts of the kind you need. You can use the noauto option to specifically prevent automatic mounting. – Vincent Nivoliers Mar 8 '16 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.