Regular IT guy

Just a guy – talking about technology … in an uncomplicated way.

Menu
  • Contact
  • Speaking
Menu

How To: Delete windows.old from Windows Server 2012 R2

Posted on December 16, 2013 by Rick
Share on Social Media
twitter facebook linkedin email

I’ve been updating my various environments from Windows Server 2012 RTM or Preview releases (build 9431) of Windows Server 2012 R2 to the final bits. On some boxes I just use my scortched earth policy of leveling the partitions and starting from scratch – others I will do an install and use the same partition. You get the following dreaded message – which you dismiss and move on.

image

Sure – I’ll just go and delete that directory after a while and go about my merry way.

Unfortunately it is not that easy.

In Windows client environments, you can just kick off a “disk cleanup” routine and have it removed – saving you a dozen or more GB of space. Unfortunately, that Disk Cleanup does not exist in Windows Server 2012 / 2012 R2 Full GUI install, unless you add Desktop Experience.

image

Fear not. Once you have confirmed you need nothing from that old c:windows.old directory structure, you can manually delete it, with a little bit of extra effort.

Here’s how you do it.

1) Download Junction.EXE from Sysinternals. I extracted and saved it to c:source. You will use this tool to generate a list of all the junctions that have to be removed.

2) create a reference file that lists all the junction points and symbolic links in use by opening up a command prompt, changing into C:source and running

junction.exe –s –q c:windows.old >junctions.txt

3) open up PowerShell ISE administrator rights and run the following script to remove all symbolic links and junction points in c:windows.old.

foreach ($line in [System.IO.File]::ReadLines(“c:sourcejunctions.txt”))
{
if ($line -match “^\\”)
{
$file = $line -replace “(: JUNCTION)|(: SYMBOLIC LINK)”,””
& c:sourcejunction.exe -d “$file”
}
}

You should get the following scrolling by…

image

Now it’s some simple taking of ownership, granting rights and deleting windows.old to get your space back.

4) to take ownership use

takeown /F C:windows.old /R /D Y

5) delete c:windows.old – you now have permissions and ownership.

How much space you get back will change based on your particular situation.  My last run at this saved me 15.5 GB of space on my OS drive.

Note: Kudos to Peter Hahndorf’s response on ServerFault.com on which this article was based.

Share on Social Media
twitter facebook linkedin email

3 thoughts on “How To: Delete windows.old from Windows Server 2012 R2”

  1. David Tesar says:
    February 12, 2014 at 09:48

    I noticed in Windows Server 2012 R2 at least – there also is a disk cleanup option now if you choose the “cleanup system files” option for “Previous Windows installation(s)”.

    1. RicksterCDN says:
      March 4, 2014 at 14:26

      That option is not available in WS2012R2 unless you have desktop experience installed. It’s a client functionality.

  2. Francesco Papini says:
    October 16, 2015 at 07:15

    Hi, I have a little doubt, is there any difference between:

    junction.exe –s –q c:windows.old >junctions.txt

    and

    dir /AL /B /S c:windows.old>reparsePoints.txt

    I would then remove the reparse points with “fsutil reparsepoint delete” inside a FOR cicle.

    Regards, Francesco Papini

Comments are closed.

Follow me on Social Media
twitter facebook youtube linkedin

Recent Posts

  • Moved over to Dreamhost
  • Microsoft Azure HPC goodness
  • Whats new in Azure VM Images
  • Whats New in Azure Managed Disks
  • What up with Azure File Sync

Recent Comments

  1. Farhan Sattar on New Year, New Responsibilities
  2. Frederi on Tuesdays with Corey: Seasons Greetings and Until Next Year!
  3. Leon Han on HowTo: Bootable USB Stick for OS Install
  4. Frederi on Tuesdays with Corey: Seasons Greetings and Until Next Year!
  5. Rick Claus [rclaus@MSFT] on Tuesdays with Corey: Seasons Greetings and Until Next Year!

Archives

  • January 2023
  • March 2019
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • March 2014
  • February 2014
  • December 2013
  • October 2013
  • August 2013
  • July 2013
  • March 2013
  • February 2013
  • December 2012
  • November 2012
  • September 2012
  • August 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • June 2011
  • May 2011

Categories

  • Azure
  • Azure 4 ServerHuggers
  • Azure IT Pro News Roundup
  • CH9 Videos
  • CloudOpsAdvocacy
  • Comments
  • Community
  • Debunking Azure Myths
  • Events
  • Helpful Tech
  • How To
  • interviews
  • Microsoft
  • Networking
  • PatchAndSwitch
  • Personal
  • Presentations
  • Security
  • Server
  • TechEd
  • Troubleshooting
  • Tuesdays with Corey
  • Uncategorized
  • Windows 8
  • Windows Server 8
  • Workarounds

©2023 Regular IT guy