Windows File Junctions, Symbolic Links and Hard Links

For a long time Linux and Unix have had the marvellous ability of allowing user created links on their file systems. These links are file and folder pointers that are sorted and registered by the operating system file partition. But unlike the more common Microsoft Windows short-cut, programs that encounter user created links will treat them as the source file or folder.

This is advantageous for a number of reasons especially if you use multiple partitions on your computer. I for example keep all my work related files on a separate partition labelled as the W: drive. This allows me to optimise searches and backups as well as keeping the partition more secure from potential problems.

Part of my work involves web development and for testing often the files I am working with need to be located within a web server’s root directory. But this can be problematic if the server application is installed on the C: drive. So a hard link is useful as I can create a pointer from the server root directory and target it to the folder containing the project files on the W: work drive. Once the project is completed the hard link can be removed which would sever the link to the testing web server without the need to move any files.

The Windows NTFS file system has supported some form of file and directory pointing since Windows 2000. Unfortunately each revision of Windows until Windows Vista has used a different method of implementing these pointers. So for this article I will just focus on Windows Vista and the identical Windows 7/8 implementations.

In Windows what is the difference between a short-cut, a symbolic link (sym-link) and a hard link?

short cut is a file that points to another file. It is an antiquated pointing system from the Windows 95 era that many programs do not recognise. Short-cuts do not only use up space on the hard drive, they also break and linger behind after the target has been deleted, renamed or moved.

A symbolic link is like a short-cut but instead of being saved as a file it is registered to the hard drive partition. It does not use any disk space and all programs recognise both the link and the target. A symbolic link can point to any file or folder either locally on the computer or over a network using a SMB path.

A file hard link is a little different and can not be used over multiple partitions meaning you can not have a link on drive C: pointing to a file on drive D:. A file hard link points to and duplicates a target as a mirrored copy but the copy does not use any additional space on the hard drive partition. So 2 hard links that mirrored a 1 GB file would  in total only use 1 GB on the partition rather than 3 GB. Importantly if either the hard links or the target are deleted the other links retain the data. Changes to the content of either the target or the links automatically propagate to all other items.

A junction behaves like is a hard link for directories but unlike file hard links you can create junctions that span multiple partitions. Again a directory junction and its content is stored on the hard drive partition but they do not use any additional space. Any changes to the content within either the target or the links will automatically propagate except where the target directory is deleted or renamed. In that case all hard links that point to the target will break and linger on the partition.

Microsoft Windows Vista, 7 and 8 use the command line program mklink to create links. It has 3 arguments and requires both a link name and target.


There are 4 modes for mklink which counteract each other so you can only use at most a single argument.

Supplying no arguments creates file symbolic link which is a pointer to a file.

/D creates a directory symbolic link which is a pointer to a directory.

/H creates a file hard link and is best used in situations where you need multiple mirrors of a file.

/J creates a directory junction which is a directory link that mirrors a the target directory over the same or on a different hard drive partition.

The word mirrors in this context means the live duplication of the target and the links. Any changes to the structure or the content of any files or any directories will propagate instantly to all links and to the target.

mklink /J WindowsVista C:\Windows

This command would create a directory junction WindowsVista linking (pointing) to the directory C:\Windows

Below is a screen capture of the 4 different types of links in use on Windows. The yellow is a hard file link that does not consume any additional hard drive space. The blue is a symbolic link to a file. The green is a symbolic link to a file directory. While the red is a hard link to a directory which is commonly known as a directory junction.

Windows Vista MKLINK


  1. Hi,

    Your article has helped me clarify a lot of things.

    Thanks in advance!



        1. Ben says:




  2. Robert says:



  3. stone says:


    1. Ben says:


  4. ElTorqiro says:






  5. After a clean install of my Vista 32-bit OS, I am taking the opportunity to redirect my user folders away from the C: drive. It is a process fraught with frustration due to duplication of folders and inability to delete the empty original folders. Although there are plenty of helpful suggestions out there for complex registry edits, this seems a cumbersome and untidy – not to mention risky – approach. So a MKLINK /J redirection from source to my desired partition would be an elegant and convenient ‘solution’, if I can make it work.

    But it’s not working at the moment! From the cmd prompt (regardless of which drive or directory I start from), when I enter I receive error message: ‘Cannot create a file when that file already exists.’

    Could you please advise whether (a) it is possible to create a junction across partitions? And (b) if so, what is the correct syntax?

    Many thanks in anticipation.

  6. Sorry – that should read:


    “mklink /j c:\users e:\users”



    Many thanks in anticipation.

    1. You syntax directory / target syntax looks to be wrong way around, you need do LINK NAME then TARGET. Your example is trying to join E:\users and create the junction at c:\users. But that will not work because you have an existing directory already there.

      Try “mklink /j e:\users c:\users” :)

  7. GOSteen says:

    Okay, everyone seems to have skipped over this so I’m wondering if I’m just not familiar with it because I’m not as used to Windows as I am Linux…

    How did you get the color support in your terminal? Is it a terminal replacement of some sort or some special hack or just some image editing trick?

    Other than that; very decent article. You may wish to know, however, that on most UNIX/Linux systems a symbolic link does, in fact, take up space though it is not much. It is created as a special independent file which takes up a minimal amount of space and acts as a pointer to a different location where the target file may be found. Hard links share the target file’s inode and, as such, don’t take extra space in the filesystem itself. As well, because POSIX-compliant systems follow the ‘everything is a file’ philosophy, there is no distinction between a ‘file’ link and a ‘directory’ link. So one needn’t worry about figuring out how to create a ‘directory junction’ in *nix.

    1. Hi GoSteen unfortunately that screenshot is not a colour terminal rather it involved some post image editing to simply highlight the different types of links. As a Linux user yourself I would highly recommend using Cygwin and combine it with Mintty for a decent terminal for Windows. It also gives you a slew of ported Linux shell apps, full access to your ntfs partitions and most importantly colour.

    1. I did a quick test on Windows 7 and managed to create a symbolic directory link to a shared directory on my local network.

      I ran command prompt as an Administrator and then ran the following

      mklink /d testlink \\NAS\my_shared_folder_name

      I could then cd \testlink and that would take me to the folder stored on the NAS. I hope that helps.

  8. Luke says:

    My computer has an SSD (boot drive) and an HDD (data drive). I have relocated the Documents folder to the HDD, but would like for one small folder (which needs to be be in the Documents folder for some program to work) to be stored on the SSD for decreased latency. If I use a directory junction, will the HDD need to be read to reach the link in the file system? Is there an interim case where the file system is in some chip in the HDD assembly at the end of the SATA cable, but not on the disk that has to spin up?

    1. Sorry for the slow reply Luke I must have mistakenly missed your question.

      I am pretty sure that the junction data will be contained within the NTFS file system on the HDD rather than your target SSD drive. So the HDD containing this junction the target details will probably need to be read at least once. I don’t know if after it has been read for the first time if Windows remembers the target and keeps the information in the system memory.

  9. […] 设置同步。因为这次电脑崩溃让我失去了一些文档，重新配置耗时费力。因此将重要的配置文件同步到网上是非常重要的一步。在这里，我将利用Dropbox(国内的朋友可以使用类似的服务)来同步cygwin中的home文件夹，这样以后重新安装就不需要做重复的配置了。因为Dropbox只支持自己的文件夹，而又不能单纯的把home文件夹拷贝过去，因此我们需要建立文件夹的硬链接。关于链接种类可以参考这里。使用硬链接可以克服dropbox只有一个主文件夹的不便。建立硬链接的命令为 mklink /J C:UsersrexzhaoDropboxCygwinhome c:cygwinhome […]

    1. I have never done it myself nor seen it written about. The System Volume Information directory is specifically used to house Windows System Restore files and databases. Considering the purpose of System Restore is to have a ready fail-safe recovery point in case your operating system, software or some drivers go haywire to be on the cautious side it is probably best not to play around with this. If you don’t need this extra protection and wish to save some disk space you could simply turn System Restore off.

  10. Hello, I have done this a few months ago in windows 7 without issues.
    But currently I am getting an error in windows, as if the junction link is not working.
    When trying to login i get “The user profile service service failed the logon. User profile can not be loaded.”

    E = SSD
    D = HHD
    (as shown from disk part)

    robocopy /copyall /mir /xj E:\Users D:\User
    (no errors, takes about 15secs)

    rename e:\users e:\users.bak (also note i have renamed the folder to something like TESTING) just in case the .bak was confuisng it)

    mklink /J E:\Users D:\Users

    Do a few tests, If i go to E:\users and create a folder, then go to D:\users i see it; all looks good. And still same issue.
    I have done this about 10times to make sure im not being retarded.

    One fishy thing that i have seen, is if i use rmdir e:\users (deleting the junction), then the d:\users should be deleted, but its NOT! It is staying there…

    Anything that i am doing wrong? I swear this is what i did like 6months ago with two normal HHDs…

    1. Well I don’t know if this is a typo in the comment … but you are missing the trailing S on D:\User


      But your symlink is pointing to D:\Users

      mklink /J E:\Users D:\Users

  11. Thank you. I have been searching for 4 hours now just so I could fully understand the difference between SymLinks and hard links. You gave the simplest explanation but gave it enough clarity. Now I can sleep. :)

    Oh, but wait. I do have a question. Is there any way to customize SymLinks so they’ll look distinguishable from the normal shortcut?

    1. In the command prompt there is a visual difference between a shortcut and a symbolic link. The shortcut will always have an file name extension “.lnk” and take up 1+kB while the symlink will not show any file size and instead list “SYMLINK”.

      On the Explorer/Desktop side of things I haven’t found away to visually distinguish symlink icons from those of shortcuts. I don’t think you can as when you open the properties of either a shortcut or a symlink icon they both have a “shortcut” tab. So I think for Windows Explorer and the Desktop it treats them as the same.

      In Windows Explorer if you switch into “list” view, a symlink will always be 0 bytes yet its “Item type” will always share the same as its target. So a symlink pointing to a PDF file will display “Adobe Acrobat Document” as the Item type. While a shortcut will be 2 kB and have an “Item type” of “shortcut”.

  12. Great write up. I am about to buy an SSD drive just for windows and make that my new C drive, then I want to make my new 1 TB HD (e: drive) for the Users, windows\temp, temp, program files, and program files x86 directories. Can you give me the run down of commands to type to use those directories on the hd? I want the SSD drive to basically be read only unless a windows update has to be performed. I want all the usual directories that change alot to be on the HD to limit the reads/writes on the SSD. Thanks in advance!

    1. That is a little out of the scope of this article. Basically you need to manually move all the directories over to your HD E: drive and then presumably create a directory symbolic link or a directory junction at their expected locations on the SSD C: drive. It is not something I have done as theses directories are critical Windows items. So I don’t know how the attempt would succeed as Windows has some inbuilt automatic restoration protections to stop users accidentally messing up their installations.

      It would probably be easiest and safer if you did the change on a fresh, clean install of Windows. If you are trying to do this on an existing install make sure you backup everything before attempting to move those directories!

      This semi-convoluted Life Hacker article might be of help.

  13. This is the best article about symbolic links, shortcuts, hardlinks and junctions I found so far, or at least the one I best understood. Thanks very much Ben.

    I would like to add something about the post where “Robert” mentioned If there was a way of listing all the symbolic link on a computer.

    Well one could use the command promt and enter:

    dir /s /al c:\

    Do this for all the drives you have Juncions, symbolic links and shortcuts. Let’s say you want a listing on your desktop about all the juncitons, symbolic links etc for c: and subfolders:

    dir /s /al c:\ > %userprofile%\desktop\junctions.txt

    1. Thanks for the positive feedback Ricardo I am glad this was useful for you. I just tried out your dir command for listing all links on a computer and it worked perfectly, nice work.

  14. chris2mop says:

    After reading the previous posts, i still have a question about symlinks:
    let’s assume:
    HDD1 C: , D: , E: partitionned
    some users’s dirs on C: mklinked (/J option) to E: partition dirs

    then, because of run out of space on D: partition, i have to resize it (getting additional space from E:)
    are the links preservated after the whole process ?

    and more:
    Expanding D: partition to the rest of HDD1 and adding a new HDD as follow:
    HDD1 C: , D:
    HDD2 E:

    Tks in advance

    1. The links will remain unaffected unless you start deleting data off drive E:. Normally you will only be able to enlarge D: from unused space from drive E:. But your available free space on drive E: and for your symlink targets will be less.

  15. How do you get “DIR” to list JUNCTION, SYMLINK and SYMLINKD? And how do you get the lines in different colors? Did you color it manually or are they actually output like that? That would be really hand if it was possible somehow. Did you use DIR /A switch to get the SYMLINK to show up? In the command window it only says “DIR”.

    1. Hi, unfortunately Windows command line has no colour support. The screenshot was coloured manually for the purposes of this article. There are no additional switches needed with DIR to show the symlinks. If there is a link in the target directory, then DIR will display it.

  16. Hi Ben – this is an awesome article even for a non technical PC user as myself. I do have a question though. If all I am doing is moving my Users folder from C: to D: and wanting the result to be as pain free as possible when it comes to installing apps that may need to write to and refer to the Users folder, is it best to use /j or /d. Keeping in mind that I’d like it to also be pain free when copying, moving and deleting files within the Users folder. (Windows 8)
    Thanks again for a good article and any help you might provide.

    1. Hi Derek, I would recommend just using /d for all directory links unless you have a need otherwise.

      A word of warning for your task of relocating the Windows User folder, you will encounter problems. As the C:\User folder is classed as a critical directory. It is protected by Windows and your symlink to the D: drive will be replaced with a new C:\User directory after your next reboot.

      As a work around you can manually move the sub-directories within a C:\User\[user name] directory. Using Windows (file) Explorer if you right click on C:\User\Derek\Downloads, select the Properties option and then select the Location tab in the Downloads Properties dialogue. From there you can move the location of your downloads to a new drive or directory. It only works for Windows created public sub-directories such as Music, Pictures, Videos, Save Games etc, so it is far from a perfect solution.

      Otherwise if you’re brave you could try following these instructions.

  17. Wonderful article.

    Reading comments, a lot of people, like me, want to move their user folders to their non-SSD. The way I see it, you have two options: Don’t touch it (…PERHAPS link to pictures and music) OR reinstall windows. My system User folder is on my D: drive. Not linked, not in theory. Win 7 installed to C:, Users on D:. It’s not easy to do, it’s not fun, but it is absolutely what people are asking. It can only be done, as far as I know, on a fresh install of Windows.

    These instructions are for windows 8, but they remind me of the steps I took for Windows 7 so I’m guessing it’s pretty much the same. This may not give immediate solutions to people looking for immediate answers, but it might save people planning ahead, if such people exist. It’s just worth showing as an option.

  18. Great article. I have a curly question. I am trying to list the contents of a large hard drive, and used DIR /s piped to a file to grab details, then wrote a small program to parse the output into a regular form which I could import to Access or Excel.

    So far so good, except that the DIR got stuck, I think following the links and going around in circles until I killed it. Analysed the results and found lots of duplicated files and folder names, hence why I suspect links / junctions as the issue.

    Any way you know of to avoid traversing links with DIR /S, or an alternate means of listing all files and folders together with size and date, so I can do some rough and ready analysis on file age, size, types and duplicates? I’m working on a SOE without admin access, and can’t install utilities. I can run exe and scripts which are standalone in nature.

    (In case anyone suggests writing code, I was copying the output file to my notebook on USB key and writing the parsing program on the notebook.)

    1. Hi Simon,

      You could maybe try the Get-ChildItem -Recurse in Powershell and see if you have the same problem.

      Otherwise you could run ‘dir /AL /S D:’ to list only the Junctions/Symlinks etc on the disk drive and then manually delete the ones causing the problem. By the sounds of it you may have a junction or symlink pointing to itself and causing an endless loop?

Leave a Reply


You are commenting using your account. Log Out / Change )

Twitter picture


Facebook photo


Google+ photo


Connecting to %s