According to the Ownership and Permissions section of the NTFS-3G documentation, we can use mount options to control file access and creation. The combinations are very complicated (see the two tables there). Also I do not read and get all of them. For example, I do not know whether POSIX ACLs is selected at compile-time or not of the NTFS-3G binary package. But the best I have come out is using a User Mapping file combined with some mount options to approximate a plausible mapping of file ownership and permissions between Windows and Linux.
Warning: This is only what works best for my sharing a NTFS data partition (drive
D: on Windows) between dual-booted Windows 8 and Kubuntu 14.04. The instructions are recorded in careful retrospection but not thoroughly tested. It is too tiring and tedious to repeat the whole procedure again. So follow it at your own risk. But if you do, share back your experience. If you decide to follow the instructions, please read it fully to have a whole picture before actually acting. Good luck!
Alright, here you go! The detailed instructions consist of three parts. Part 1 should be carried out on Windows while Part 2 on Linux. Part 3 is for test.
The User Mapping section of the NTFS-3G documentation specifies two versions to set up user mapping between Windows and Linux, one Windows version and one Linux version. My experience was that the Linux version ended up with a miss. The Linux account was not mapped to my Windows account but some unknown account appeared under an SID. The result was a mess since this unknown account takes ownership of all files of my Windows account. In that situation, unless you have an administrative privilege to take your ownership back, files under your Windows account become inaccessible. But even if you mange, it is still a wrong mapping. That means, later whatever files you create on Linux get assigned to that unknown account on Windows and those on Windows get assigned to root on Linux (if I remember correctly). So on Windows you need to take ownership back again and on Linux change ownership. That is not what we expect it to be. After several hopeless attempts to fix the issue, I gave up and turned to the Windows version. That one worked. Detailed instructions extracted from the relevant section of the NTFS-3G documentation follow:
Download the usermap tool, extract it somewhere (in my case, drive
C:), better outside the NTFS partition (in my case drive
D:) to be shared.
Open the Windows command line. Change to the extracted directory
tools (by default) of the
usermap tool. Then run the following command:
C:\tools> mapuser > UserMapping
This generates a template and redirects it to a file named
UserMapping. Open the file with a text editor, say Notepad, you should see the following lines:
\# Generated by usermap for Windows, v 1.1.5
\# For Windows account "Account" in domain "Domain"
\# Replace "user" and "group" hereafter by matching Linux login
Presumably, the first
SID should be your user SID while the second your group SID. You can check them respectively by commands
whoami /user and
(Note that I added the backslashes to the three comment lines to please the buggy Markdown interpreter of StackExchange. They are not part of the generated file.)
After you make sure the SIDs are correct, following the instructions in the comment, that is, change
user in the
user::SID line to your user name and
group in the
:group:SID line to your primary group name on Linux. On Ubuntu, they are the same. Moreover, add your Linux group name also after the first colon of the
user::SID line. So the line should look something like
user:group:SID. It seems that if not doing so files created on Windows will be assigned to
user:root on Linux.
Save the file. Move it to a directory named
.NTFS-3G (create it if not existent yet) on the NTFS partition to be shared (in my case drive
This step is for test in Part 3. On the shared NTFS partition, create a new directory and a new file.
Now boot into Linux.
sudo edit the file
/etc/fstab. Add or modify the line for the shared NTFS partition to something like the following:
UUID=... /data ntfs defaults,umask=077,utf8 0 0
The essential is to set the
fmask may also work but not tested). Pick a value for
umask you like, although I picked
077. It seems without this setting, full permissions will be given to
others for newly-created files.
Save the file. Now
sudo mount or remount (
sudo umount and then
sudo mount) the shared NTFS partition (in my case
$ sudo mount /data
Now (still on Linux)
cd to the mount point (in my case,
ls -l the files there. Check whether their ownership and permissions match respectively that you specified in the
UserMapping file and the
umask you set in
/etc/fstab (the match between permissions and
umask requires some complement calculation, see man (1) umask for more information). If they do, congratulations, half goal is achieved. Otherwise, poor you. Ask Ubuntu or Windows.
Then create a new directory and a new file.
ls -l to check their ownership and permissions. The ownership should be your user name and primary group as usual. The permissions should match the
umask. Now restart your computer and boot into Windows. Locate on the shared NTFS partition the directory and file you just created on Linux. Check their properties to see if they are assigned to your Windows account. If they are, congratulations, you are all done. Otherwise, bad luck. Ask Windows or Ubuntu.