I'm using a set of junctions to move my user folder tree to another drive, as my OS install is on a rather small SSD. However, the junctions still appear as if they occupy space on the SSD. Can I do something to change this?


I believe you're looking in the wrong direction here. The representation of junctions is already correct (and if you still changed it to achieve the result you want, junctions could no longer work) – but it's probably not the same kind of representation that you're expecting to see.

Junctions themselves occupy very little space, but so do folders (directories) – if you asked the OS for a folder's size, you'd get a few kB; only as much as necessary to store the file list.

Instead, when programs show the "total size" of a folder (be it in Windows Explorer or du -hs or another app), they actually calculate it manually by listing all the files and adding up their sizes. They do this recursively, by descending into anything that looks like a directory.

The key point is that junctions pass both "is this a directory" and "is this a link" checks, and this is the whole point of junctions. Therefore, if you tried to change this at OS level so that junctions no longer looked like directories, then obviously they could not be used anymore for their main purpose.

So in reality your file manager needs to distinguish junctions (or rather, reparse points) from regular folders, and not try to 'descend' into them when calculating the total size. This is the same as with symlinks in Linux.

You might have more luck with Windows' symbolic links (mklink /d, introduced in Windows Vista) – they're similar to junctions, but might be just different enough to make your file manager program recognize them.

  • This is interesting stuff. Given that I'm using Explorer, would the appearance of the junction to be x GB in size affect how my storage works, rather than how it appears? I'll give the symbolic link a shot later on. Edit: Also, not only is Total size a number of GB, but so is Size on Disk - is that relevant here? – Wolfish Jul 1 '17 at 11:42
  • Noi, it wouldn't affect anything. Explorer calculates "Size on Disk" in the exact same way – adding up all files' "sizes on disk"; the only difference from "Total Size" is that it accounts for compressed files, cluster sizes, etc. dir in Command Prompt would give a more direct answer. – grawity Jul 1 '17 at 16:24
  • (At least Explorer finally recognizes junctions when trying to delete them. Back in WinXP, trying to delete a junction via GUI used to make Explorer delete its target's contents too...) – grawity Jul 2 '17 at 17:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.