A single NTFS file can be "hard linked" to multiple directory entries; all the directory entries (e.g. A, B, C) point to the same data. If a change is made to this single file (e.g. A), all the entries (A, B, C) now refer to the same changed data. But what if you don't want the data for B to change? Is there a way to make Windows write the changed A data to a new file, leaving B to refer to the same unchanged data? For example, the changed A data could be written to a new file automatically; or the user could be warned and given the choice whether or not to link the other directory entries (B, C, etc) to the new data. I do see that if you make B read-only, then you can't write to A, and you'd have to save changes to A to a new name. But I'd prefer that changes automatically be written to a new file, or a prompt to write to the old file.
-
3Short answer: No, what you want is not possible.– DavidPostill ♦Jan 9 at 16:52
-
3In general some tools can break hard links by saving to a new file and moving the new file to the old name (example), possibly conditionally (example). It's courtesy of the tool though.– Kamil MaciorowskiJan 9 at 18:28
-
1Why not just make a copy of the file?– PhilippJan 10 at 14:45
-
2I guess you can always delete A, then rewrite it. This will leave B and C intact. But this would be a deliberate choice for your program to make and doesn't have to do anything with the operating system itself. (This comment is almost identical to @KamilMaciorowski's, except it deletes and rewrites the file without renaming anything).– Guntram BlohmJan 10 at 17:15
1 Answer
This would not be a "hardlink" anymore; it would be called a "reflink" or "copy-on-write link".
Copy-on-write links are not supported by NTFS, as it doesn't support sharing extents between files in general (whereas hardlinks don't just share data, they share the whole file that only has multiple names attached).
Meanwhile, ReFS does support CoW links via block cloning; Microsoft has published a tool for creating them. (Windows only supports ReFS for data volumes, not for the system volume, and AFAIK you need to borrow Windows Server in order to create a ReFS volume.)
Reflinks are also supported on Linux by Btrfs and XFS. They're also supported by Btrfs on Windows using the experimental WinBtrfs, but I've heard reports of WinBtrfs being not very reliable.