Copy to another NTFS disk and preserve hard links

hardlinkntfssymbolic-link

I have to copy directory structure from one local NTFS disk to another (Windows 7+) and preserve hard links that exist within this directory structure.

An acceptable solution would be to replace hard links with (relative) symbolic links before copy, but I'm not sure if it is practicable either.

Please note that these are hard links and there would be no problem with copying junction points and symbolic links, the latter could be just copied and fixed later. I don't intend to clone it, just to copy the directory structure—which is a part of the whole disk—to another non-empty disk.

What are the options here?

Best Answer

Tool To Copy Hard Links Across Separate Disk Partitions

LN - Command Line Hardlinks

Example Command: ln --copy x:\dir\dir2 y:\dir\newdir

In the above example the directories and files below x:\dir\dir2 are copied to y:\dir\newdir, and all hardlinks/junctions/symbolic links within x:\dir\dir2 are copied/tied to their new locations under y:\dir\newdir.


Download

enter image description here

Basic Instructions

  • Download the software for your CPU architecture from the applicable zip file, as well as the vcredist (Visual C++ Redistributable) and install it.
  • Then just extract the files and folders from the zip file to a new folder somewhere (.e.g C:\Temp).
  • In command prompt, change to that [directory] folder (e.g. cd /d C:\Temp) and then run the needed commands for your drive locations as the above example command shows.

Note: Running ln --help shows help detail but the above command example is supposed to copy the hard links per the documentation.


Potentially Relevant Functions


Other Notes

It appears hard links are locked to the same disk partition for their file pointers, and cannot be used across multiple partitions. Also, hard links on NTFS partitions are part of the Master File Table records—or attributes for the counts at least—so copying these to an existing disk that has it's own MFT could be a problem if you don't clone byte-for-byte at the partition level at least.