Click here to Skip to main content
14,173,149 members
Click here to Skip to main content
Add your own
alternative version

Stats

1.3K views
Posted 15 May 2019
Licenced CPOL

The eternal battle with disk space

, 15 May 2019
Rate this:
Please Sign up or sign in to vote.
From the earliest days of my youth, we have always battled with finding space to install “stuff” on our computers.  Whether it was fragmentation, whittling down all the unnecessary things we don’t need or just plain burring millions of cat pictures to CD’s, we always needed more space.

image

From the earliest days of my youth, we have always battled with finding space to install “stuff” on our computers.  Whether it was fragmentation, whittling down all the unnecessary things we don’t need or just plain burring millions of cat pictures to CD’s, we always needed more space.

Technology caught up and gave us bigger hard drives and suddenly we had the space we needed, but access was still slow and as software got bigger, it got slower.

 

Then came the herald of SSD’s, the promise of speed. Our machines got quicker, programs loaded faster and the world sped up to keep pace.  However, we are suddenly again scratching for space, these new drives are fast but they are costly in sizes that we now need to install everything.  So we are back to scratching through the dirt to find stuff to move and delete.

 

My battle with space

I develop for so many platforms these days, my hard drive seems to fill up so fast.  It’s a daily / weekly struggle to find the space to install things.  Most things like Visual Studio or VR games have to be on the SSD to perform as fast as they can, while others can happily sit on the old HDD’s chugging along.

However, things like Visual Studio have sooo many components and a lot Can’t be installed in another location (I wish they could), others by default build large caches of information while you are developing (such as NuGet) right with your user profile which is also invariably where you’ve installed Windows, on your fast drive.

But I’m finally making headway after some later research

 

NuGet (saving approx 10gb)

The easiest one to start with is NuGet, by default, creates a global cache in your user profile (which sits alongside your Windows folder). But as of NuGet 3.5, you can now force NuGet to use another folder.  To do this, you simply need to add a new Environment Variable called “” pointing it to a new location.

 

Before you start, you should clear your current NuGet cache from Visual Studio:

 

  1. Open the NuGet package manager using “Tools –> NuGet Package Manager –> Package Management Settings”
  2. Click on the “Clear All NuGet Cache(s)” button. Bang and the cache is gone.

Then to move your cache folder, do the following.

 

  1. Create a new folder where you want your NuGet cache to store downloaded packages, e.g. “D:\NuGetCache”
  2. Open up your System environmental variables
    Settings –> Search “Edit the System Environment Variables” –> “Environment Variables”
  3. Click on the lower “New” button in the System Variables section
  4. Enter a new variable name of “NUGET_PACKAGES” and enter the path to your new folder in the Value field (or click “Browse Directory” and select it

This will tell NuGet to use this alternate folder for its cache. 

 

Microsoft SDKs / Windows Kits (Approx 16gb)

A lot of “stuff” we need for development are the various SDK’s, development kits and platform packages that are used when we are building project, we don’t use them every day and they can take up a lot of space.  If like me you need them ALL, it can get very large.

 

Unfortunately, you can’t just move them as Visual Studio needs them where they are, in fact, I’ve been unable to find any way to specify they could be in another location (feel free to comment if you find a way).  All is not lost however as we can actually move then and fake their location through a feature in Windows 10 called Symbolic links.  Simply put, they are a way to cheat the system and put a link where the files are which automatically redirects to where the files actually are.

 

Warning!!

A fair few articles will suggest Symbolic links for things like user directories and other Windows System folders.  DO NOT DO THIS.  When Windows upgrades the links will be lost and you’ll end up with duplicate data or worse, you’ll not be properly upgraded and things will get broken

 

Symbolic links are useful for storage files or non-system based files to trick the system to think the data is still where it expects.  I found this fantastically useful for the following folders:

 

  • C:\Program Files (x86)\Microsoft SDKs
  • C:\Program Files (x86)\Windows Kits

Both of these contain a lot of information that you will rarely use when building solutions.  If you find other large folders, by all means, repeat this process for them.

 

To get started, simply:

 

  1. Close any applications possibly using the folder you want to move
  2. Cut / Copy the folder to its new location, e.g. C:\Program Files (x86)\Windows Kits –> D:\Windows Kits
  3. Start a new Command Prompt in admin mode ( Start –> CMD –> Start as Administrator)
  4. Run the following command (updating the arguments as required)
    mklink /J “C:\Program Files (x86)\Windows Kits” “D:\Windows Kits”
  5. Profit

If you only copied, you can safely delete the old folder (I just moved mine), once the move is complete!!

 

Now Visual Studio still thinks the files are where it expects, but in reality we’ve shifted them elsewhere, saving oodles of disk space.

 

 

But Wait, there’s more?

I’m still digging through for more little tidbits, but these two tricks alone have already saved me more than I’ll need at the moment and it’s at the balance point of moving low impact data to slower storage against the speed I need for other data.

 

If you find more, let me know and I’ll update this article!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Simon Jackson
Architect ZenithMoon Studios
United Kingdom United Kingdom
Long time game developer / IT maniac.
By day working as a lowly Technical Architect for a healthcare software firm, by night Masquerading as the Master Chief of ZenithMoon Studios.

At heart I'm a community developer breaking down lots of fun and curious technologies and bringing them to the masses.

I'm also a contributor to several open source projects, most notably the AdRotator advertising rotator project for Windows and Windows Phone.

After a hefty break with Windows Phone and Windows 8 I'm heading back to my XNA roots to show how beginners and current XNA devs can take their skills forward with XNA's bleak future.

ID&Xbox MVP & Best selling author
[Mastering Unity 2D Game Development] (https://www.packtpub.com/game-development/mastering-unity-2d-game-development)
[Unity 3D UI Essentials] (https://www.packtpub.com/game-development/unity-3d-gui-essentials)

You may also be interested in...

Comments and Discussions

 
QuestionThe env variable name disappeared in the displayed text Pin
PhilipOakley17-May-19 3:34
professionalPhilipOakley17-May-19 3:34 
Questioncategory? Pin
John Torjo16-May-19 18:38
professionalJohn Torjo16-May-19 18:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190524.3 | Last Updated 15 May 2019
Article Copyright 2019 by Simon Jackson
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid