search
top

How To Create SYMLINK’s on Windows 2012 R2 Server Using mklink

Introduction

In this post we will expand more on creating symlink’s to directories and files on a Windows 2012 R2 server using mklink command. This post builds on a previous post on mounting NFS exports on Windows server 2012 R2.

Process

So we have an NFS mount, and now we would like to create a symlink to a sub-directory in the export and also to a sub-directory on a local drive on the Windows server. We are able to achieve this using the mklink command.

Syntax
mklink [[/d] | [/h] | [/j]] <Link> <Target>

Parameters
Description
/d   Creates a directory symbolic link. By default, mklink creates a file symbolic link.
/h   Creates a hard link instead of a symbolic link.
/j    Creates a Directory Junction.
<Link>     Specifies the name of the symbolic link that is being created.
<Target> Specifies the path (relative or absolute) that the new symbolic link refers to.
/?    Displays help at the command prompt.

A few notes about the available parameters.

A junction is not the same thing as a directory symbolic link, although they behave similarly. The main difference is that, if you are looking at a remote server, junctions are processed at the server and directory symbolic links are processed at the client.

It should also be noted that creating a symbolic link requires special privilege (by default, only available to elevated processes) whereas creating a junction only requires access to the file system.

Links and junctions can be renamed and removed as any real folders. System automatically modifies registry and sets the target to be the same for a renamed link as it was on the original link.

So in an earlier post we mounted and NFS export. What we are looking to do is to create a directory symbolic link to E:\MyDirectory\eDocsFiles from a sub-directory called pdfs on our mounted NFS Export I drive. For that to happen we will need use the /d and <Link> <Target> parameters.

Before we run the command you need to make sure the link sub-directory does not exist. From the elevated command prompt type.
mklink /d E:\MyDirectory\eDocsFiles i:\pdfs

That’s all there is to it. With the mklink command we can safely create links in folders and files from NFS exports.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

top