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.
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).
Example:
$ 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
UUID="C24C8AB84C8AA72F"
Choose a mount point you want and put it into a bash variable:
MOUNT_POINT="/mnt/DATA/"
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 ~/fstab.save # 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 ~/fstab.save # 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 ~/fstab.save
and
the new one /etc/fstab
to check if everything looks good.
DO NOT reboot until mount -a
works.
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:
WINDOWS_HOME_DIR="$MOUNT_POINT/Users/username"
You can use the attached script to create the links for you:
curl -O https://gist.github.com/aduh95/a7d90afb44688c1b606b58d7e5fd7747/raw/05ab035bbcc9f0afbf168a172c15b2f6e7e320e6/symbolicLinkWithWindows.sh
sh symbolicLinkWithWindows.sh $WINDOWS_HOME_DIR Documents
sh symbolicLinkWithWindows.sh $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.