NTFS is not supported by default on RHEL 8 / CentOS 8. To make our system able to read and write block devices formatted with this proprietary filesystem, we need to install the
ntfs-3g software, which usually in provided by third party repositories like
Epel. At the time of writing, however, a version of this software source for Rhel8 doesn't already exist, therefore we will see how to install it from source in few easy steps.
- How to build ntfs-3g from source
- How to install ntfs-3g
- How to mount a block device formatted with ntfs-3g
- How to format a block device with the ntfs filesystem
- How to check the ntfs filesystem integrity using ntfsfix
Software Requirements and Conventions Used
|Category||Requirements, Conventions or Software Version Used|
|System||RHEL 8 / CentOS 8|
|Software||The "Development Tools" package group|
|Other||Root privileges to install ntfs-3g|
|Conventions|| # - requires given linux commands to be executed with root privileges either directly as a root user or by use of |
What is ntfs-3g?
ntfs-3g open source software implements full support (reading and writing) for the proprietary
ntfs filesystem created by Microsoft and used in all recent versions of the Windows operating system. Most Linux distributions include the ntfs-3g package in their repositories, however this is not the case for Red Hat Enterprise Linux 8.
On this distribution the package is usually provided by third party repos like Epel (Extra Packages for Enterprise Linux); at the time of writing, however, the Rhel8-specific version of this software source is not yet available. As an alternative solution, we can compile and install
ntfs-3g from source. We will learn how to do in this tutorial.
Installing the build dependencies
To be able to compile and install ntfs-3g, we need to install some dependencies in our system. All we need is usually included in the Development Tools package group. For those of you who are not familiar with the package group concept, you can think of a package grous as a "meta-package", which allows us to install many related packages using just one command. To install the "Development Tools" package group we can run:
$ sudo dnf groupinstall "Development Tools"
In case we installed a minimal version of Rhel8, to be able to unpack the ntfs-3g source tarball we will also need to install
tar which is (surprisingly) not included by default in the set of packages of this type of installation:
$ sudo dnf install tar
Downloading and compiling the source code
Now that we have installed all the needed dependencies, we can proceed further and download the ntfs-3g source code. The source tarball is available at this address. We can combine the
tar commands to download and extract it in just one step:
$ curl https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz | tar -xvpz
After we run this command we should find that
ntfs-3g_ntfsprogs-2017.3.23 folder was created:
$ ls ntfs-3g_ntfsprogs-2017.3.23
The next step is to enter this directory and run the
configure script, which will prepare the source code for the actual compilation:
$ cd ntfs-3g_ntfsprogs-2017.3.23 && ./configure --prefix=/usr/local --disable-static
When running the
configure script we can provide some options which will influence the way the software is installed. One of the most important are
--exec-prefix. The former is used to setup where the architecture-independent files should be installed in the filesystem (by defalt the
/usr/localdirectory). The latter has the same function but for architecture-independent files: by default it's set to assume the same value of
By default, all the files will be installed under
/usr/local, in the appropriate directories: binaries will be placed under
/usr/local/bin , libraries under
/usr/local/lib, etc. To achieve a fine-grained control, it's possible to specify the destination path for each group of files using options as
--bindir. To read all the possible switches we can use when executing the "configure" script, we can lunch it with the
-h option (short for --help).
In the example above we could have omitted to specify a prefix, since we used the default value anyway, but we used another option,
--disable-static, which is needed to disable the use of the static versions of the libraries needed by the program: in short, when
static is enabled (the default), the libraries on which the executable(s) depends, are "merged" into the program at compile time. This setup can have its pros, but will produce larger executables. What we want, instead, is the same libraries to be shared by all the programs who need them.
Launch the command above, and wait until it finishes. The next step is to actually compile the source code running:
The compilation will begin and a lot of messages will be displayed on the screen. Once the task is complete, we can proceed and install the the compiled files. Since the destination specified with
--prefix, we need root privileges to perform the action:
$ sudo make install
The command will copy the compiled files in their destination directories. Binaries and system-binaries (binaries that need super user privileges to run correctly), for example, will be placed respectively under
$ ls /usr/local/bin ntfs-3g.probe ntfscat ntfscluster ntfscmp ntfsfix ntfsinfo ntfsls $ ls /usr/local/sbin mkntfs ntfsclone ntfscp ntfslabel ntfsresize ntfsundelete
The command will also perform some extra steps: some files will be created into the /bin directory and symlinked to /usr/bin:
/bin/ntfs-3g will be linked as
/sbin/mount.lowntfs-3g. Finally, a symlink to
/usr/local/sbin/mkntfs will be created as
/sbin/mkfs.ntfs. Some of this links are necessary in order for the relative programs to be invoked by root without having to specify their whole filesystem location, since, by default only the
/usr/bin directories are included in its
Now that ntfs-3g is installed, we can see how to use it to perform typical operations like mounting and checking a filesystem or format a block device with it.
Mount a block device formatted with the ntfs filesystem
Suppose we have the
/dev/sdb1 device formatted with the ntfs filesystem, and we want to mount it to
/mnt/data. Here is the command that we should run:
$ sudo mount /dev/sdb1 -t ntfs-3g /mnt/data
Notice how we used the
-t switch to specify the filesystem type (ntfs-3g). In case we want the filesystem to be automatically mounted at boot, we must add an entry for it into
/etc/fstab, in this case:
/dev/sdb1 /mnt/data ntfs-3g defaults 0 0
/dev/sdb1is the block device hosting the filesystem,
/mnt/data is the mountpoint to use and
ntfs-3g is the filesystem type. In this case we used the default mount options, but you can, of course, use the ones you need.
Format a block device with the ntfs filesystem
Another operation we may want to perform is to format an existing block device with the ntfs filesystem. The command to run to accomplish the task is:
$ sudo mkfs.ntfs /dev/sdb1
/dev/sdb1 is the block device to be formatted with the ntfs filesystem, which must be unmounted for the operation to succeed.
Check the integrity of the ntfs filesystem
Checking the integrity of a filesystem is a very important operation that also needs to be performed when the filesystem is not mounted. Even in this case the command to run is very simple (here we must provide the full path of the utility since a link to it does not exists in the PATH of the root user):
$ sudo /usr/local/bin/ntfsfix /dev/sdb1
Ntfs-3g provides also other very useful utilities to perform specific operations on a ntfs filesystem. Among the others:
ntfsundelete which is used to recover files removed from a ntfs filesystem,
ntfsresize which let us resize a ntfs filesystem without data loss, and
ntfsclone which is used to clone, image and restore a ntfs filesystem.
Since we installed ntfs-3g from source code, we cannot use the distribution package manager to uninstall it. To remove the files from our system we must first go back into the folder where we compiled the application, which also contains the
Makefile and run:
$ sudo make uninstall
All the previously created files and links will be removed from the filesystem.
Ntfs-3g is an open source set of utilities and libraries used to fully interact with the proprietary ntfs filesystem: it is not included into RHEL 8 / CentOS 8 default repositories, and it is usually installed from some third party sources like Epel. Since at the time of writing the latter is not yet available, in this tutorial we saw how to install ntfs-3g from source code in few easy steps. We also saw how to perform the most common operations on this filesystem: mounting, formatting and checking its integrity.