symbolic link, hard link e directory junction

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

A 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.

mklink /D /H /J [LINK NAME] [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

Delete junctions with rmdir (rd). Works in all Windows versions.

Posted in Random

Leave a Reply

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


Like it!



Canzoni Marsala – World Of Warcraft