Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a following problem. I need to let normal users mount device /dev/loop0 to a predefined directory /mnt/data. The filesystem of the device is unknown and is to be defined when mount command is invoked via -t option. Furthermore I need to specify an offset when mounting.

I edit the /etc/fstab like this:

/dev/loop0 /mnt/data auto user 0 0

Then I invoke mount like this:

mount loop,offset=32256 hdd.img /mnt/data/

Whet I get is:

mount: only root can do that

What could be the problem?

PS. User is added to "disk" group so he can access /dev/loop*. Rights to access /mnt/data are also granted.

share|improve this question
    
SOLVED: adding to fstab "/dev/loop0 /mnt/data auto loop,users 0 0"; using losetup -o offset /dev/loop0 hdd.img; mounting like "mount /dev/loop0"; umounting and unbinding like losetup -d /dev/loop0 –  azerIO May 7 '11 at 11:36
    
FYI: By a) adding users to disk group or b) allowing users to mount arbitrary filesystems without nosuid,nodev options you are opening your system to quick pwnage. (For example, the user can read private data straight from /dev/sda1.) –  grawity May 7 '11 at 23:30
    
In the end switched to "pmount". It allows mounting anywhere under /media/ if device is listed in /etc/pmount.allow. The discussion about disk group is not relevant. If asking for such thing I probably realize the potential risk out of it and yes I know that one can change rules in udev to make loop devices created with another group etc... –  azerIO May 11 '11 at 14:49
    
Unfortunately, most people asking for such things do not realize the potential risks. –  grawity May 12 '11 at 5:10

1 Answer 1

Would you consider using sudo? You can configure sudo to allow the relevant users to run the mount command as root.

share|improve this answer
    
No, I can't consider "sudo" solution and adding entries in /etc/sudoers. –  azerIO May 7 '11 at 11:14
    
@azerIO: Why not? –  grawity May 7 '11 at 23:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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