15

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.

3

3 Answers 3

22

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.

4
  • Do you have ideas on how I can get around this?
    – Sandro
    Feb 9, 2011 at 17:04
  • 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: Feb 9, 2011 at 23:21
  • 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
    Sep 24, 2017 at 0:22
  • I could create a junction to directory, and they are in separate drives. Jun 3, 2019 at 8:32
3

If it's Windows 7, you can use symlinks - Steam Mover does just that.

4
  • How is that different from what I am doing now? I guess I can give it a try :)
    – Sandro
    Feb 9, 2011 at 7:31
  • 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
    Feb 9, 2011 at 7:57
  • 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. Feb 9, 2011 at 11:57
  • 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
    Feb 9, 2011 at 17:05
-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.

2
  • I tried those and still nothing. Thanks for the idea though!
    – Sandro
    Feb 9, 2011 at 7:31
  • It's probably the dot-name of the target. Does it work for other files?
    – user3463
    Feb 9, 2011 at 7:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .