Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for something that works like UnionFS in Windows 7. My usecase: having clean code working directory in a read-only directory, and compiling it in a union filesystem which would store compiled binaries logically in the same place, but physically in different directory.

Libraries do not work this way, even though they were accepted as an answer in -- they only show top-level directories in one place.

The code itself is huge (2GB of data), and I'd like to avoid copying it for every build in my build server.

share|improve this question
Oh, oops. :-/ I'm trying to solve the exact same problem myself, and did not read nearly carefully enough. I'll delete my comment. I have virtually no familiarity with the Windows platform. :-/ – Omnifarious Feb 7 '12 at 13:04

Could you use symbolic links to fake this? It's not answering the exact question but I think it will solve the use case you've given.

share|improve this answer
I don't see how could it... could you explain? – liori Sep 7 '10 at 13:29
I don't know the way your build tree is structured but assuming it's something like src, src/bin, src/obj, then you can have bin and obj be symbolic links to wherever you want to the code to be. Just make sure your build isn't deleting those folders completely. Alternatively have src be the symbolic link to the "read only" then have the links in the read only go back. Either way you should be able to make it work. Unless i'm completely missing your scenario. – MikeBaz Sep 7 '10 at 15:50
I don't control the build procedure, and it can write everywhere. – liori Sep 7 '10 at 15:57
@liori: for this use case, you could reproduce the directories and create symbolic links for every file (something like cd SOURCE; find -type d -exec sh -c 'cd BUILDDIR && mkdir "$@"' _ {} +; find -type f -exec sh -c 'mklink "$1" "BUILDDIR/$1"' _ {} \; or some Windows equivalent). – Gilles Sep 7 '10 at 19:03
@Gilles: you make me think copying isn't that bad solution... (besides, could you make it into an answer?) – liori Sep 7 '10 at 20:31

You can make a poor-man's unionfs with symbolic links: reproduce the directory structure of the source, but make links (symbolic or hard) for the files. This should be suitable for your purpose as long as the build system doesn't try to modify source files.

With GNU cp, it's as easy as cp -al or cp -as. But I don't know if there is a port of GNU tools that understands Windows links.

If you need to call the mklink command, it can be done with POSIX tools (warning, typed directly into the browser):

find -type d -exec sh -c 'cd BUILDDIR && mkdir "$@"' _ {} +
find -type f -exec sh -c 'mklink "$1" "BUILDDIR/$1"' _ {} \;

I suppose there is a native Windows way involving Powershell, but I have no idea what it looks like. It might be worth investigating if your directory tree is large and your disks are fast because forking under Windows tends to be slow, and the commands above need to fork a lot.

share|improve this answer
The native way would be something like for /R %BUILDDIR% %F in (*.*) do @junction X:%pnxF %F, using the junction tool from sysinternals. – MSalters Feb 7 '12 at 14:49
@MSalters Symbolic links are native to Windows now. And NTFS junctions are not the same thing. – Nick Whaley Oct 14 '15 at 13:53
@NickWhaley: Indeed, junctions are essentially hard links. – MSalters Oct 14 '15 at 14:00

I found this, but I don't really know how well it works:

share|improve this answer

Yes there is in recent versions of Windows, but I don't know how to use it.

share|improve this answer
"UWF is a new feature for Standard 8, and is not available as part of Windows 8." Unlikely this is available in end-user Windows versions. – Daniel B Nov 21 '15 at 23:38
@DanielB It seems to be available for enterprise in Windows 10 too. – Mehrdad Nov 22 '15 at 0:01

You must log in to answer this question.

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