I know it sound like a dublicate questions but I tried the following and it didn't help:
My drive is mounted under
/media/data
so I entered
sudo chown -R :users /media/data
However I still cannot write to that partition as a user. I also tried to make an entry in the /etc/fstab
UUID=... /media/data ext4 rw,suid,dev,exec,auto,user,async 0 0
but after that my computer could not boot anymore because he could not find the disk.
I have Ubuntu 14.04 Server installed. The partition is listed under /dev/nvmeOn1p1
and does not appear in the /etc/fstab
(see pics below).
(the device is a "Intel DC P3700" 800GB SSD)
Additional Remark: Since the partition is empty i could also format it and recreate it using gparted for example. Is there a way in gparted or other gui programs to specify that the partition should be usable by all users?
Maybe you're doing the things in the wrong order. When you create a file system with
mkfs.ext4
, everything inside it is owned by user root and group root with your system default permissions set.When you mount that file system on a directory, you see file system permissions and owner, regardless of the original owner and permissions on that directory.
So doing something like this won't work:
The right thing to do is create the file system, mount it, and then change permissions and ownership on it. It doesn't matter what you do in /etc/fstab.
The right way to do it is this:
This should answer your question. If you need more details, read on.
To better understand what happens, let's experiment a little with an image file
Create an empty file to format and mount using
fallocate -l 100MB /tmp/filesystem.img
. Then format it as an ext4 file system withsudo mkfs.ext4 /tmp/filesystem.img
(it's not a block device, but if you answer yes you can put a working ext4 file system on it anyway) and create a directory to use as mount pointmkdir /tmp/experiment
.Now try to change the owner and permissions on that directoy with
sudo chown -R :users /tmp/experiment
andsudo chmod -R g+rw /tmp/experiment
, and check permissions withls -la /tmp/experiment
. You'll get something like this:This tells you that /tmp/experiment is owned by user gerlos and group users, and group members can read, write and execute on it. You can put files in it, for example with
touch /tmp/experiment/somefile
.Now mount the file system on that directory with
sudo mount /mnt/filesystem.img /tmp/experiment
, and look again atls
output:As you can see, now /tmp/experiment seems owned by root, with different permissions! Why? Because we are not looking at /tmp/experiment itself, but at the root directory of the file system contained in /mnt/filesystem.img, mounted on /mnt/experiment.
Additionally, your normal user won't be able to put files there with
touch /tmp/experiment/anotherfile
.If you now try again to run
chown
andchmod
as above, you will change owner and permissions not on the mount point, but on the mounted file system, and your users will be able to use the file system. To confirm this look at ls output one last time:As you can see, now members of users group can put files on the file system! In fact, nothing prevents your normal user from creating a new file there with
touch /tmp/experiment/myfile
:Mission accomplished! :-)
I finally solved the problem. I found out that I had a typo in my UUID. So my final entry in
fstab
was:or even better:
I checked it before rebooting by simply calling:
If the fstab entry is correct everything will mount ok and every user of the computer will have access to the partition (At least to the folders he created himself which is the correct behaviour).
One cat do
while the partition is still mounted to ensure everybody can access the partition.
If you do the ´chown´ ensure the specific user is part of the group "users" by typing:
and logout and login again!
Edit
The partition after mounting by default is owned by root. This seems to prevent anyone from writing to the partition. Changing the owner to "UserNameOfSudo" after mounting as shown above yields the desired behaviour.
Edit2
In the case of sharing the computer between local users and LDAP users a solution is to give all rights to everyone:
and then to set a 'sticky bit', which means only the user that created a folder / file is allowed to delete it. Which adds some sensible security:
A solution that gives default permissions to all, also for newly created files, is with a default access control list.
It is described for full in this unix.stackexchange.com answer -- the short parts:
Problems might occur if you copy files with their set attributes; permissions might be preserved and other users might not edit or overwrite the files (but usually still read). But since the upper level directories are world-writeable, any user can rename or delete the files (and thus (via copying) also create new files owned by oneself and set permissions to
777
). See the above mentioned stackexchange answer.It`s manual - "How create EXT4 partition" https://superuser.com/questions/643765/creating-ext4-partition-from-console
After you can add it on FSTAB. Add next text in end of file /etc/fstab:
Where
/dev/nvme0n1p1
- your physical device,/media/data
- your mountpoint.After use command
mount -a
for mounting all partition in FSTAB.