Best practice for mounting a Windows partition
You can use fmask
and dmask
mount options* to change the permission mapping on an ntfs filesystem.
To make files appear rw-r--r--
(644) and directories rwxr-xr-x
(755) use fmask=0133,dmask=0022
. You can combine this with uid=
and gid=
options to select the file owner and group if you need write access for your user.
* fmask
and dmask
seem to work for the kernel (read-only) driver as well, even that they are not documented in mount man page. They are documented options for ntfs-3g.
First of all this is not how you should use /mnt. That is for doing administrative tasks on a file system temporarily not every system boot.
Because the windows partition makes no part of the running of the Linux system it makes sense to mount it under /media. You may also want to consider mounting it under root / as /Windows to avoid any confusion about /media being for removable media.
As for permissions I would use a group called windows
groupadd -g 1001 Windows
and give it the permissions you want with options like:
gid=1001,umask=022
If you want to use cp and maintain permissions between separate file systems use cp with the -p or -a flag.
Using the mount options uid
, gid
, fmask
and dmask
you can make the entire NTFS filesystem accessible to your regular user account and/or one group. But that is all-or-nothing: as far as the NTFS filesystem is concerned it's like running as full Administrator all the time in Windows, or like doing everything as root in Linux. The ntfs-3g
NTFS filesystem driver can do better than that.
If you're using ntfs-3g
, you can use the ntfsusermap
command to create a user mapping file for your NTFS filesystem(s). The command will help you in identifying the Windows usernames and their corresponding Windows SIDs and associating them to Linux user and group IDs.
In this way, you can associate the SID of your Windows user account to your Linux UID. That way, once you mount the NTFS filesystem with the user mapping file in place at <NTFS filesystem root>/.NTFS-3G/UserMapping
, you can use your regular Linux user account to access the NTFS filesystem exactly as your Windows user account would be able to access. For things you would need Administrator permissions in Windows, you'll still need root in Linux.
This way, you'll get convenient access to your files on the Windows partition, but are still protected from messing up your \Windows
directory by a mistyped command, unless you're running as root.
You might also want to use the windows_names
mount option on the NTFS partitions to prevent you from accidentally creating files with names that Windows cannot access.