Windows drive full? Use junctions! (Windows User Series)


Microsoft Windows is not so bad, is it? But in my experience it can be greedy as it comes to disk usage. Not that this is necessarily always Windows to blame, but also third party software or other reasons.

Whatever the reason is, if it happens you have a problem. But don’t panic, luckily there is something you can do about it!

Disk consumption in Windows is like a glass of water being filled until it would overflow ..
Disk consumption in Windows can be like a glass of water being filled until it would overflow ..


Use cases

But what situations are we talking about? I can give you some examples:

  • Windows updates eating disk space (does the folder “SoftwareDistribution” ring a bell?)
  • Visual Studio 2015 with full mobile development installation taking 40GB for that part only!
  • Software for navigation equipment that does need temporary space for downloading an update but has no way to choose the folder to download it to (my experience was with Garmin).
  • Just lots of huge files in “My music” or “My videos”, where basicly of course, there is no one to blame but you.
  • On a computer with a large amount of memory, having “hybernate” enabled. If you put a computer in “hybernate” all the memory contents is saved to disk, so when you have 16GB of RAM, you will need this amount of free disk space.
  • You have partitioned your disk to a “Windows” and a “Data” partition (aka a C- and a D-drive), but your underestimated the disk space required for the C-drive.
  • Your disk is not full but you want to store user data (documents, pictures, music and so on) on a different drive, e.g. so you can easily restore an image of Windows without copying your user data back after the restore.


Ways to free up disk space on drive C

The are more ways to free up disk space. However I want to focus on one solution, here is a (non-complete) list of things you could do:

  • Compress folders that you do not use frequently. This will save disk space but will cost cpu power when accessing the files in that folder(s).
  • If you have partitioned your disk, increase the size of the C-drive (and therewith decrease the size of the D-drive).
  • Using Windows utilities to free up disk space (can help but is not always you can regain enough diskspace with this)
  • Uninstall programs you do no longer need.
  • Use junctions. This is the solution I will dive into in this blog post.


Using junctions – prerequisites

There is one important requirement when it comes to junctions: you need to have more than one (fixed) disk or partition in your computer. If it is a second physical disk or a second partition on one disk does not matter. And of course you need to have free disk space on that second disk or partition.

So when you have a notebook with only a small sized SSD, and it is full, junctions can not do much for you.

WARNING! Don’t make junctions pointing to folders on removable drives, like USB pen drives, SD cards and so on for system-critical folders, otherwise applications might stop working or Windows would not even start!

Using junctions – how it works


First of all, what the heck is a junction?

I got to know junctions (also called a soft link) as a shortcut for a folder. This shortcut behaves like a folder but redirects all applications that access that folder to a different folder. Cool, hey?

If you want to know more: read more on MSDN

A junction in the Netherlands (Rotterdam)
A traffic junction in the Netherlands (Rotterdam)

Examples of use

An application taking up too much space

Okay, suppose you have Garmin software installed, you have only a few gigabytes free disk space and want to install a Garmin update on your device. Before starting to download and install the update, this is what you can do:

  1. Create a cmd script and store it on your computer (call it e.g. create_junctions_garmin.cmd)
  2. Paste this into the empty cmd file. Adjust the bold folder names if needed.

@echo off
mkdir D:\Junctions
mkdir D:\Junctions\ProgramData
mkdir D:\Junctions\ProgramData\Garmin
echo Please check that the previous step was completed succesfully . . .
echo If errors occurred close the command window WITHOUT PRESSING ENTER ! ! !
xcopyC:\ProgramData\Garmin” “D:\Junctions\ProgramData\Garmin” /E /K /X
echo Please check that the previous step was completed succesfully . . .
echo If errors occurred close the command window WITHOUT PRESSING ENTER ! ! !
rmdir /s /q “C:\ProgramData\Garmin
echo Please check that the previous step was completed succesfully . . .
echo If errors occurred close the command window WITHOUT PRESSING ENTER ! ! !
mklink /j “C:\ProgramData\Garmin” “D:\Junctions\ProgramData\Garmin

3. Run the cmd file as Administrator and check that it runs without errors. Alternatively you could also move the folder including subfolders and files manually and create a cmd script that only contains STEP 4 – CREATE JUNCTION FOR SOURCE FOLDER

If files are locked, maybe you have to reboot and start Windows in Safe mode, then run the cmd script again.

Moving userdata to a different drive

However Windows offers to some extend the possibility to move these folders, in my experience still downloaded files, pictures or documents sometimes are stored on the C-drive. By creating junctions this is not the case.

I recommend to move this user folders manually and create only the junctions with a cmd script.

Warning / disclaimer: However this works fine for me on Windows 7 and 10 and I do not expect any problems if you follow the procedure, please try this at your own risk.

Note: this works also on non-English versions of Windows as the displayed localized folder names (e.g. in Dutch: “Documenten” for “Documents”) are not the actual folder names. So for the junctions you need to use the English names.

This is what you can do (adjust the bold folder names: replace Hans with your Windows username and replace D:\USERDATA with some other folder if you like)

  • Create a folder D:\USERDATA\Hans
  • Create a cmd script and store it on your computer (call it e.g. create_junctions_userdata.cmd)
  • Paste this into the empty cmd file

Note that you can select the folders of your choice, this list is just an example.

mklink /j “C:\Users\Hans\Downloads” “D:\USERDATA\Hans\Downloads”
mklink /j “C:\Users\Hans\Contacts” “D:\USERDATA\Hans\Contacts”
mklink /j “C:\Users\Hans\Favourites” “D:\USERDATA\Hans\Favourites”
mklink /j “C:\Users\Hans\Music” “D:\USERDATA\Hans\Music”
mklink /j “C:\Users\Hans\OneDrive” “D:\USERDATA\Hans\OneDrive”
mklink /j “C:\Users\Hans\Pictures” “D:\USERDATA\Hans\Pictures”
mklink /j “C:\Users\Hans\Videos” “D:\USERDATA\Hans\Videos”
mklink /j “C:\Users\Hans\Searches” “D:\USERDATA\Hans\Searches”

  • Use Windows Explorer to go to the folder C:\Users\Hans
  • Select the following folders while pressing the CTRL key: Contacts, Documents, Downloads, Favourites, Music, OneDrive, Pictures, Searches, Videos.

Note that you can select the folders of your choice, but make sure every folder selected is in your cmd script.

  • Press CTRL+X (Cut)
  • Navigate to the folder D:\USERDATA\Hans
  • Press CTRL+V (Paste)
  • Run the cmd file as Administrator and check that the junctions are created.


For your interest, on the Windows drive the little arrow in the corner of the folder icon reveals that these “folders” are now actually junctions.


Conclusion / Wrap up

With junctions you can replace a Windows folder with a “shortcut” to a different folder.

This can amongst others be handy when you have lack of disk space on the Windows drive.

It is strongly recommended to create only junctions that redirect to folders on fixed drives.

I have explained some examples of how you can use junctions, but you can use junctions for other applications as well. Beware that in some cases files in folders you want to make a junction for can be locked. Stopping the Windows Services or applications accessing those files can help, or starting Windows in Safe Mode (I must admit I did not try this but in theory it should work).

(c) 2016 – Do not steal the contents – spread the link instead – thank you.

Hans Michiels

Hans is an Independent Business Intelligence and Datawarehouse Consultant & Microsoft SQL Server Consultant, working in the Netherlands. He has been working in the software industry since 1996, with SQL Server since the year 2001, and since 2008 he has a primary focus on datawarehouse- and business intelligence projects using Microsoft technology, using a Datavault and Kimball architecture. He has a special interest in Datawarehouse Automation and Metadata driven solutions. * Certified in Data Vault Modeling: Certified Data Vault 2.0 Practitioner, CDVDM (aka Data Vault 1.0) * Certified in MS SQL Server: * MCSA (Microsoft Certified Solutions Associate) SQL Server 2012 - MCITP Business Intelligence Developer 2005/2008 - MCITP Database Developer 2005/2008 - MCITP Database Administrator 2005/2008

More Posts

3 thoughts on “Windows drive full? Use junctions! (Windows User Series)”

  1. OneDrive is not junction-aware. Creating a junction on a small (128GB) drive pointing to a large (2TB) drive and then pointing OneDrive to that junction is not possible when the amount of data in OneDrive cloud is greater than the free space on the smaller drive. This is ridiculous and defies the idea of junctions completely. Moreover, Microsoft are very aware of the issue but they don’t give a damn about fixing it. Shame on you, Microsoft.

  2. There is a workaround. Use the OneDrive folder as the main folder and the original source created as junction.

    onedrive-and-directory-junctions-sync-problems at preining dot info (can’t post the link without been considered spam.)

Leave a Reply

Your email address will not be published. Required fields are marked *