Jameser's Tech Tips

Sunday, August 13, 2006

Tip #37: Creating NTFS Hard Links in Windows XP

Today's tip is on creating hard links on Windows XP systems using the NTFS filesystem. Hard links allow you to create an alternate name for an existing file on the same partition.

The hard link itself is simply a reference to an existing file, and points the exact disk location of the original file without actually duplicating the file. The hard link you create can be in a different directory as the original file, or in the same directory using an alternate name, but it must reside on the same partition as the source file.

To create hard links in Windows XP, use the following command from a Command Prompt (Start/Run/cmd):

fsutil hardlink create new_link_name source_file

One of the benefits of creating hard links is that all hard links to a file, as well as the original file, need to be deleted in order to actually delete the original file from the filesystem. So, if you create a hard link to important.doc called hl_important.doc and the original file is deleted, it will still be available by accessing hl_important.doc. If you delete both, then the file will be removed from the filesystem. Keep in mind though that changes to either the original file or its hard links will affect each other. So, if you overwrite important.doc on accident, your hard links will also contain the same overwritten data.

Another obvious benefit is that you can create an easier to type "alias" for a deeply nested but often accessed file. To create a link to C:\Deeply\Nested\File.doc on the root of your C drive, simply use:

fsutil hardlink create "C:\newlink.doc" "C:\Deeply\Nested\File.doc"

If you have any questions on today's tip, please leave comment.


  • At 9/10/2006 2:22 PM, Anonymous Anonymous said…

    Yeah. That's super nice. Except that the resulting link is useless. All it does is copy the file. Show me how you edit the file as opened by a hardlink, and the other hardlinks show the change. It does NOT work.

  • At 9/10/2006 2:48 PM, Blogger Jameser said…

    It should work just fine... This example shows file creation, link creation, modifications to each file/link, and the resulting changes in their contents... Please let me know if you still have problems/questions...

    Thanks for the comment...


  • At 3/26/2008 6:00 AM, Blogger Darren said…

    Hi James,

    was wondering if a similar type of method could be used to perform the following:

    I have 2 partitions that I want remote users to be able to access via FTP. I am using W2K3 and have my FTP up and running but can only have 1 directory listed. I want to be able to list both partitions for my FTP users.

    Any ideas/comments?

  • At 4/13/2008 6:05 AM, Blogger Ondrej said…

    Hi Darren, in case you didn't get it to work yet, I believe the correct way to do it would be to create a directory, and mount into it the two partitions as subdirectories (via Disk Management in Administrative Tools). Then expose the parent directory via FTP.

  • At 9/05/2008 1:13 AM, Anonymous Anonymous said…

    Thanks, it worked.

  • At 9/09/2008 4:27 AM, Blogger maticus said…

    It is possible to create and use hard links on ext2/3 filesystems also,
    using the ext2 IFS:
    and ln from unxutils:
    Works on dual boot OS just fine, however I haven't tested it thoroughly.

    There is also one more nice thing about the ln tool - it can create hard links on NTFS too, and is IMHO much more convenient.

  • At 10/28/2008 7:19 AM, Blogger Hoang Vu Tuan Anh said…

    Can I create hardlink for Folder?

  • At 12/24/2008 6:49 PM, Anonymous Anonymous said…

    it's odd. create a file. make a hard copy. edit in notepad - both act as expected.

    open a command window and use edit.exe on one of the 2 files and the link is broken...

  • At 12/26/2008 8:38 AM, Blogger JMoore said…

    The hard links are not useless. The program editing the file has made a very good decision.

    What most editors do is: when they're ready to save a file, they save the file into a temporary name, and then once it's been completely written, delete the original file and rename the new temporary file into the proper name.

    This means that if for example the disk fills up when the file is half-written, the program can display an error message (disk full) rather than destroying the original file. Which is a good thing.

    It does mean that hard links are less useful for some things, but it doesn't mean that they're broken.


  • At 1/19/2009 10:54 AM, Anonymous PKL said…

    Actually, most editors do not delete the original file, but instead rename
    it to .bak file. This is quite logical, since the .bak file really is the
    original file. And the .bak file will then automatically have the original
    date/time and attributes.

    However, this has the effect that now the hardlink points to the .bak file.
    Or, if you edited the hardlink, the .bak file is now the hardlink and what
    you think would be a hardlink is now a new file. So, indeed, the link is

    Notepad does not create backup files. In addition, it does not use file
    buffering but instead loads the whole file in memory. When you save
    the file, it just overwrites the original file.

    On better editors, the behaviour can be configured.
    For example on Vedit, option -f forces saving over the original file, which
    keeps the hardlinks intact. However, this makes file saving slower since an
    additional copy operation is performed to create backup file.

  • At 2/15/2009 3:54 AM, Anonymous Anonymous said…

    It worked as expected on Vista too. Thanks. Bookmarked.

  • At 4/18/2009 3:14 PM, Anonymous Anonymous said…

    Very useful. Thank you.

  • At 7/31/2009 11:55 AM, Anonymous David Spector said…

    To anyone wanting a hardlink to a directory (a type of folder): nope. To do this you have to create a junction point, which has limited usefulness (see this nice discussion).

  • At 4/07/2010 4:18 PM, Blogger Kimme Utsi said…


    I have testet every way to make an hardlink on my external USB drive in an network from their original folder to an public shared folder on the network. (uShare shared with LaFonera2.0n) Hopefully this utility will help me. :)


Post a Comment

<< Home