6

I just created a new ext4 filesystem on a new drive and I am trying to mount it manually:

mount /dev/sdc1 a 

it does mount correctly, but then only root seems to have write permissions. How can I give write permissions to my user as well?

1
  • Is this a permanent thing? If so, you can add the drive to your /etc/fstab with the user option activated. Commented Feb 19, 2016 at 21:50

3 Answers 3

6

This is normal behavior - mount doesn't give write permissions at all. The write permissions are controlled by the permissions bits on the directory in the filesystem (i.e. after it's mounted). To manage who can read and write from/to this filesystem, just use the normal chown and chmod tools.

5
  • 2
    Why does mount change the ownership of the directory? Initially this a directory was owned by my user with write permission on it. Commented Feb 19, 2016 at 20:12
  • 2
    @Grzenio mount temporarily overlays the directory a with the / directory of the filesystem that has been mounted. a's owner, its permissions, even all of its contents, are all hidden. When you unmount the filesystem, you can access a just as it was before. Commented Feb 19, 2016 at 20:25
  • The directory a prior to the mount is a completely different item than the filesystem at a after the mount. Commented Feb 19, 2016 at 23:58
  • "mount doesn't give write permissions at all." For the sake of completeness, some filesystems (the ones which don't support Unix permissions, e. g. fat and vfat) may be provided uid, gid and some ?mask options through mount to control access. Commented Feb 20, 2016 at 16:46
  • If you just need to view files, and the mounted filesystem is read-only, just open a GUI file manager as root, as I mention here. Commented May 15, 2023 at 22:58
1

As Mark Plotnick said, mount just overlays a directory in your system with the contents of / on the attached drive.

To circumnavigate this and as an expansion to John's answer, you can try

chmod -R -rwxrw-rw a 

or

chmod -R 755 a 

depending on your preference. The command will change all files in a to give you RW permissions.

Alternatively, if ls -l reports that root is the owner:

chown -R <your name here> a 

would make you the owner of all the files in a.

chmod and chown with -R can mess up some intentional permissions modifications on files, so do exercise caution when executing such commands.

2
  • 1
    Shouldn't that be chmod -R -rwxrw-rw- a? (with a final - to say unprivileged users can't execute the file.) Commented Sep 24, 2018 at 15:27
  • The second command and the third combined worked for me. Commented Feb 16, 2022 at 6:15
0

If the mounted filesystem is read only, such as a MacBook Apple Filesystem (APFS) mounted with apfs-fuse on an Ubuntu LiveUSB, you can't use chown to change the owner. In that case, just open a root file manager window and view the files through that.

Ex:

# the default Ubuntu file manager: nautilus sudo nautilus # the pretty one (https://askubuntu.com/a/1173861/327339): nemo sudo add-apt-repository universe sudo apt update sudo apt install nemo sudo nemo 

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.