PDA

View Full Version : Trying to mount loop device during boot: permission denied



openSauce
13th August 2008, 09:31 AM
Hi

I have a file containing an ext3 filesystem I want to mount during bootup, but get a 'permission denied' error. Here is the entry in /etc/fstab:

/mnt/data/.filename /home/user/mntpoint ext3 loop,user,defaults 0 0/mnt/data is the mountpoint of an NTFS partition whose fstab entry occurs above the one for the file, and which mounts correctly.

With the above entry in fstab, the command

mount ~/mntpointmounts the filesystem when I execute it after logging in. But during boot I get the message:

/mnt/data/.filename: permission denied/mnt/data is normally mounted with me as the owner and permissions rwxrwxrwx. I tried mounting it with root as the owner and the same permissions, but got the same error message. I also tried changing the mountpoint to /mnt/mntpoint (owned by root rather than me), but still got the same message.

stevea
13th August 2008, 11:27 AM
What are the permissions & ownership for /mnt/data and /mnt/data/.filename ?
It's quite possible that user has rw permissions to the file (x perms for the dir) and root doesn't.

openSauce
13th August 2008, 12:22 PM
/mnt/data points to an NTFS partition, so all permission bits are on by default, for it and all its children. Here is its fstab entry:

/dev/sda6 /mnt/data ntfs uid=500,gid=500 0 2


$ ls -ld /mnt/data
drwxrwxrwx 1 user user 8192 2008-08-12 09:14 /mnt/data
$ ls -l /mnt/data/.filename
-rwxrwxrwx 1 user user 1073741824 2008-08-13 12:03 /mnt/data/.filename

When nothing is mounted on it, /mnt/data belongs to root:


$ umount ~/mntpoint/
$ sudo umount /mnt/data
$ ls -ld /mnt/data/
drwxr-xr-x 2 root root 4096 2008-05-20 11:07 /mnt/data/

The mountpoint for .filename belongs to user, but I get the same problem if I give a mountpoint belonging to root.

If root executes 'mount -a' from a terminal when /mnt/data is not mounted, then /mnt/data/.filename mounts successfully. The permission error only occurs during boot.

openSauce
15th August 2008, 09:27 AM
Bump...

No suggestions? This seems like it should be something quite simple, although I've tried everything I can think of

bingoUV
15th August 2008, 10:14 AM
I don't understand how ntfs permissions are handled in linux, but some suggestions:

1. Add this in /etc/rc.local


mount -a


2. dmesg might have a more detailed analysis of the reason for permission denied. Add this to rc.local so that you can read the file /tmp/bootMessages after booting:


dmesg > /tmp/bootMessages


3. Try removing uid=500,gid=500 for the ntfs filesystem to see if that is causing root to be unable to mount a file inside this ntfs filesystem.

openSauce
15th August 2008, 12:23 PM
I don't understand how ntfs permissions are handled in linux, but some suggestions:

1. Add this in /etc/rc.local


mount -a



Good idea, but it just gives a second permission denied error during boot.


2. dmesg might have a more detailed analysis of the reason for permission denied. Add this to rc.local so that you can read the file /tmp/bootMessages after booting:


dmesg > /tmp/bootMessages


This produces no output to /tmp/bootMessages, I guess dmesg doesn't work at the time rc.local runs. I've tried grepping the dmesg output after I log in for "mount", "permission", and the filename of the loopback device, but didn't get anything helpful.


3. Try removing uid=500,gid=500 for the ntfs filesystem to see if that is causing root to be unable to mount a file inside this ntfs filesystem.

Makes no difference unfortunately. I tried with options="defaults" and an empty list of options, but no dice either way.

I'm thinking perhaps it is not root who executes 'mount -a' as part of the startup process. Although I'm still not sure whether this would explain the problem.

bingoUV
15th August 2008, 01:57 PM
Could be selinux that is denying the permission. Before mount -a in rc.local, disable selinux enforcement to check this.


echo 0 >/selinux/enforce
mount -a


Otherwise, I can only say it could be one of the NTFS quirks. It is remarkable we have a working NTFS driver for linux without any documentation. Just try creating a small experimental file in an ext3 partition, make an ext3 filesystem in this file and loop mount using fstab. That would settle the issue.

openSauce
15th August 2008, 04:45 PM
Could be selinux that is denying the permission. Before mount -a in rc.local, disable selinux enforcement to check this.


echo 0 >/selinux/enforce
mount -a



Bingo. This makes it mount successfully. But obviously I don't want to be disabling selinux permanently... do you know how I can get it to allow mounting while still enabled?

Under Applications -> System -> SELinux Management I found an option "allow mount to mount any file", but checking it didn't actually allow the mount.

PS tried mounting a file stored on the / partition (which is ext3), but got the same problem, so not an NTFS issue I guess

bingoUV
15th August 2008, 05:24 PM
selinux is a big mystery for me. I keep it enabled it as long as it doesn't break anything that cannot be fixed by trying out the simple suggestion in the popup window it opens. After that selinux is out.

You can try re-enabling selinux after your purpose is solved, be an opportunist. i.e. in /etc/rc.local,



echo 0 >/selinux/enforce
mount -a
echo 1>/selinux/enforce


If you feel uncomfortable with this or it does not work, you will have to create an selinux policy with the ghastly tool provided by fedora. My sympathies.

PS: Sorry I blamed NTFS needlessly.

openSauce
5th October 2008, 11:29 AM
In case anyone else has this problem, I managed to work around it by putting the command to mount the filesystem in my ~/.bash_profile. It does mean I get an error message if I log in a 2nd time, but this can be ignored, or you can put a slightly smarter command in the profile.