Ubuntu – Symlinks to Windows folder breaking


I've got a folder of my work on my Windows partition, which I still use from Windows sometimes, so I can't just move it to my Linux partition. So I've made a symlink (both with ln -s and by right clicking on the folder) which I keep in my Linux documents folder, but whenever I turn my computer off and on again, the link breaks. Is there anything I can do to stop this from happening?

EDIT: I have found a workaround, which is simply clicking into the Windows_OS directory before I go and try and access the symlinks mounts the C: drive and fixes the links, but I'd still appreciate it if anyone knows a way to either automate this or stop them breaking in the first place.

Best Answer

You can add an entry to your fstab so the partition is mounted with the right permissions at boot

You can read some background info on fstab here in Ubuntu help

You will want to mount the drive with read write permission, so you need the filesystem label to be ntfs-3g. First check that you have the package:

sudo apt-get install ntfs-3g

probably it will say you already have the latest version, which is cool.

Next, choose a mount point for your partition. You probably know where it is normally mounted when you open it from your Ubuntu partition. You can either use that mount point, or make a new one. You can call it anything but it should be in /media.

sudo mkdir /media/windows

Now please backup your fstab:

sudo cp /etc/fstab /etc/fstab-backup

To undo the changes any time sudo mv /etc/fstab-backup /etc/fstab

You need the UUID of your windows partition so run

sudo blkid

You will see all your partitions with UUID="VeryLongString-OfLetters&Numbers" You can identify the windows partition by its filesystem tag TYPE="ntfs". Copy the UUID of the partition. Now you are ready to make your new entry in fstab so

sudo nano /etc/fstab

at the end of the file, make a new line with UUID, then the mountpoint you chose, then filesystem type, then options, then two separated zeroes, like this

UUID=that-long-string-you-copied /media/windows   ntfs-3g    auto,user,rw   0   0

the options mean it will mount automatically at boot, and be read & writable by you (not just root) the two zeros are just null options (see the help page linked above). You might want to add a comment (starting the line with #) on the line above for future reference like:

# To make my symlinks persistent

Save the file (Ctrl+X then Y) and exit, then reboot. If you did everything right, you will find your partition at the mountpoint you selected. Make your symlinks again and now they will survive power cycles.