See https://superuser.com/questions/343074/directory-junction-vs-directory-symbolic-link/343079#343079 And answer https://superuser.com/a/343079/331605

Poor mans Unified filenames across multiple disks/hosts

I am a superuser/hi/tech user that wants to setup my NAS (aka files) so that they appear with the same filename regardless of where the file lives. Historically, this is simple in UNIX/Linux and impossible with Windows unless you have enterprise level services such as Remote File Systems (RFS, see https://learn.microsoft.com/en-us/windows-hardware/drivers/ifs/introduction-to-remote-file-systems).

What I want is to be able to access the file:

/home/user/mydata/my-dir/file.txt

using the same path regardless of what host I’m on. On Windows I use “OneDrive for Business” which makes it possible to have a shared file system on multiple machines (much like dropbox).

So I can access files using:

h:\users\steranka\MyOneDrive\my-dir\file.txt

On any system I’m working on and it updates the same file on all of my machines (that have OneDrive) and all of them have OneDrive in one way or another!

In Windows, I’ve learned how to achieve this using OneDrive and NTFS symlinks and NTFS Junctions. To do this, I setup %USERPROFILE%\MyOneDrive as a link to wherever I have my OneDrive for Business installed and running. In some cases it is on the same host, and same file system (e.g., %USERPROFILE%\OneDrive - Steranka Enterprises). In other cases OneDrive is on a separate disk (on a given host), and in some cases I don’t have OneDrive installed and I use another hosts OneDrive installation to allow access to the files.

So How do I set this up so that regardless of the host, the filename appears the same?. I use NTFS Symlinks and Junctions. The way I do this is described below, but the pattern is:

LOCALHOST
c:\users\steranka\MyOneDrive => POINTS to wherever I want to access ONEDRIVE

Below it is explained.

Setting up OneDrive so all names are consistent across multiple hosts

Setting up OneDrive so it works with default installation (on laptop)

I point MyOneDrive to where it needs to go. In this example, it points to C:\users\steranka\OneDrive - Steranka Enterprises directory using this command:

mklink /j c:\users\steranka\MyOneDrive "C:\users\steranka\OneDrive - Steranka Enterprises"
subst h: c:\

That is all that is needed to make OneDrive work on a laptop with my h: drive shortcuts.

Setting up OneDrive on pc22 (Now pc29) (OneDrive on remote share)

To make this work I need to point H: drive’s MyOneDrive to the local hosts MyOneDrive. When I’m on pc22, the following command does this:

cd r:\h\users\steranka
mklink /j MyOneDrive "c:\users\steranka\MyOneDrive"

NOTE: that the subst command is used as follows:

subst H: R:\h

So when I’m on pc22, I’m accessing files from r:\h\users\steranka as h:\users\steranka.

Next the c:\users\steranka\MyOneDrive must point to the remote share. This is done using these commands but they must be run as admin because it requires created a symlink from a local to a remote share. Next, Become admin and enable symlinks from remote to local and local to remote.

fsutil behavior query SymlinkEvaluation
fsutil behavior set SymlinkEvaluation R2L:1
fsutil behavior set SymlinkEvaluation R2R:1
rem fsutil behavior set SymlinkEvaluation L2R:1

Next, As admin, create the link so c:\users\steranka\MyOneDrive points to wherever OneDrive is on the local host. On pc22, we are using vdev3’s OneDrive which is shared via the share \vdev3\MyOneDrive mklink /d %USERPROFILE%\MyOneDrive o:\

Next, Create the O: share as follows net use o: \10.1.2.96\MyOneDrive /user:pc22\steranka /persist:yes At this point the following links happen: h:\users\steranka\MyOneDrive  c:\users\steranka\MyOneDrive  o:
and O: is mapped to \vdev3\MyOneDrive

How do other directories build on that?

Like this:

cd /d r:\H\users\Steranka
mklink /j "Tasks (Priv)" "r:\H\users\Steranka\MyOneDrive\Tasks (Priv)"
Junction created for Tasks (Priv) <<===>> r:\H\users\Steranka\MyOneDrive\Tasks (Priv)

This allows the h:\users\steranka\Tasks (Priv) directory to access the data on OneDrive.

OneDrive on 2nd Drive in VM

In one VM, I have OneDrive setup on a secondary drive (D:\OneDrive).

Below are the steps: This can be done as non-admin

cd c:\users\steranka
mklink /j MyOneDrive "d:\OneDrive\OneDrive - Steranka Enterprises"

The VM either has h: drive mounted as net use h: \pc22\users_drive or uses subst h: c:\

This provides a great deal of information about the answer: https://stackoverflow.com/a/48586946/3281336


<
Previous Post
Java Install and switch when multiple versions exist
>
Next Post
Maven How To Install Jar Into Local Repository