LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Permissions and ownership of /media and /mnt (https://www.linuxquestions.org/questions/linux-software-2/permissions-and-ownership-of-media-and-mnt-626752/)

Haines Browsn 03-09-2008 06:32 AM

Permissions and ownership of /media and /mnt
 
In the past, I've been too much in a hurry and simply changed ownership of /media and /mnt to owner:owner, although I suspect that was not correct.

My inclination would be to assign these mount point directories to a group, and then put users into the group. No standard group seems appropriate. When I plug in a usb-stick, it is assigned to a device interface in floppy group (I'm running sidux on a Thinkpad X61s) and wonder if that is an obvious group name.

Is changing permission of these directories to owner:owner OK? Or should I take care of the problem in fstab? If not, should I assign a group? Would "floppy" be appropriate?

Haines Brown

jschiwal 03-09-2008 07:27 AM

No. Normally the permissions of the mount point don't matter because they will be changed when something will be mounted over them. However, /media and /mnt are probably the parent directories of the mount points anyway.

Which desktop environment do you use. I'm not familiar with Sidux. Does it use hal?
Does a dialog box pop up on the screen if you insert a pen drive? If so, is there a properties button you can hit. It may have mounting options including to mount using the users uid.

You can add an entry in /etc/fstab for your pendrive. I would recommend using the label or filesystem uuid to mount it instead of the device node. If you do this, I would recommend using a mount point under /mnt/ instead of /media/.

If you insert the pendrive, determine which device node was used. Either from /var/log/messages or dmesg or ls /dev/sd* or "sudo /sbin/fdisk -l". There are numerous ways to get that info.

The use "udevinfo -q env -n /dev/sdXN" where sdXN is a device node such as sdb1. Note the line for the filesystem uuid and copy the value.

Then when you edit /etc/fstab, you can use:
Code:

UUID=<the fs_uuid number> /mnt/pendrive vfat rw,noauto,nosuid,nodev,noatime,flush,uid=<username>,utf8,shortname=lower
Now you will be able to mount the pendrive as a normal user entering "mount /mnt/pendrive". It is the "user" option that does this magic. The mount program has its suid bit set, but is careful to only allow regular users to mount if the /etc/fstab entry says so.

The "noauto" option prevents stalling during bootup because a removable drive isn't plugged in. The "uid=" and "gid=" options change the ownership and group of the mounted filesystem. The chmod and chown commands won't even work on a fat32 filesystem.

To change the permissions, you need to include other options in the fstab entry as well.
"fmask=0660,dmask=0770" will result in rw-rw---- permissions on all files and rwxrwx--- permissions for all directories.

Good Luck!

Haines Browsn 03-09-2008 12:46 PM

Thanks for all the tips. I had concluded that what really mattered in this case was putting users as option in fstab.

You suggest: "/media and /mnt are probably the parent directories of the mount points anyway". Well, I'm trying to avoid having mount points in /mnt, which I see as a temporary mount point in itself. I know I'm bucking the trend.

> Which desktop environment do you use. I'm not familiar with Sidux.
> Does it use hal? Does a dialog box pop up on the screen if you insert
> a pen drive? If so, is there a properties button you can hit. It may
> have mounting options including to mount using the users uid.

This is a new installation that by default gave me a desktop manager, but I'm about to purge it and run just on a window manager. Sidux is a modification of the debian unstable version (Sid). Debian generally is very conservative, which is a good thing in my view, but I've installed debian on new hardware (Thinkpad X61s), and so need something more cutting edge. Sidux is both cutting edge and yet fairly stable.

Sidux uses HAL. The KDE mount dialog will happily disappear when I purge KDE. I would be inclined to use LABEL in fstab for my USB-key. Although this little laptop has no optical or floppy drive and one usb-jack, the reason I'd bother with labels is that some of my usb-keys are formatted vfat and others ext3 (such as the one I used to install the system).

On my desktop system, where I've got all kinds of things to plug in and sometimes use multiple scsi disk, the jumping about of the device interface can be a nuisance, and certainly need LABELs and UUIDs.

jschiwal 03-11-2008 05:12 AM

If your distro uses hal, one thing to watch for is that you don't have the "noacpi" boot option. Auto-mounting won't work with it. You will need a separate /etc/fstab entry for each unique label or UUID. You could have some similar pen drives using the same label however. For example, two labeled "PODCASTS". As long as they used the same filesystem, they would then be mounted the same which would be convenient. My concern with using /media is that the hal/udev system creates and deletes directories there on the fly. You could end up having to recreate a mount point before mounting a pendrive.


All times are GMT -5. The time now is 12:29 PM.