0

I'm trying to make a hard link of my .bash_profile into my dotfiles repo on my HDD. I can't get it to work and I don't know why.

mklink - type - link - target

mklink /H "F:Documents\Repos\dotfiles\.bash_profile" "C:\Users\name\.bash_profile"

This returns the following message "The system can't move the file to a different disk drive"

eternalNoob
  • 307
  • 2
  • 10

1 Answers1

0

Because of the nature of hard links, they cannot be made from one drive to another. Here's Microsoft's documentation on the subject.

Every file is a hard link. A hard link is a name pointing to a piece of data (a file) on a hard drive. For most files there's just one name pointing at one file. When you make a hard link to an existing file you're creating another file path that points at the same file. A hard link points at the data, not at the name.

This is why hard links can only be made on the same drive, drives cannot reference the underlying files on another drive without using the name. To link to another drive you need to use a symbolic link from one filename to another.

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • If I used symbolic links but stored the main file in the dotfile repo on the hdd F drive, then used a symlink in the User directory, would this work? I'm not sure how soft links work, it just points to file? would my bashrc be loaded if it was a soft symlink? – eternalNoob Feb 04 '16 at 00:08
  • @user125047 Yes, it should work fine. A soft link is like a little file that just says "the real file is over here". Most programs will do the redirection fine. The important thing is to ***keep the real file in the Git repo*** otherwise Git will store just the soft link and not the real data. – Schwern Feb 04 '16 at 00:17
  • I thought that might be the case. I have moved the dotfiles into the SSD for now, which isn't such an issue given the relatively small size. But this is useful for future reference! Thanks. – eternalNoob Feb 04 '16 at 00:29