1

I have C:\HardDrive1\name\ and D:\HardDrive2\name. I want to make (at least read-only) access to these folders at I:\name (for example). Is this possible at Windows? Also I'm interested is there UNIX way to do it?

ShyMan
  • 245
  • 3
  • 8
  • windows 7 (and possibly vista) has symlinks. older windows has junctions. In this case, you might want to be specific about versions. – Journeyman Geek Nov 11 '11 at 06:47

2 Answers2

1

In UNIX, symbolic links. Read the man page for ln (use the -s option). For Windows, use junctions.

David Schwartz
  • 61,528
  • 7
  • 100
  • 149
  • 1
    @ShyMan see also http://superuser.com/questions/67870/what-is-the-difference-between-ntfs-hard-links-and-directory-junctions which has all the most usefull links to the MS info. – Psycogeek Nov 11 '11 at 06:49
1

On Windows 7 and Vista, there is the command line utility mklink to make symbolic links, for the rest, there's junction from sysinternals which creates so called junction points.

Some things to keep in mind:

  • Junctions and symbolic links are softlinks between two directories.
  • Never use recursive deletion tools to remove a junction (Windows 2000, XP), it will delete the files inside the junction first (thus deleting the real files). Use the tool rmdir to delete junction points.
  • If you delete a symbolic link (made with mklink, Windows Vista and 7), just that will disappear.

If you delete the real directory, the junction/symbolic link will be an empty directory from now on.

  • It is MANDATORY that both partitions be formatted as NTFS to make junctions or symlinks.

Usage:

First, create the folder(s) the junction(s)/symlink(s) will point to, in this example, I:\name1 and I:\name2. Junctions need an empty NTFS folder to point to!

C:\>mklink /d "I:\name1" "C:\HardDrive1\name"
C:\>mklink /d "I:\name2" "D:\HardDrive2\name"

Or, on XP using junction.exe

C:\>junction /d "I:\name1" "C:\HardDrive1\name"
C:\>junction /d "I:\name2" "D:\HardDrive2\name"
sinni800
  • 3,150
  • 3
  • 23
  • 36
  • Problem is that I don't want create just two links `I:\name1` `I:\name2`. What I really need is to access two (or maybe more) paths from same (virtual) path. Possible solution is to create link (junction) for every file (folder) from `C:\HardDrive1\name` `D:\HardDrive2\name` `Z:\HardDrive1000\name` in target directory `I:\name`. This is works perfectly. But this ugly hack IMO (In my case I need to create 100K links per drive). – ShyMan Nov 11 '11 at 07:22
  • You can't point two junctions to the exact same folder. My suggestion is, just move the C:\HardDrive1 to c:\HardDrive1000 folders into one c:\HardDrives folder, and junction/mklink that. Now you need only one per drive, and you max out at 26 drives (A to Z) anyway – sinni800 Nov 11 '11 at 07:24
  • @sinni, nonsense. You can point as many links - whether symlinks or junctions - as you want to the same location. (In the end, both are just reparse points containing the textual path of their target, no deep magic. Because of this, and the fact that disks can be moved physically, implementing such arbitrary restrictions is not only unnecessary; it's also impossible.) – u1686_grawity Nov 11 '11 at 10:09
  • @sinni, also, it is *not* mandatory that the *target* filesystem be NTFS; symlinks and junctions are unidirectional pointers to an arbitrary textual path, and while they can only be created *in* NTFS, they can point *to* practically anything (symlinks can even point to network shares). – u1686_grawity Nov 11 '11 at 10:17
  • @sinni, to clarify my first comment: one link can point to exactly one target, but one target can have *any* number of links pointing to it. – u1686_grawity Nov 11 '11 at 10:20
  • @grawity I was trying to say that one folder can only point one link at a target and now have many targets combined – sinni800 Nov 11 '11 at 20:02
  • @sinni: What you said earlier was the opposite, though - you were talking about multiple links to one target, which is possible. – u1686_grawity Nov 11 '11 at 20:09
  • @grawity I said point two junctions to the exact same folder. The junction is the destination of the link for me, the "empty folder", the target. Even though "junction" as in "a different way, a crossing" or something along these lines really goes more to the link itself... – sinni800 Nov 11 '11 at 22:24
  • @sinni: How can a junction point *to* somewhere, and be "the destination of" something, at the same time? (At least in the terminology used by Windows, the junction is the link itself, *not* the target.) – u1686_grawity Nov 13 '11 at 00:21
  • @grawity Yeah, What I said one post before... I kind of got the terminology wrong, English is not my mother tongue actually! – sinni800 Nov 13 '11 at 20:25