21

I was just wondering how a Windows system handles symbolic links (when created via Linux's ln -s on a filesystem that Windows natively supports and that supports symbolic links, such as NTFS). My best guess is that it will not recognize them, but I'm not entirely sure.

Also, what do Macs do when confronted by one?

2
  • 1
    How do you plan to expose Windows to a symbolic link? It doesn't understand filesystems that support them (except NTFS, which has something not entirely unlike symbolic links that is mostly hidden from the UI). Commented Jan 31, 2013 at 0:57
  • Oh.. so what happens if you've mounted your Windows partition, and you try to put a symbolic link in it? Does it just work as if it were a folder? (If so, I wonder what happens with RECURSION...) Commented Jan 31, 2013 at 0:58

2 Answers 2

20

Depends on the Windows version and the configuration of the server-side when we talk about non-local disks.

Since Windows Vista, Windows does have an idea of symbolic links, but the semantics differ. But the more important problem here should be the path names, which follow a different syntax. For starters: single-rooted directory tree on the unixoid side and several drive letters as roots on the Windows side.

On the unixoid side symlinks are merely text files with a special flag. On the Windows side the underlying mechanism is called a reparse point. This tells the object manager to to pass it to particular registered filters (the meta-date for this is stored in the reparse points). Windows 2000 already introduced one type of reparse points known as junction points (roughly, but not quite, directory symlinks). With Vista they introduced symlinks to both files and directories, also on remote drives. And symlinks on remote drives are also supported to some extent.

The main point is whether the file system driver - when run locally - would do any adjustments to the paths Windows gets to see. In such a case it would work for certain local/relative symlinks. For absolute paths as targets things will get difficult and impossible to deduce what's meant. Same for remote symlinks links (to "network shares").

As for the Mac side I have no idea and it might make sense as a separate question. But as long as the server side conveys the information that this is a symlink, I see no problems, since they both follow the SUS semantics (unlike Windows).


Consider the Linux side mount points:

/dev/sda1 /
/dev/sda2 /home
/dev/sda3 /var

And now consider a symlink /home/paul/fstab pointing to /etc/fstab. They are located on two different volumes which Windows - if able to see them through a file system driver (which does work!) - can't tell belong together the way /etc/fstab describes it. So the link, which Windows would see under a folder \paul\fstab, even if translated, would point to \etc\fstab, which doesn't exist on /dev/sda2. And if that symlink would point to the relative path ../../etc/fstab things wouldn't change at all.


The gist: So while this is conceivable that you can get this to work for some corner cases, the fact that semantics and syntax differ on both sides of the fence makes it unlikely that you will find a practical and generic method that works.

9
  • 3
    Wow, this was a very detailed, thorough answer! Thank you for providing all this information! I actually had no idea that Linux's symlinks were text-based. Thank you again for all the useful information here. Commented Jan 31, 2013 at 1:01
  • can you please help me on this : stackoverflow.com/questions/21403772/…
    – Goofy
    Commented Feb 1, 2014 at 14:02
  • I think I have done a sym-link on XP, are you sure that vista was the first? Commented Mar 1, 2015 at 19:33
  • ntfs supports mount points (for if you don't like all those letters). Commented Mar 1, 2015 at 19:35
  • 1
    @JamesTheAwesomeDude Pretty much everything in Linux is text-based. (:
    – GPWR
    Commented May 14, 2023 at 21:42
1

0xC0000022L's answer is thorough for the Windows side of things. The Mac can recognize Linux's symlinks; however Linux cannot recognize aliases made in the Mac's Finder (symlinks created using ln -s work fine).

1
  • 1
    sounds like aliases are the OSX counterpart to shortcuts on Windows (.lnk files). Commented Jun 1, 2016 at 6:36

You must log in to answer this question.

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