The New Technology File System (NTFS) is a file system developed by Microsoft in 1995 with Windows NT. You can easily auto mount a hard disk drive partition containing a NTFS using the following method on any modern Linux desktop.[donotprint]
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | Yes |
Requirements | ntfs-3g |
Time | 5m |
Out sample setup
- /dev/sdb1 = NTFS partition (use fdisk -l command to find out NTFS partitions names)
- Linux user id = 1000 (vivek)
- Linux group id = 1000 (vivek)
- Linux mount point = /mnt/ntfs
- Required package : ntfs-3g (3rd generation read/write NTFS driver
A note about ntfs-3g
Type the following apt-get command to install the same:
sudo apt-get install ntfs-3g
Sample outputs:
Auto mounting a drive containing a Windows (NTFS) file system using /etc/fstab
The file /etc/fstab contains descriptive information about the various file systems. You need to edit this file and append the following information.
Step 1: Edit /etc/fstab
Open the terminal application and type the following command:
sudo vi /etc/fstab
Step 2: Append the following configuration
/dev/sdb1 /mnt/ntfs/ ntfs nls-utf8,umask-0222,uid-1000,gid-1000,ro 0 0
A note about the /dev/sdb1 device name
If /deb/sdb1 path will change due to system configuration, I recommend that you use the UUID (Universally Unique Identifier) of the partition. To find the UUID of /dev/sdb1, enter:
sudo blkid /dev/sdb1
Note down the UUID value and update /etc/fstab as follows:
# syntax # UUID="YOUR-UID-HERE" /mnt/ntfs/ ntfs nls-utf8,umask-0222,uid-1000,gid-1000,ro 0 0 UUID="c2dbc0c5-a8fc-439e-aa93-51b0a61372e8" /mnt/ntfs/ ntfs nls-utf8,umask-0222,uid-1000,gid-1000,ro 0 0
Save and close the file.
Step 3: Create the /mnt/ntfs/ directory
Type the following mkdir command:
sudo mkdir -p /mnt/ntfs/
Step 4: Test it
Type the following command:
sudo mount -a df -h cd /mnt/ntfs/ ls -l cp -v "My File Name.Doc" $HOME
Step 5: Unmount NTFS partion
Type the following command:
sudo umount /mnt/ntfs ## OR ## sudo umount /deb/sdb1
Optional: Manual mounting using ntfs-3g cli option
The syntax is as follows to mount /dev/sdb1 to /mnt/ntfs/:
sudo mkdir -p /mnt/ntfs
Mount it:
ntfs-3g /dev/sdb1 /mnt/ntfs
OR
mount -t ntfs-3g /dev/sdb1 /mnt/ntfs
You can mount the ntfs data partition /dev/sda3 to /mnt/data with standard Linux permissions applied :
ntfs-3g -o permissions /dev/sda3 /mnt/data
You can do read-only mount /dev/sda5 to /home/user/mnt and make user with uid 1000 to be the owner of all files:
ntfs-3g -o ro,uid=1000 /dev/sda5 /home/user/mnt
References
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 7 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
It’s worth noting that Windows sometimes makes a small partition at the beginning of the disk and you need to mount the second partition (e.g. /dev/sda2) instead of the usual first one.
I had to figure this out when I was mounting remotely a usb hdd with gpt / ntfs on a debian server.
On a System with often switching configurations it may be helpful to identify the partition by UUID.
sudo blkid
to get something like:
/dev/disk/by-uuid/F656C6B256C67455.
Then replace the /dev/sdb1 from above with /dev/disk/by-uuid/F656C6B256C67455.
The faq has been updated. I appreciate your feedback.
Hi nice article. It previous Ubuntu verions 9.04, 10.04 and 12.04 I used ntfs-config. Can this program be used in later Ubuntu versions, Zorin 9 and Mint 17.1? I can do work using the CLI but I prefer using a GUI application/program as much as possible. I usually only use the CLI as a last resort.
An issue I have with most of the answers to queries on forums etc is that the answers given are almost always the CLI entries. It would be if the GUI route was also given.
Regards
Philip
The “ro” option stands for read only? Is not possible to have a read write mounted NTFS partition?
Hi Franco normally if you manually mount a NTFS partition it mounts as a read/write so you should also be able to do it automatically. The ntfs-config program automounted NTFS partitions as read/write. I am wondering why a person would want to mount a NTFS partition in read only mode in their home folder.
Regards
Philip
The ro and umask-0222 both caught my attention. If I’m not mistaken, that would result in a read-only mount where all the directories and files have read and execute bits set, but not write. I’m not sure why you’d want that.
After reading the fstab and mount pages carefully, here’s what I used and it works great:
UUID=2EE63C53E63C1E11 /mnt/windows ntfs defaults,uid=0,gid=0,umask=0000
Note that I didn’t specify the last two fields. They have reasonable defaults.