0

I have found a program that can make you save space by hardlinking files that are actually the same, thus leaving only one copy of the file on the file system with more than one hardlink pointing to it. The program is called hardlink.

This is very nice as I have at last found a way to save space on my backup disk for old backups I have made before I knew about rsync and incremental backups.

After such a lengthy introduction, any reader would expect a question, so here it is:

Would it be safe to use hardlinks to save space on a ntfs partition? The hardlinks would of course be created from Linux, using the hardlink program mentioned above. More precisely, will Windows (any version) be able to then use the files that would have been replaced by hardlinks?

Many thanks

Morlock
  • 6,880
  • 16
  • 43
  • 50

3 Answers3

2

There are hardlinks on Windows. They are created by the CreateHardLink system call in kernel32.dll. As to whether your hardlink program would work over remote shares, I wouldn't know, but a native one or one from cygwin would.

Now the real question is whether or not Windows programs handle them. Even Windows Explorer fails to calculate disk space used for hardlinks correctly.

Joshua
  • 40,822
  • 8
  • 72
  • 132
  • Would you advise against manual hardlinking (using the 'ln' command) of files on a ntfs partition if the goal was then to use them using Windows? – Morlock Jan 13 '11 at 21:18
  • 1
    Just curious what your idea of calculating disk space used for hardlinks "correctly" is; it's not as straightforward as it might seem. – Luke Jan 13 '11 at 21:42
  • Windows explorer adds up the size of all the files without checking inode numbers to see if it encountered the same file twice. – Joshua Jan 14 '11 at 04:46
  • I use hardlinks on Windows, but then again I know what tools do not understand and avoid mixing. Notepad understands just fine. Word breaks rather badly if a .doc file has extra links. – Joshua Jan 14 '11 at 04:47
  • That is probably the most logical approach, but then you run into consistency issues. If the same file is in two different directories, then sizeof(directory1) + sizeof(directory2) != sizeof(directory1 + directory2). Windows is intentionally dumbed-down, so from that standpoint they probably made the least worst choice. – Luke Jan 14 '11 at 16:06
  • @Joshua @Luke Raymond Chen talks about it here: http://blogs.msdn.com/b/oldnewthing/archive/2004/12/28/336219.aspx and although he does raise a number of seemingly thorny issues, I'm sure Joshua would solve the problem with some ease! ;-) – David Heffernan Jan 14 '11 at 19:47
  • Actually UNIX systems have a single answer for almost every one of those questions. Reparse point = symlink: do not descend. When calculating directory sizes, you count each file the first time you encounter it. This means the directory may be less than the sum of its children. Compressed + sparse + alternate data streams count physical size for space consumed. When copying multiple links to a non-supporting destination, copy first link only and spew error messages. Copy ACLs by default if root, explicit only if not root. Be careful handling sparse as most tools don't. – Joshua Jan 14 '11 at 20:08
  • 1
    BTW, even FATxx had something like hard links. But they were called cross-linked files and were a severe error. (SCNR) – glglgl Jul 11 '16 at 17:41
0

I did a small test. Creating a hardlink (using 'ln TargetName LinkName') yields the same file at creation time, but after that the file and the hardlink content change independently. I would therefore discourage any use of unix based hard links on an NTFS partition. Use either an Ext4 partition (linux only) or software adapted for windows-like links on NTFS partitioning (windows software or perhaps some linux software if explicitly mentioned).

Josja
  • 131
  • 7
-5

I guess that the program hardlink will either fail because hard links doesn’t exists on Windows or create Windows shortcuts.

Guillaume Brunerie
  • 4,676
  • 3
  • 24
  • 32