From Gentoo Wiki
Jump to:navigation Jump to:search
Not to be confused with NFS.

NTFS (New Technology File System) is a proprietary disk filesystem by Microsoft for Windows and Windows-based operating systems.

There are two primary methods to achieve NTFS support when using Linux. Linux kernel 5.15 provides the new driver NTFSv3 with full support of NTFS filesystem including compression capabilities. There is also a FUSE filesystem driver called NTFS-3G - a slow but more stable and time-tested solution.



Before Linux kernel 5.15, the mainlined old NTFS kernel driver had very limited functional support for NTFS. The kernel configuration information defines support as "partial, but safe". The old driver could overwrite existing files but is not capable of file or directory creation, deletion, or renaming. As of Linux 5.15 the old NTFS code was replaced by new Paragon's in-kernel NTFS driver named "NTFSv3". This driver is more fully featured and supports full read/write and compression capabilities.

Most NTFS users will want to enable the FUSE-powered NTFS-3G implementation for systems running pre-5.15 kernels.

Native support

On Linux 5.15 and later following kernel options must be enabled for new NTFSv3 driver:

KERNEL Enabling new NTFSv3 driver with optional support for reading Windows compressed files (lxz/xpress) (CONFIG_NTFS3_FS, CONFIG_NTFS3_LZX_XPRESS)
File systems  --->
    DOS/FAT/NT Filesystems  --->
        <*> NTFS Read-Write file system support
        <*> activate support of external compressions lzx/xpress

NTFS-3G (FUSE implementation)

The following kernel options must be enabled for NTFS read/write capabilities over FUSE in Linux before 5.15:

File systems  --->
    <*> FUSE (Filesystem in Userspace) support

The sys-fs/ntfs3g package is also required (see the emerge section below).



The following package is only necessary when using NTFS-3G. It is not required for native support!

Because NTFS-3G is a FUSE-based filesystem, it requires user space utilities. It is currently the only FUSE-based implementation available in the main Gentoo repository. Make sure the suid USE flag is enabled, otherwise there may be a "read only filesystem" error.

USE flags for sys-fs/ntfs3g Open source read-write NTFS driver that runs under FUSE

acl Add support for Access Control Lists
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
fuse Enable ntfs-3g FUSE driver
mount-ntfs Install mount.ntfs symlink
ntfsdecrypt Build and install the ntfsdecrypt application.
ntfsprogs Enable ntfsprogs
static-libs Build static versions of dynamic libraries as well
suid Enable setuid root program(s)
xattr Add support for extended attributes (filesystem-stored metadata)

After reviewing USE flags and making adjustments as necessary, install the FUSE user space tools. This will enable the manipulation of NTFS filesystems:

root #emerge --ask sys-fs/ntfs3g



The mkfs.ntfs command irreversibly destroys the contents of the partition it is told to format. Be sure to select the right partition before running this command!

To create an NTFS filesystem on the /dev/sda1 partition (needs ntfsprogs USE flag):

root #mkfs.ntfs /dev/sdyX

Please replace /dev/sdyX with the actual partition you want to format.


There are several ways to mount a NTFS filesystem:

Native support

Using the new native driver NTFS3 (kernel 5.15):

root #mount -t ntfs3 /dev/device /path/to/mountpoint
Running mount /dev/device /path/to/mountpoint may fail even if the ntfs3 driver is loaded, ensure the command is executed with -t ntfs3.


Using the read/write capable driver provided by the ntfs3g package:

root #mount -t ntfs-3g /dev/device /path/to/mountpoint



Force mount NTFS partition after Windows was hibernated

NTFS file systems controlled by Windows may be hibernated instead of cleanly shutdown in order to save on system start times. When this occurs it will not be possible to mount the NTFS partition unless the hiberfil.sys file is removed. The following command can be used to force-mount a hibernated partition, which will result in the hiberfile being removed; all data in the file will be lost. Windows will have to perform a clean boot in order to resume operation:

root #mount -t ntfs-3g -o remove_hiberfile /path/to/device /path/to/mountpoint

On the Windows system, in order to prevent unclean shutdowns from Windows it is possible to run powercfg /h off from an Administrator command prompt. This will disable hibernation which will most likely increase boot times when booting Windows, but has the benefit of cleanly unmounting the drive.

If obtaining Administrator access to prevent hibernation is not possible on a Windows 10 system, then try the following workaround:
  1. Boot Windows to the Windows login screen.
  2. Click the power button (bottom right hand corner), then press and hold the shift key and click Restart.
  3. Choose advanced options, then reboot to the UEFI firmware settings.
  4. Once in the UEFI firmware, choose the appropriate boot entry for Linux.
This should forcing Windows to perform a clean shutdown, which will enable a clean filesystem mount for NTFS-3G.


Occasionally it is necessary to fix an NTFS formatted partition from a Linux system. ntfsfix is the tool for the job:

root #ntfsfix /dev/nvme0n1p3
Mounting volume... $MFTMirr does not match $MFT (record 3).
Attempting to correct errors... 
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... FAILED
Correcting differences in $MFTMirr record 3...OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
Checking the alternate boot sector... OK
NTFS volume version is 3.1.
NTFS partition /dev/nvme0n1p3 was processed successfully.

See also

External resources