Tuesday, May 5, 2015

HowTo Debian/Ubuntu Linux Auto Mount Windows NTFS File System [ntfs-3g]

I'm dual booting MS-Windows with a Debian / Ubuntu Linux desktop. How can I auto mount a drive containing a MS-Windows NTFS file system on a Linux based systems?

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.



Out sample setup

  1. /dev/sdb1 = NTFS partition (use fdisk -l command to find out NTFS partitions names)
  2. Linux user id = 1000 (vivek)
  3. Linux group id = 1000 (vivek)
  4. Linux mount point = /mnt/ntfs
  5. 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:
Fig.01: Install the ntfs-3g package from the official repositories on a Debian/Ubuntu
Fig.01: Install the ntfs-3g package from the official repositories on a Debian/Ubuntu

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

0 comments:

Post a Comment