Windows7 hardlink over two different drives

13

I am trying to create a hardlink on my C drive that points to a file on my D drive. I open up a terminal with Administrator privileges and try the following:

C:\Users\sandro>mklink /H _vimrc D:\sandro-desktop\.vimrc

The error that I get is: The system cannot move the file to a different disk drive.

When I try a softlink I get the issue that for some reason changes to the link contents aren't reflected on the targeted file.

Thank you!

Sandro

Posted 2011-02-09T05:12:46.073

Reputation: 499

How about _vimrc in the destination instead of .vimrc? – ulidtko – 2011-02-09T05:45:41.773

Not an answer, but you'll find good information here, http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html.

– therube – 2011-02-09T08:17:42.577

Answers

20

A hard link is a file system feature that cannot cross a file system boundary. You can't hard link files on C: to D: because they are separate file systems. They might each contain the same type of file sytem (eg. NTFS) but they are separate file systems.

Mike Fitzpatrick

Posted 2011-02-09T05:12:46.073

Reputation: 15 062

The only case when hardlink between C: and D: will work is when they are on the same file system, e.g. subst D: C:\utils (of course, created using Registry to make this subst persistent). – miroxlav – 2017-09-24T00:22:52.010

I could create a junction to directory, and they are in separate drives. – M.kazem Akhgary – 2019-06-03T08:32:00.160

I believe s/different/separate/ would be more apropriate. – user1686 – 2011-02-09T11:03:51.213

@grawity: Yep, agreed. So edited. – Mike Fitzpatrick – 2011-02-09T11:14:42.290

Do you have ideas on how I can get around this? – Sandro – 2011-02-09T17:04:10.590

You could migrate your Windows 7 user profile (or just the My Documents folder) to drive D, then hardlinks will work. If you do this, make sure you use the proper methods in Windows 7 (generally through properties tabs) - don't manually move folders from C: to D: – Mike Fitzpatrick – 2011-02-09T23:21:09.430

3

If its windows 7, you can use symlinks - steammover does just that

Journeyman Geek

Posted 2011-02-09T05:12:46.073

Reputation: 119 122

How is that different from what I am doing now? I guess I can give it a try :) – Sandro – 2011-02-09T07:31:11.733

symlinks works between directories - quite a few of the older junction related options do not. In addition, since there's a neat front end, which tells you the command, its easier to work out what is done. I'm mostly using XP, so i'm not sure if its 'better' but from what i've read, it should do the job you need it to do with the least fuss – Journeyman Geek – 2011-02-09T07:57:53.443

2@Sandro: Technical details: two hardlinks point to the same inode (on Unix; very similar in Windows' NTFS though), which only works within a single filesystem. Two hardlinks are completely identical; there's no "original". A symlink, on the other hand, points to a path, which can be any text in fact. – user1686 – 2011-02-09T11:57:38.380

If that's how symlinks work then how come when I make a change to one file the other doesn't show the changes? – Sandro – 2011-02-09T17:05:22.553

-3

Try this:

mklink /H "C:\Users\sandro_vimrc" "D:\sandro-desktop\.vimrc"

I'm guessing this has something to do with the filename of the target. Try using quotes around the target link.

I think your link has to be a full path as well.

user3463

Posted 2011-02-09T05:12:46.073

Reputation:

I tried those and still nothing. Thanks for the idea though! – Sandro – 2011-02-09T07:31:33.870

It's probably the dot-name of the target. Does it work for other files? – None – 2011-02-09T07:37:54.573