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 do 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 do the mount?

  • 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. – Riccardo Murri Jun 9 '11 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? – Ilari Kajaste Jun 9 '11 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. – Riccardo Murri Jun 9 '11 at 12:51
up vote 16 down vote accepted

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 -u $user -g $group /mnt/sda1 /home/$user/sda1
  • 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. – syntaxerror Nov 17 '13 at 23:27
  • Would be nice if bindfs could accept dictionaries for translating any set of UIDs and GIDs... – Alexey Dec 24 '16 at 14:42

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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