How to Mount an NTFS Partition in Linux During Boot

terminal1If you have a separate partition in your Linux installation where you keep your data, you may want to mount that partition automatically. Instead of mounting it manually by clicking on it in order to access the data stored. For this we will need several things, ntfs-3g, your uid and pid numbers, create a mount point, and finally, edit the fstab file. Note: the fstab file is the “File System” file which Linux reads every time it boots, and when you issue the “mount” command this file is also read and every entry in this file is mounted. This file basically contains mappings of file systems and mount points in the form of /dev/sda# /media/disk. The first being the disk device and second the directory that will act as the mount point. Here’s a complete example of an entry

/dev/sda3 /media/data/ ntfs nls-utf8,umask-0755,uid-1000,gid-1000,rw 0 0

so let’s get started. First install ntfs-3g

sudo apt-get install ntfs-3g

second, find your uid and gid, which if you install the system should be 1000 and 1000

id -u && id -g

third, get your disk number

jorge@nixbox:~$ sudo fdisk -l
[sudo] password for jorge: 
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0008e668
Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1  *         2048  292970797  292968750 139.7G 83 Linux
/dev/sda2       307202048 1953523711 1646321664   785G  7 HPFS/NTFS/exFAT
/dev/sda3       292972542  307202047   14229506   6.8G  5 Extended
/dev/sda5       292972544  307202047   14229504   6.8G 82 Linux swap / Solaris

note the disk number of your ntfs partition sda1 or 2 or 3 as you’ll need it later

fourth, create the mount point

sudo mkdir /media/data

fifth, open the fstab file

sudo gedit /etc/fstab

sixth, add the following entry

/dev/sda2 /media/data/ ntfs nls-utf8,umask-0755,uid-1000,gid-1000,rw 0 0

or if you prefer, just watch this video

Share This!

Leave a Reply

Your email address will not be published.