15

I'm trying to mount an ext3 file system from another Linux installation so that the user, not root, will have full access to all the files. (I really do need user to have access to those files, because I would like to use them from another computer via sshfs, and sshfs will only give the user's access rights to the files.)

If I run mount /dev/sda1 /mnt/whatever all files are only accessible by root.

I've also tried mount -o nosuid,uid=1000,gid=1000 /dev/sda1 /mnt/whatever as instructed by a SuperUser question discussing ext4 but that fails with an error, and dmesg reports:

EXT3-fs: Unrecognized mount option "uid=1000" or missing value

How can I mount the filesystem?

3
  • 1
    I'd say that Gilles' answer in the SuperUser question you mentioned is the correct one. Indeed, then man page mount(8) does not list uid=... and gid=... options for none of the ext2/3/4 filesystems. Commented Jun 9, 2011 at 11:26
  • @Riccardo Thanks, that was the correct solution! First mounting the ext into some directory regularly, then mounting that directory with bindfs -u $(id -u) -g $(id -g) into the final destination. Write it up as an answer, maybe? Commented Jun 9, 2011 at 12:21
  • 1
    Since the answer is Gilles' and he's very active on this forum as well, I'll leave it up to him to re-post it here and collect the deserved credit. Commented Jun 9, 2011 at 12:51

2 Answers 2

22

On an ext4 filesystem (like ext2, ext3, and most other Unix-originating filesystems), the effective file permissions don't depend on who mounted the filesystem or on mount options, only on the metadata stored within the filesystem.

If you have a removable filesystem that uses different user IDs from your system, you can use bindfs to provide a view of any filesystem with different ownership or permissions. The removable filesystem must be mounted already, e.g. on /mnt/sda1; then, if you want a particular user to appear as the owner of all files, you can run something like

mkdir /home/$user/sda1 bindfs --no-allow-other -u $user -g $group /mnt/sda1 /home/$user/sda1 
7
  • 1
    Thank you from me as well! With a little tweak, this also works for devices like e. g. hot-plugged SATA DVD-ROMs (which was the device I had problems with). HOWEVER, the device will always be mounted 000 for some reason (d---------) so you have to specify -p 700 to the bindfs line to access the files on the DVD via dolphin/nautilus etc., for instance. Commented Nov 17, 2013 at 23:27
  • Would be nice if bindfs could accept dictionaries for translating any set of UIDs and GIDs... Commented Dec 24, 2016 at 14:42
  • 1
    I had to use the --no-allow-other option too. This stops bindfs from asking for permissions that my OS (Ubuntu 22.04) doesn't grant by default. Commented Feb 2, 2024 at 1:32
  • 1
    @Hibou57 These are file permissions, ownership, and access control lists. You can set them with chmod, chown, chgrp and setfacl. Commented Aug 26 at 11:20
  • 1
    @Hibou57 The ext4 filesystem (and other Unix-like filesystems) does not support user or group as mount options. It's not some metadata in the filesystem that makes them invalid, they're intrinsically meaningless to the filesystem driver. Commented Aug 26 at 16:07
0

A solution (just tested, it works), is to chown the directory after the filesystem was mounted onto it: https://superuser.com/questions/320415/mount-device-with-specific-user-rights

Seems at least, neither ext4 not ext3, supports to specify user and group at mount time (which leads to a question: in which way the behavior differs with /etc/fstab?)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.