Saturday 24 December 2016

Running out of space on your system SSD? Meet Junction.

My PC is getting on a bit these days; I got it back when SSDs had got to the point of being reliable, but only just, so it only has a 120GB SSD for a system drive, and a 1TB HDD for storage.  After a year or so I found out that 120GB is very barely enough to run Windows from.  In fact, the only stuff I have on it is Windows and Dota (because Dota had performance issues when run from the HDD). This wasn't always the case: I had previously installed a few applications on it.  To make space by moving them I could have uninstalled them then reinstalled them on the HDD; that's an annoying amount of work.  Worse however; some developers have taken to make their installers totally foolproof, by which I mean they remove any options for the user to make: they install to C: and don't give you another choice (Office 365 does this, as does Oculus).  When you don't have enough space on C: to install them this is problematic.  Happily, there's a Windows command that comes to the rescue: Junction.

Junction is used to make a "junction point" on a drive. A junction point is sort of like a Shortcut to a folder, except it is handled at a much lower level.  To Windows, it's as if the folder it points to is actually at the location it sits in.  With it you can make Windows think a program is installed in C: when it is actually held on D: (or any other drive).

Moving software to HDD

Let's say you have Photoshop installed on your SSD, but it takes up a ton of space that you want to reclaim (because the SSD is full and Windows is starting to choke on not having any free MB). Photoshop will typically be installed in c:\program files\adobe.  To free up the space you could uninstall photoshop entirely, then run the installer again and put it on D:, but that's a lot of time wasted (and potentially a lot of bandwidth if it has to re-download a bunch of stuff).  Instead you can move the adobe folder to D: and use a junction point to make Windows think it's still happily running from C:.  To do this you need to:

  1. Make sure the application in question is not running.  Close all open windows, and make sure it hasn't left any icon in the system tray.

  2. Move the folder from its location on C: (your SSD) to a location on D: (your HDD).  Make a D:\program files folder and then using the right mouse button drag the adobe folder over.  By using the right mouse button, when you release it a menu will pop up allowing you to select Move.

  3. Now you need to make the junction point.  Open the Start menu and type cmd but don't push enter.  When it displays the cmd icon, right-click it and Run As Administrator.  In the cmd window type:

  4. Windows 7

    cd "\program files"
    junction adobe "d:\program files\adobe"

    Windows 10 (Junction command was removed from Windows 10; use mklink instead)

    cd "\program files"
    mklink /j adobe "d:\program files\adobe"

  5. Close the cmd window.  You should now be able to run Photoshop as normal.

Installing to HDD

For a program that only lets you install on C: you either need to make enough room by moving other folders first, or set up the junction before running the installer. For example, Oculus installs in c:\program files\oculus so before installing you can make an oculus folder on D: and then make a junction to it as above; when you run the installer it should see that the oculus folder already exists and install into it.

  1. Make sure there is no folder at c:\program files\oculus.  If you have tried to install and failed it may have left one.
  2. Make folder d:\program files\oculus
  3. In a cmd window:

    Windows 7

    cd "\program files"
    junction oculus "d:\program files\oculus"

    Windows 10

    cd "\program files"
    mklink /j oculus "d:\program files\oculus"

Making Space

If you want to go on a space-saving spree a good program to use is treesize.  This will scan your SSD and display all the folders on it sorted by how much space they are taking up, allowing you to quickly see which ones are worth moving over to the HDD.  You can use this technique on most programs you find in c:\program files and c:\program files (x86), though you should avoid any Windows folders as they can be a bit temperamental.