Sharing a Partition Between Windows and Linux

Motives

I have been dual booting Arch Linux and Windows 10 for some time now. There are a lot of files that I want to be able to access and modify on both operating systems, ranging from source code to music files.

After digging google for solutions, the most reliable way I've come across is to configure a hard drive partition to be shared among the two systems. Since Windows is terrible at reading or modifying EXT4 (file system commonly used by Linux), we will keep the shared partition in NTFS (proprietary file system developed by Microsoft) and mount the hard drive from Linux after each startup.

This method should work on most Linux distributions.

Mounting a Hard Drive From Linux

After booting, Linux mounts hard drives according to entries in /etc/fstab, which should look something like:

# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/nvme0n1p4 Linux Root
UUID=34346c16-eff9-dead-beef-9bde9ff6e6f3  /   ext4    rw,relatime 0 1

# /dev/nvme0n1p2 Linux Swap
UUID=5ec73324-c806-cafe-babe-068eee1d38cc none  swap  defaults  0 0

Each entry consists of 6 whitespace-separated fields, you can learn more about the entry layouts in man 5 fstab. What we want to do here is to add an additional entry to mount the NTFS drive at boot. After some googling this is what I came up with:

# /dev/nvme0n1p1 Share Partition
UUID=BCE9B718AABBCCDD /home/x2w/Share ntfs-3g defaults,nls=utf8,umask=077,uid=1000,gid=1000,windows_names 0 0

Obviously you will have to lookup your hardware ID, find out the UUID of your hard drives with sudo blkid. My share dirve will be mounted at $HOME/Share. I've also renamed the drive to "E:\Share" on Windows.

In the options we set gid and uid to the default user, you can determine yours with id -u and id -g, respectively. umask is in fact the complement of the permissions you want, which means 077 sets rwx permissions for the owner and zero permission for others.

Since /etc/fstab is maintained by system admins, modifying it requires root privileges. After rebooting you should have your NTFS drive successfully mounted on Linux, create and edit some files in Linux, the changes should reflect in your next Windows session and vice versa.

© 2024 x2w-soda. All Rights Reserved.