- Can Ubuntu work with NTFS file system partitions? Could it read and write its contents? [duplicate]
- Can Linux read NTFS? 6 things to know about Linux and NTFS
- Can you install Linux on NTFS?
- How to use NTFS-3G to read and write NTFS on Linux
- Mount NTFS using NTFS-3G
- How to mount NTFS partition on boot
- Can’t mount NTFS partition because of Windows hibernation
- NTFS mounted disk shows errors or constantly turns into read-only
Can Ubuntu work with NTFS file system partitions? Could it read and write its contents? [duplicate]
Ubuntu is capable of reading and writing files stored on Windows formatted partitions. These partitions are normally formatted with NTFS, but are sometimes formatted with FAT32. You will also see FAT16 on other devices.
General Considerations
Ubuntu will show files and folders in NTFS/FAT32 filesystems which are hidden in Windows. Consequently, important hidden system files in the Windows C:\ partition will show up if this is mounted. Since it is all-too-easy to accidentally modify or delete files which are essential for Windows, it is advisable to mount your Windows C:\ partition as seldom as possible, preferably not at all, or read-only by configuring /etc/fstab (see below). If you have data which you want to access regularly from both Windows and Ubuntu, it is better to create a separate data partition for this, formatted NTFS.
Whether you write to your Windows C:\ partition or a shared NTFS data partition, be aware that if you are using Windows 7, and Windows 7 is in a hibernated state when you write to the NTFS partition from Ubuntu, you will lose all your changes. This is because when Windows 7 is hibernated it writes the system state to a file stored on disk and restores from that file when the system is re-awakened, thus restoring the whole fileystem to a state before any changes made from Ubuntu. In Windows 7 you must avoid using hibernation. With Windows 8, the situation is more complex in that, by default, it uses a hybrid hibernation/shutdown when you shut the system down. Any changes made by Ubuntu will be lost when you reboot into Ubuntu.
With both Windows 7 and Windows 8 (when installed to a legacy mbr partition table) there is usually a 100-200MB boot partition labelled «SYSTEM». Do not mount it — you do not need to. Similarly it is highly advisable to leave any recovery partitions unmounted.
Can Linux read NTFS? 6 things to know about Linux and NTFS
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
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.
- sudo blkid
- 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
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.
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.