💾 Archived View for gluonspace.com › gemlog › auto-mount_ntfs_in_linux.gmi captured on 2023-01-29 at 02:48:23. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
One of the most frequently asked questions by Linux users dual booting is how to automatically mount NTFS partitions. This partition is usually their main Windows installation or a NTFS data partition which needs to be auto mounted whenever they boot Linux. Here's how to achieve this in five easy steps: 1. Become the root user Open a terminal and issue the following command: "su -". You should get a prompt asking for the root password. After entering it, hit the enter key and you'll become root. All the following steps should be performed as root. 2. Install ntfs-3g This step is optional and you only need to perform it if you need the NTFS partition to be writable. In Debian and Debian based systems like Ubuntu for instance you can install the ntfs-3g package with this command: "aptitude update && aptitude install ntfs-3g". If you're running a different Linux distro use its package managing system for the same effect. 3. Create a mount point There must be a mount point for each partition mounted in your system. Therefore, create a directory under "/media". In my case, since I'm auto mounting a shared NTFS I'll call it "share". To achieve this run "mkdir /media/share" replacing "share" with a name of your choice. 4. Find the right NTFS partition device name Run the "fdisk -l" command:
root@uranium:~# fdisk -l Disk /dev/sda: 250.0 GB, 250059350016 bytes 255 heads, 63 sectors/track, 30401 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x97646c29 Device Boot Start End Blocks Id System /dev/sda1 1 1275 10241406 1c Hidden W95 FAT32 (LBA) /dev/sda2 * 1276 5453 33559785 7 HPFS/NTFS /dev/sda3 5454 7542 16779892+ 83 Linux /dev/sda4 7543 30401 183614917+ 5 Extended /dev/sda5 7543 7673 1052226 82 Linux swap / Solaris /dev/sda6 7674 30401 182562628+ 7 HPFS/NTFS
The output is a listing with all the partitions available on your system. Search for NTFS system entries and write down their respective device name. Though you can see two NTFS partitions in my case, I only want to auto mount the last one ("/dev/sda6") which is a data partition I want to share between Windows and Linux. The first one is where my Windows installation actually resides. 5. Edit "/etc/fstab" Finally edit "/etc/fstab" (you can use "nano /etc/fstab" for this) adding the following line where you should replace "sda6" with the appropriate device name in your system and "share" with the name you chose as the mount point:
/dev/sda6 /media/share ntfs-3g defaults,umask=000 0 0
The first field is the partition device name, the second field is the mount point, the third field is the file system type of the partition, the fourth field takes some options to the mount command and lastly the fifth and sixth fields are used by dump and fsck. If you didn't perform step 1 and therefore don't need a writable partition replace "ntfs-3g" with "ntfs". The defaults option is an alias to some sane default options: "rw, suid, dev, exec, auto, nouser, async". The "umask=000" option is a quick way to allow all users in your system to access the NTFS partition, however a better way would be using "defaults,umask=007,gid=users" and then adding all the users who should be able to access the NTFS partition to the group "users". That's it, from now on whenever you boot into your Linux system the NTFS partition will be automatically mounted under the desired mount point.