Linux – How to Mount Filesystem Read/Write as Normal User

linuxmountpermissions

This may seem like a stupid question, but with most Linux stuff, it seems to me that a lot of trivial things are not documented.

Anyway, I want to simply mount an ext4 file-system onto a normal mount point in Ubuntu (/media/whereever), as read-writable for the current logged-in user, i.e. me.

I don't want to add anything into /etc/fstab, I just want to do it now, manually. I need super-user privileges to mount a device, but then only root can read-write that mount. I've tried various of the mount options, added it into fstab, but with no luck.

Best Answer

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.

With Ubuntu, mounting should happen automatically when you insert the disk, or you should be able to click on an icon to mount. You can also install pmount to mount filesystems as an ordinary user from the command line.

If you have a removable filesystem that uses different user IDs from your system, you can use bindfs (in the Ubuntu package of the same name) to provide a view of any filesystem with different ownership or permissions. The removable filesystem must be mounted already, e.g. on /media/disk9; then, if you want to appear as the owner of all files, you can run

mkdir ~/disk9
sudo bindfs -u $(id -u) -g $(id -g) /media/disk9 ~/disk9
Related Question