Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Auto-mount a NTFS partition on a GNU/Linux system (Windows dualboot)

Dual-boot GNU/LinuxWindows file sharing

You want to use the same files on different environment? Here is how to setup your Linux system.

It is strongly recommended to have a separate partition for every OS you want to have and another partition on which you want to store your data. If you are using UNIX-like OSes only, you can have a /home partition that every OS will share and you don't need this tutorial. However, if you want to use a Windows OS as well, here is what you need to do.

Note: If you have kept your documents on the same partition as your Windows installation (this is default), you can still use the Windows partition as the DATA partition, but that is far from ideal.

N.B.: This shared DATA partition MUST be formated on NTFS if you want to access it from a Windows OS.

Note: Because of NTFS limitation, your files must be on a NTFS partition. That means you'll have to give up on the file-specific permission system for example, every files in your NTFS will have the same permissions (0o777 for the directories and 0o755 for the other files).


THIS AN IMPORTANT ACTION THAT CAN HARM YOUR SYSTEM FOR GOOD. Please don't do it alone if you don't understand what you are doing.

How to

First, get the UUID of the partition:

ls -lh /dev/disk/by-uuid

Pick the partition you want to have mounted automatically and copy its UUID and put it under a variable $UUID. If you don't know which one it is, you can spot NTFS partition by their shorter UUID (because they don't really have a UUID, they use a serial number instead).


$ ls -lh /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 11 Nov 16 22:03 C24C8AB84C8AA72F -> ../../xvda1

Here the UUID of my partition is C24C8AB84C8AA72F


Choose a mount point you want and put it into a bash variable:


Note: If the partition is already mounted, it doesn't matter if you specify a different mount point.

Then we need to modify the fstab file.

cp /etc/fstab ~/ # this is in case something wrong happens
echo -e "\n# Mount shared NTFS partition\nUUID=$UUID $MOUNT_POINT" \
    "ntfs-3g rw,auto,user,exec,fmask=0022,dmask=0000,x-gvfs-show,uid=1000" \
    "0 2" | sudo tee -a /etc/fstab
sudo mkdir -p $MOUNT_POINT
sudo mount -a

Or if you're connected as root:

cp /etc/fstab ~/ # this is in case something wrong happens
echo "" >> /etc/fstab
echo "# Mount shared NTFS partition" >> /etc/fstab
echo -n "UUID=$UUID $MOUNT_POINT ntfs-3g" >> /etc/fstab
echo -n "rw,auto,user,exec,fmask=0022,dmask=0000," >> /etc/fstab
echo "x-gvfs-show,uid=1000 0 2" >> /etc/fstab
mkdir -p $MOUNT_POINT
mount -a


If the last command fails, compare the ancient file saved in ~/ and the new one /etc/fstab to check if every thing looks good.

DO NOT reboot until the commands works.

Dynamic linking (optional)

After that, I can recommand to replace the original Documents and Downloads folders by the one from Windows. First you need to localize the full path of the Windows "home" folder (the one containing the Documents and Downloads folders). It should be something like that:

# replace `usermname` with your Windows account name in the following:

You can use the attached script to create the links for you:

curl -s | bash -s - $WINDOWS_HOME_DIR Documents
curl -s | bash -s - $WINDOWS_HOME_DIR Downloads
# You can link as many files or directories you'd like

Now, if you cd or ls into your Documents folder, you should always see the same content, on GNU/Linux as on Windows.

If ln fails, you can try to kill the graphical interface and execute the remote script from the CLI.

WINDOWS_HOME_DIR=`realpath $1 | sed 's/\/$//'`
TARGETED_FOLDER_NAME=`echo $2 | sed 's/\/$//'`
echo "Deleting folder '$HOME/$TARGETED_FOLDER_NAME' (press y to confirm at each step)…"
echo "Creating symbolic link to '$WINDOWS_HOME_DIR/$TARGETED_FOLDER_NAME'…"
echo "Done!"
echo "'$WINDOWS_HOME_DIR/$TARGETED_FOLDER_NAME' does not exist, aborting!"
exit -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.