By default, unless the partition being mounted is an ext2/3/4 partition or a partition that can handle UNIX style permissions (such as Mac HFS/HFS+ partitions), the drive gets mounted as root:root
for user/group ownership by default. exFAT/FAT/FAT32/NTFS do not support UNIX style permissions, so you can't use these types of permissions.
As such, you have to set permissions at mount to what you need them to be. There're a lot of different options that you could set, but we'll borrow some from my other answer on how to mount NTFS so it can be read by any user but adapt it for your user only.
First, we need to get some information. You will need to run the id
command, in the terminal. This will give us some information we will need when we construct the mount points, namely your uid
and gid
. Below is the example of such output from my own laptop, though yours will probably differ substantially:
$ id
uid=1000(teward) gid=1000(teward) groups=1000(teward),4(adm),6(disk),20(dialout),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare),132(sbuild),137(lxd),140(wireshark),998(pgadmin4)
Of relevance in this specific instance is the uid
and gid
values, which in my case are 1000
for both. Yours might differ, but we'll need to keep these values handly.
Next, let's restructure your /etc/fstab
line. Your system has done auto
for detecting the external disk, which is fine, but there's a small issue with this - this relies on the OS being able to determine the type of file system on disk. So we'll replace that with ntfs
.
This makes the following the beginning of your /etc/fstab
line:
/dev/sdb4 /mnt/sdb4 ntfs
The key part of what you need to do now, though is adjust the options for mounting. defaults
is a good start point but not what you need. Ideally, you should have the following additional options in your options:
locale=en_US.utf8,windows_names,umask=7000,uid=UID,gid=GID
Note that you need to replace UID
and GID
in the uid=
and gid=
lines with the numeric uid
and gid
values we got earlier from id
.
Because you might wonder what these options do, let me pull my explanation with some edits from my other answer:
locale=en_US.utf8
- enforces the US English locale with UTF8
windows_names
- enforces that Windows name restrictions are in place for new files in the partition.
umask=7007
- Basically, inverse chmod. Define what permissions are not permitted for files. Essentially, I don't prohibit anything
read/write/execute here except for 'other users' than yourself, so all files on the mounted location get,
effectively, read, write, and execute privileges for your user. I don't want any of
the special bits set (setuid, setgid, sticky), so I have to eliminate
them from the first octet - since the numeric sum of those is a '7'
and i'm prohibiting those permissions, I put a leading 7.
uid=1000
, gid=1000
- Have the partition mounted into that folder with user and group ownership of UID (User ID) and GID (Group
ID) of 1000
(this is my user's user and group, teward
, on the
Ubuntu system).
Adding these to the options line will allow your external device to be compliant with your Windows dual boot with file naming, and also enforce UTF8. It'll also set permissions properly, so that your user only can have read/write on the partition. This makes your /etc/fstab
line this:
/dev/sdb4 /mnt/sdb4 auto defaults,x-gvfs-show,locale=en_US.utf8,windows_names,umask=7000,uid=UID,gid=GID 0 0
We don't need to do anything with the last two zeroes, that's OK to leave there. Just make sure you updated the GID
and UID
values to the actual values.
Then, use sudo umount /dev/sdb4 && sudo mount /dev/sdb4
to unmount and remount the partition with the new options. You should then have read/write privileges on the entire disk now.
Best Answer
your windows is putting the "read-only" flag on all detectable ntfs partitions everytime it shuts down or reboots.
If you don't want it to do that, boot to your windows, open up a administator powershell (to do that find powershell in start, right click on it, then select "run as Administrator").
then type :