Tuesday, February 14, 2017

Elbow Room

Duncan and Trixie cuddling
What do you do when you have an old SQL Server that is running out of space?   Well, you can free up space by deleting unneeded files, add additional space, or buy a new server, right?

Well, we have a server was constantly running out of space on its tiny 50 gig system partition and we were months away from retirement (best case), we've deleted all unneeded junk and there was no possibility of adding space.

I pulled out my favorite tool, SpaceSniffer, which shows disk usage.  Six gigabytes were taken up in the c:\windows\Installer folder.

We had adequate space on the data partition, so the plan was to move the installer folder to the D drive.  Since many software packages need the information in this folder in order to work, we needed to fool them into thinking the folder was still on C.

My Coworker, Mike, remembered an article he saw on Microsoft.  The solution was to create a symbolic link to the folder.  The kicker is that this has to be done at system level, which is higher than just administrator.  After some Googling, here are the steps to do what we did.


  1. Copy the c:\Windows\Installer folder to the D Drive
  2. Delete the c:\Windows\Installer folder
  3. Download the Sysinternals PSTools from https://technet.microsoft.com/en-us/sysinternals/pstools.aspx
  4. Unzip these tools to a folder on the server.
  5. Run CMD as administrator on the server
  6. change into the PSTools folder, and execute PsExec by typing
    PSEXEC -i -s -d CMD
  7. in the new Command Window that opens, test that you're running as system by typing
    whoami /user
    You should see "nt authority\system s-1-5-18"
  8. in the new command window, type
    mklink /d c:\Windows\Installer d:\Installer
    this will create the link, so software that navigates to C:\Windows\Installer will go, instead, to d:\Installer. 
  9. Reboot
Viola, the server now had 6 gig free on C: and was now happy!

Addendum:
Since writing this post, I've had to use this trick at least a dozen times.  I ran into a situation where I have already moved the installer folder and still ran out of space.  I found another folder, the SoftwareDistribution folder(where Windows Updates downloads its updates.) that I could move.

This required an extra step of stopping the WindowsUpdate service before the move, since it may recreate the folder when it is missing.  Once you are done, restart.

I found, however, that despite being an administrator, I didn't have the rights to stop the WindowsUpdate task.

Skip steps 1 and 2 above.  Follow the rest of the steps until step 7.  While in the NT Authority command prompt, type "Services.msc"  this starts the Windows Services console.  Find and stop the Windows Update.  Move the folder (steps 1 and 2) and then proceed.