NTFS is a proprietary file system, which stands for New Technology File System, it has this name because it was made for Windows NT 3.1, while Linux on the other hand has the Extended File System, or ext, which is the file system designed to support Linux.
Linux only supports reading NTFS, it cannot write on the file system, but by using an NTFS implementation called NTFS-3G, you can read and write on NTFS.
Can you install Linux on NTFS?
Linux must be installed in an EXT partition, like Ubuntu, in some situations dealing with NTFS is unavoidable, like the users who use a dual-boot with Windows and want to access another partition.
When using dual-boot, you have a drive or different drivers which will have the NTFS partition for Windows and the EXT partition for Linux, Linux is still installed on the EXT partition, which supports the permission system it has.
How to use NTFS-3G to read and write NTFS on Linux
NTFS-3G is a driver/implementation which will help you dealing with NTFS partitions from your Linux partition. If you have an NTFS partition that you want to write to, you must use the NTFS-3G NTFS implementation.
Before using NTFS-3G check if you have it installed, if not, install it on your system.
How to install NTFS-3G
- To install NTFS-3G on Ubuntu, use:
sudo apt-get install -y ntfs-3g
- Fedora: NTFS-3G is already installed
- Arch Linux, Manjaro:
pacman -S ntfs-3g
- You can get ntfs-3g in almost any distribution!
Caution when using NTFS-3G
This driver implements the NTFS file system and its wrong use may harm your device, read more about it on the MAN page.
Mount NTFS using NTFS-3G
sudo mkdir /mnt/mydata
Creates a folder called mydata to mount the partition
sudo mount -t ntfs-3g /dev/sdxx /mnt/mydata
Use the mount command, using -t to specify ntfs-3g as the type, followed by the device and then the mountpoint.
If you don't know the exact partition you want to mount, use
sudo fdisk -l to list the disks and devices, you can identify the partition using the disk model or its size as a reference.
After mounting, you can access the data in the mountpoint specified, with read and write permissions!
To umount, you can use the umount command with that partition.
How to mount NTFS partition on boot
You can follow these steps to mount your NTFS on boot.
- Copy the UUID of your disk
sudo nano /etc/fstab
- Add the following line to the end of this file:
UUID=the uuid copied above /mnt/mydata ntfs-3g defaults 0 0
- Save the file and reboot
If you have problems with the ownership of the mounted disk, you can use the following:
Umount the disk if it is being used
Use chown to set your user as owner
chown youruser:youruser /mnt/mydata
And mount it again.
The problem with chown is that it will have to be set every time the partition mounts, to change this, change the defaults for the device on fstab to:
rw stands for read and write, users is being used to allow any user to mount this disk, when searching online you will also find the user option, the difference between users and user is that users will let any user umount it, while user will make only the user who mounted the filesystem umount it.
For an external disk you could use something like:
Auto and nofail are being used to not stop the boot process in case of an error with this device, but to mount it if possible, the noatime option will prevent writes when doing reads.
Can't mount NTFS partition because of Windows hibernation
If you get the message 'Metadata kept in Windows cache, refused to mount.', your disk was previously used by a Windows installation, the message is preventing you from doing potential harm to your Windows installation, like locking it in hibernation forever.
You cannot by default mount a partition that had a Windows installation in it, the proper way to fix this is by booting the Windows system and properly shutting down the computer, but if you don't care about that previous installation, there is an easier way to mount the partition.
- Install ntfsfix
ntfsfix /dev/sdxx, remember to specify the disk and the partition
You can also try to fix it using the mount command:
mount -t ntfs-3g /dev/sdxx /mnt/myhd -o remove_hiberfile
The remove_hiberfile does what is needed to allow you to mount the partition even with the presence of the hiberfil.sys file, which holds a flag telling other Operational Systems that Windows is hibernating.
Users report problems with the remove_hiberfile command, which in my machine it turned out that it didn't do anything, what you can do is try to append the -o parameter at the end of the command like above, to attempt fixing the problem.
NTFS mounted disk shows errors or constantly turns into read-only
One bad surprise that you can have is figuring out that after mounting the disk with read-write mode, it randomly and repeatedly turns back into read-only.
The most common reason for the read-only issue is that your disk has problems, Linux turns it to read-only to prevent further damage, even if Windows didn't care about that.
There can be other reasons why your disk is doing this, but spotting this is a good signal to backup your data, and be safe until you figure out the issue.
You can use tools like badblocks and smartctl to further identify these issues, if you are just mounting your NTFS partition for the first time, it could even be a great idea to format it to EXT4 and run some checks to know your data is safe!
Badblocks has destructive and non-destructive modes, and it will report the reading, writing, and comparing errors, the tests don't go easy on your disk, so use it with caution.