How could I mount an ext4 partition and have write permission?
Solution 1
First of, it'd be useful to check the drive's UUID by using following command:
ls -l /dev/disk/by-uuid
In my experience, I usually mount an EXT4 formatted harddrive using the defaults, and I never experienced any errors in write permissions.
My /etc/fstab
looks like the following:
UUID=004f9bfa-fb5a-438c-8a5a-dc04fa6f2d3e /media/MYCH0 auto defaults 0 0 #external hdd
if all fails, you also might try to set yourself as the owner by doing this:
sudo chown username:username /media/mountpoint
For further reference, you might want to take a look at this:
http://ubuntuforums.org/showthread.php?t=1482818
Solution 2
This may not because of mounting problem, but of permission. You may not have sufficient permission to write on drive/folders on it or you are not the owner.
As you not provided the mount point we assume partition mounted at /media/foo
To own a directory,
Open a terminal and run sudo mkdir /media/foo/test; sudo chown $USER /media/foo/test
. Now you should be able to write inside the folder test.
If you want to write on the folder then there are two option.
1. own the data by sudo chown $USER /media/foo
.
2. Allow write for other users sudo chmod o w /media/foo
Rarely some people interested in write, read access to all content for all users, like a windows partiton in linux. Commands chmod
and chown
has an option -R
which recursively change the mode of all data under it. But it is not recommended unless you know what you do. If you use the -R on a OS's partition it may become unfunctional.
Solution 3
Unfortunately Linux kernel enforces POSIX permission on ext2/ext3/ext4 FS.
With common group across hosts and setgid
bit or ACL you may share external volume across different hosts and keep read/write permission. One example of such setup is:
$ sudo chgrp -R sys /mnt/data/dir
$ sudo chgmod -R g+s /mnt/data/dir
$ sudo fsetacl -R -m g:sys:rwx /mnt/data/dir
$ sudo fsetacl -R -d -m g:sys:rwx /mnt/data/dir
$ sudo adduser user sys
Read more at https://unix.stackexchange.com/questions/126213/external-hard-drive-permissions-ext4/
See also Solving permission problems when using external EXT4 hard disk with multiple linux installs
Related videos on Youtube
Sameh Hany
Updated on September 18, 2022Comments
-
Sameh Hany over 1 year
I've set the
/etc/fstab
file so that I can mount an ext4 partition on startup and I did it with the following options :rw
,auto
,nouser
,exec
,sync
.The problem is that I can't create or delete any file on that partition without using sudo, which I find even more puzzling because I've mounted an
ntfs
partition (with these options :rw
,auto
,user
,noexec
,sync
) and I didn't get the same problem I can read and write on the ntfs partition without using sudo.How could I mount an ext4 partition and have read/write permissions on it?
-
user98085 over 11 yearsWhilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
-
m.devrees over 11 years@FEichinger Thanks for the heads up, I've edited my post.
-
user98085 over 11 yearsWonderful. Please do include the source link, though, as it may have further information. In fact, try to always include the material you used to come to the answer. :)
-
Sameh Hany over 11 yearsthanx, that did help
-
Kiwy about 10 yearsrecursive 777 chmod is definitlely a very bad idea
-
Kiwy almost 10 yearsas far as I can tell what you say is very inacurate, and a very important warning on
chmod 777 -R
is still missing. I guess that you do not use windows that often, because it does handle groups and user access on file system since windows 2000 NT -
Prinz almost 10 years@Kiwy. Updated. I mean windows partition on linux. Does a windows partiton have write access to all linux users ?
-
askcompu almost 8 yearswhat if i want the hard drive to be able to be used by anyone who plugs it into their computer and not have to deal with permissions each and every time?