I need to mount a ntfs partition and be able to use it with unix file system permissions. The problem is that, when I mount the partition using the following fstab entry, I cannot run chown and chmod successfully. It executes without error, but the file access rights are not changed.
PARTUUID=c3e3b171-d451-44e6-9f17-ffbe9e220dc7 /mnt/mounted_drive ntfs-3g defaults,umask=0022,uid=1000,gid=1000,errors=remount-ro,permissions 0 2
When I mount the partition without setting umask, uid, and gid I can use previously mentioned commands successfully.
PARTUUID=c3e3b171-d451-44e6-9f17-ffbe9e220dc7 /mnt/mounted_drive ntfs-3g defaults,errors=remount-ro,permissions 0 2
What shall I do to mount the partition properly?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
With NTFS-3G, setting the owning user and group seems only to be possible when a UserMapping file containing a mapping for the targeted user/group is present. This is not really clear from the documentation, but I’m testing it just now and that is what is happening.
If compatibility with an existing Windows installation is not needed, create an empty file .NTFS-3G/UserMapping on the mounted partition and fill it via:
getRUI4() { od -An -N4 -tu4 /dev/random | tr -d ' '; }
USERMAPPING=/media/NTFS_PARTITION/.NTFS-3G/UserMapping
echo ":users:S-1-5-21-$(getRUI4)-$(getRUI4)-$(getRUI4)-513" | sudo tee -a $USERMAPPING >/dev/null
echo "$(id -un):$(id -gn):S-1-5-21-$(getRUI4)-$(getRUI4)-$(getRUI4)-1001" | sudo tee -a $USERMAPPING >/dev/null
If you want to use existing Windows SIDs, you can instead use the program ntfsusermap on an unmounted (!) partition, which will interactively ask you to specify user- and group-names (do not need to be numeric, regardless of the message) for given paths where it first finds an as of yet unmapped ID. This is quick to do.
User and group root is mapped by default, as is other. The above lines will create a mapping for users group, and the current user. Repeat as necessary.
Also, in my case, I mount the drive with the options
no_def_opts,allow_other,acl,nodev,nosuid,big_writes,hide_dot_files
However, in your case you should not need any of them, although I find that these options improve upon the default, as otherwise for instance chown/chmod fail silently in case of errors.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0