Mount a disk image root has no access to

4

1

I need to mount a disk image located on an NFS network share without copying it first.

Only a non-root user (apache) on the RHEL 5 machine I'm on has permissions to access the files on that network share.

sudo mount / sudo losetup both didn't work, as I lose permission to access the files. Adding an /etc/fstab entry with user flag didn't work either. chmod ugo+rw on the network share also failed.

Is there any way to mount these disk images without copying them first?


Doing what @Malvineous suggested:

$ losetup -o 512 /dev/loop7 img.img
/dev/loop7: Permission denied

# chown apache:apache /dev/loop7

$ losetup -o 512 /dev/loop7 img.img
memlock: Cannot allocate memory
Couldn't lock into memory, exiting.

Doing the exact same thing as root works.

Daniel Beck

Posted 2011-03-14T21:46:59.757

Reputation: 98 421

Answers

3

What happens if you chown apache /dev/loop0 then use losetup as the apache user to set up the loopback device. You should then be able to mount /dev/loop0 as root.

In response to the updated question:

A quick Google suggests you should be able to get around it by increasing the amount of memory you, as a normal user, can lock. As only root can do this, you will need to su to root, run "ulimit -l unlimited" to remove the limit, then su to the user you were before (don't logout like you normally would to go back to your normal user or you'll restore the previous limit in the process.)

Malvineous

Posted 2011-03-14T21:46:59.757

Reputation: 1 881