Is there a difference between the original file and a hard link to it?

3

I'd like to synchronise some configuration files via a file hoster like Dropbox. I could create a hard link in the software's configuration folder and let it point to my cloud storage directory.

When having done that, is there a difference between those two files? I read somewhere that both files are attributes of the file in the master file table and that there would be no difference at all.

On the other hand, on Windows, directory junctions via mklink can be found using dir /AL /S, so they somehow differ from real directories.

Is that correct?

Xiphias

Posted 2014-04-11T18:54:06.887

Reputation: 145

Are you referring to a symbolic link or the actual hard link?

– Raystafarian – 2014-04-11T19:03:08.450

mklink's help says that it creates a hard link to a file using mklink /H. So I am referring to a hard link. I suppose the directory junction is a symbolic link? However, I can use directory junctions just as normal directories, but I cannot use symbolic file links as files as those programs using it complain that they cannot find the file. So I thought those directory junctions would be hard links as well. – Xiphias – 2014-04-11T19:13:12.643

1just to add to accepted answer you can hardlink files, but not directories. On the other hand (AFAIR) Dropbox properly handle junctions so you could link folders with mklink /j – wmz – 2014-04-11T19:40:48.440

Answers

3

No they dont differ. A Hard link is created via mklink /H. Notice the /H switch.

I read somewhere that both files are attributes of the file in the master file table and that there would be no difference at all.

Correct.

If you ommit the /H switch, you create a junction or soft link

A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories, and a junction can link directories located on different local volumes on the same computer. Otherwise, junctions operate identically to hard links.

via msdm

The difference between a junction and a hard link is:

  • hard links must be on the same partition. If you delete the last hard link, the file is deletet.

  • junctions can be on different volumes

Peter Lamby

Posted 2014-04-11T18:54:06.887

Reputation: 362

2Do be aware, however, that some synchronization software (e.g. rsync can do this) will "break" your hard links, where the "updated" file is actually a new one, but your hard link elsewhere still in effect is the old file. I don't know offhand if Dropbox does this, so test that, but if it does you can link to a directory inside your Dropbox folder instead, and that will work fine (I use this method myself, so I know it works). – Kromey – 2014-04-11T19:53:11.817