Freigeben über


How to reclaim space after applying Windows 7/2008 R2 Service Pack 1

An often asked question is how to reclaim space after a service pack installation.  We've talked about VSP1CLN and COMPCLN for Windows Vista and 2008.  Now that SP1 is out, it's time to talk about how to do this on Win7/R2.  It's a DISM command now:

DISM.exe /Image:C:\test\offline /Cleanup-Image /spsuperseded /hidesp

NOTE: This command is from the help file and might not be the command you need.  For example, if you're running against an online installation, the command is dism /online /cleanup-image /spsuperseded

You can also use the disk clean up wizard to remove the service pack files.

Of course, either of these will make the service pack permanent which means that you cannot uninstall it from the system once you do this.  So, use this with caution.  As in previous cleanup commands, this will remove any superceded package from the system on the next scavenging pass and reclaim your space.  Feel free to ask questions if you have them.

--Joseph

Comments

  • Anonymous
    January 01, 2003
    Service Packs can not be integrated in Vista ++ operating systems.  So in your case Chris, you'll need to do an online installation, install the service pack, remove the uninstall files, sysprep the image and then capture it.  

  • Anonymous
    January 01, 2003
    No, there is not.

  • Anonymous
    January 01, 2003
    You need a colon between source and the drive letter.  source:c:

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Correct, it has to be contiguous space at the end of the volume you're extending.

  • Anonymous
    January 01, 2003
    You can use the same command against an offline WIM.

  • Anonymous
    January 01, 2003
    @rsr the tip only works if you do it right after the clean installation of Windows. if you add/remove features or install updates you must insert the original install CD. this is the disadvantage of this tweak. to reduce the current folder, compress it with the NTFS compression or get the  Windows Installer Cleanup Utility  and run     msizap G!    to remove unneeded MSI/MSP files. An other tweak is to run     pnputil -e      to get all 3rd party drivers you have in your driverstore folder. Next run pnputil.exe -f -d oem0.inf (replace oem0.inf with the inf of the driver) to remove it. I do this to delete older drivers like the older AMD catalyst driver. The only way to get space is to uninstall older updates which are replaced by newer ones (old cumulative IE, Media Center updates for example)

  • Anonymous
    January 01, 2003
    I was able to run the command successfully, rebooted and confirmed that no back up files were found (see below), but the winsxs folder size has stayed the same at 16 GB.  Any ideas? C:Windowssystem32>dism.exe /Online /Cleanup-Image /spsuperseded Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Removing backup files created during service pack installation. Removing package Microsoft-Windows-UltimateEdition~31bf3856ad364e35~amd64~~6.1.7 600.16385 [==========================100.0%==========================] C:Windowssystem32>dism /Online /Cleanup-Image /spsuperseded Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Service Pack Cleanup can't proceed: No service pack backup files were found. The operation completed successfully.

  • Anonymous
    January 01, 2003
    If the space is contiguous, you just right click the C drive and choose Extend Volume from the menu.  Once you do it should allow you to choose the space you freed up.  If the space isnt contiguous, you wont have anything to choose as free space.

  • Anonymous
    January 01, 2003
    1.) It did find at least one file - "Removing package Microsoft-Windows-UltimateEdition~31bf3856ad364e35~amd64~~6.1.7, 600.16385", but the winsxs folder size remained the same. 2.) SP1 is installed.  Version 6.1 (Build 7601, Service Pack 1)

  • Anonymous
    January 01, 2003
    You'd break stuff more than likely if you did that Jared.  Because at that point the files on disk and the hardlinks to them wouldnt be the same.  I guess in theory you could run SFC /SCANNOW and let it recreate the hard links. I guess my question to you would be this, why do you want to run the command in the first place?

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Sure thing, glad that worked out

  • Anonymous
    January 01, 2003
    I would restart your systems if that's the case.  Running the command again should tell you that the service pack is permanent

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Peter, You might want to run CheckSUR against the machine then to make sure that you don't have any corruption first.  I haven't really seen the removal fail.

  • Anonymous
    January 01, 2003
    LOL, well that is one option I guess ;) Best of luck.

  • Anonymous
    January 01, 2003
    Oh sorry...I did misread that. Have you rebooted the machine since doing that?  Maybe the transactions are pended and need to be flushed out.  Oddly though, it sounds like it actually ran based on the behavior, so I am trying to figure out what is missing.

  • Anonymous
    January 01, 2003
    No problem.  Please dont use Bart's PE, I wont even get into that :) As for making your own, you can actually pull the one out of the Windows AIK, which you can download here:www.microsoft.com/.../details.aspx or you can utilize the WDK and create your own legacy version.  Steps are found here:technet.microsoft.com/.../cc709665(WS.10).aspx --Joseph

  • Anonymous
    January 01, 2003
    Because it was a Vista binary that nothing superseded would be my guess. Have you reclaimed your SP1 space with DISM?  If not, it may go away with that but honestly, I've never really tested your scenario so I am not sure.

  • Anonymous
    January 01, 2003
    Weird, you were running it in an admin cmd prompt before, correct?  Not sure why a shortcut would have changed that behavior, but regardless, glad you got it figured out.

  • Anonymous
    January 01, 2003
    Yup, the ServicePack folder is just the SP3, so if you dont think you'll need it you can get rid of it.   PE is created for downlevel operating systems like WinXP/2003 but it is a part of the installation process with Vista/2008 and later.  So, if you have a Win7 DVD around you basically have PE already, booting it and choosing "Repair my Computer" will boot you into PE with some tools.  We call it Windows RE in Vista and later because its the new recovery environment. Information on WinPE can be found here: technet.microsoft.com/.../cc766093(WS.10).aspx

  • Anonymous
    January 01, 2003
    @ Joscon: Thanks, I'll go read your referred WinPE info. At first glance, PE (pre-installation environment) was intro'd with Vista (or maybe earlier NT Server OSes), so I'm unsure if it might have any meaning for WinXP.  If WinPE encompasses WinRE (recovery environment), the only WinXP analog I'm aware of is XP's WRC (recovery console).  Anywho, WinPE sounds much more-full featured for special installs (eg unattended or vendor customized) than the basic recovery commands in WRC. So is it feasible to create a "WinPE" CD for the dire case that WinXP croaks - How to do it? If so, would a "custom" WinPE CD be required foe each machine, say to capture each machine's hardware-specific drivers and so on (kinda like "BartPE")? TIA when you get a chance, and apologies for my getting so far off-topic.

  • Anonymous
    January 01, 2003
    @ Joscon: Thanks again for your earlier help cleaning up after Win7 SP1! Is there a similar (or likely diffrent) method to reclaim disk space after performing an Online install of Service Pack 3 (SP3) on Windows XP Pro? What do you recommend for post-WinXP SP3 cleanup? Thanks in advance.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    @Joscon: Indeed disk cleanup shows 0 KB of Service Pack backup files to remove. So I've now done Start> Run "dism /online /cleanup-image /spsuperseded" command, but that didn't reclaim any disk space.  Now what? (FYI: my sole username does have Admin privileges - do I need to run the DISM command at some higher level?  If so, how?  BTW I am denied access to view the hidden+system "C:System Volume Information" folder, so I can't look to see if any SP1 backup filesfolders might be stored there).

  • Anonymous
    January 01, 2003
    Sounds like you're probably using the wrong command when attempting to run the command.  What command are you using and are you copying and pasting it or typing it in?

  • Anonymous
    January 01, 2003
    @rsr:  Are you asking if you can delete the Winsxs folder?  If so, the answer is no, you shouldnt delete anything in that folder or you will break servicing on the installation.  Technically you can delete it, but you would be in an unsupported state.

  • Anonymous
    January 01, 2003
    @Al;  That's fair I guess, its also why we moved this into the disk cleanup wizard.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    No files were found because SP1 isn't installed yet.  You're showing Version: 6.1.7600.16385 which is RTM.  This should have been 7601.17514

  • Anonymous
    January 01, 2003
    LOL, dont worry about it, that's what its here for.   To answer your questions, yes, you can remove the service pack files for SP1 but doing so makes the service pack permanent (you can not uninstall it).  You're also correct that you dont have a means to remove the superseded files for individual patches but again, we do some of that automatically for you now anyways so its not the same problem as it would be in 2008/Vista.

  • Anonymous
    January 01, 2003
    12.6GB isnt horribly huge, what file/folder is consuming the majority of that space based on your tools output?  If you need to reclaim the space though, the DISM command or disk cleanup would give you back some space.

  • Anonymous
    January 01, 2003
    @Shannid; Did you install with SP1 integrated media?  If so, this has already been done on the image.

  • Anonymous
    January 01, 2003
    LOL, happens to me all the time.  Just glad to know its working properly.  Let me know if you need anything else.

  • Anonymous
    January 01, 2003
    You're running the wrong command, because you're actively in Windows you dont need the /offline switch.  So, your command is: dism /online /cleanup-image /spsuperseded --Joseph

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    You'd have to extend to free space on the same contiguous disk.

  • Anonymous
    January 01, 2003
    @BMaytum; Sure thing, glad we got most of the SP1 stuff worked out at this point.  As for XP SP3, it's a little easier while being a little more dangerous.  Generally you can delete the $NTUninstallKBXXXXX directories to eliminate space constraints.  The problem with doing this however is that on XP, if you happened to have one a need for one of those files and the machine was down, you'd be in a very, very bad state with no recovery options aside from trying to add them back from WinPE.  Just something to keep in mind. --Joseph

  • Anonymous
    January 01, 2003
    @ Joscon: Yes, I did re-boot (I likewise thought the cleanup might be pended), but on reboot the space was still not recovered. However, I * did* finally get the pre-SP1 Backups purged and recovered aprox 3.6GB free disk space - here's how I did it:

  1. I created a desktop shortcut to open the Command Prompt (set Target= "C:WINDOWSsystem32cmd.exe") with elevated privileges (click Advanced and check the "Run as Adminstrator" checkbox);
  2. Launched the elevated Command Prompt and chose Edit> Paste the stated command "dism /online /cleanup-image /spsuperseded";
  3. that ran the cleanup process (it took about 3+ minutes to run). Here's what was reported in the Command prompt window <quote>: C:Windowssystem32>dism /online /cleanup-image /spsuperseded Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Removing backup files created during service pack installation. Removing package Microsoft-Windows-UltimateEdition~31bf3856ad364e35~amd64~~6.1.7600.16385 [==========================100.0%==========================] Service Pack Cleanup operation completed. The operation completed successfully. C:Windowssystem32> <end quote> (Aside: I duuno why this refers to "UltimateEdition" since my Win7 x64 is Professional version) But I'm happy now that the pre-SP1 Backup disk space is recovered!  Hopefully this will help other people do the same.
  • Anonymous
    January 01, 2003
    @rsr as stated in the WinSxS guides, the WinSxS doesn't consume space (with exception of the files of the branches which is currently not used, the manifest files and the drivers from the driver store) and system restore points are stored in C:System Volume Information.

  • Anonymous
    January 01, 2003
    Yes, you should restart after running this command

  • Anonymous
    January 01, 2003
    You'd be doing an online installation because it was against a running OS.  Maybe I will write something more on the subject. I'm surprised you didnt see it in disk cleanup, if thats the case, run the DISM command you should be good to go.

  • Anonymous
    January 01, 2003
    Interesting, your image version looks like RTM to me.  SP1 is 7601.17514.  I don't have a Win7 install available readily, can you confirm that SP1 is actually installed on the machine?

  • Anonymous
    January 01, 2003
    "Also, so far other than using the cleanup tool, deleting everything in the C:WindowsSoftwareDistributionDownload folder and running the DISM tool with those switches as you recommended. Is that the best I can do to keep Windows lean? By running the DISM tool, I gained about 2GB."


@rsr When you install Windows set the option not store the MSI/MSP files into C:WindowsInstaller: reg add HKLMSoftwarePoliciesMicrosoftWindowsInstaller /v MaxPatchCacheSize /t REG_DWORD /d 0 /f Because this folder is the largest folder on my Windows (14GB vs 7GB for the WinSxS folder)

  • Anonymous
    February 15, 2011
    The comment has been removed

  • Anonymous
    February 15, 2011
    It looks like the command you posted would work on an offline image and one would want to use /online to use it on a running system with 7 SP1.

  • Anonymous
    February 21, 2011
    Is the a similar command for ImageX? Or can I use the same for it (with imagex instead of DISM of course)?

  • Anonymous
    February 22, 2011
    Ok, a tool for removing SP uninstall files on Windows Server 2008 R2.  Great! How about a tool for cleaning up hotfix/patch uninstall files on Windows Server 2008 R2?  Sorry to redirect but I have been searching the web and technet all day and only finding references to cannot delete winsxs and use compcln on windows 2008.  There is no compcln on R2.

  • Anonymous
    February 23, 2011
    Joseph, Thanks so much for your response.  The specific issue is that my windows directories on my Windows 2008 R2 servers are growing at an unprecidented rate.   Since I have the ability to uninstall all of the patches that have been installed to my machines my assumption is that the uninstall files must still be present.  Over the last few years I have only needed to uninstall a patch 3 or 4 times.  We have a fully patched environment, so unless a patch breaks needed functionality, it gets installed and stays installed.  For those few patches that have broken functionality, they have been removed promptly.  It is true that new servers come with larger disk drives, but in my environment not all new servers are physical.  My VM's use costly shared storage that doesn't grow with every new server deployment.  It is amazing how fast a couple of terrabytes can disappear when you are allocating 40GB per to servers that require little or no file storage.  40GB for a DHCP server seems to be unreasonable.

  • Anonymous
    February 23, 2011
    sorry for hijacking your blog.  To simplify things and not create an extended thread in your comments; We can remove service pack uninstall files, right?  That is great, and much appreciated.  Based on your comments it appears there is no tool to remove uninstall files for individual patches.

  • Anonymous
    February 23, 2011
    Never got this working on an offline image. How should the sp1 be integrated and how exactly should the offline image path be in this command? Why theres no index parameter? Sorry buts somethings wrong here, not?

  • Anonymous
    February 23, 2011
    Ok, so I can't apply SP1 to an install.wim from the media?  Bummer.. I've got a domain controller image on the install.wim file (ie: sbs2011 source), and once installed, it can't be sysprepped... so is there any way to slip-stream the SP1 bits onto it pre-install?

  • Anonymous
    February 24, 2011
    I have not tested this method yet so, caveat emptor - How To Slipstream Windows 7 SP1 Into Installation DVD ISO www.intowindows.com/how-to-slipstream-windows-7-sp1-into-installation-dvd-iso

  • Anonymous
    March 15, 2011
    I upgraded my Windows Vista to Windows 7, and SP1. Why is "compcln.exe" still on my system if it isn't anymore the appropriate tool?

  • Anonymous
    March 15, 2011
    Quite frankly these commands are annoying and unintuitive.

  • Anonymous
    April 03, 2011
    I ran this command on my desktop and it worked great.  When I run it on my laptop I get an Error: 87 spsuperseded option is not recognized in this context.  

  • Anonymous
    April 08, 2011
    So this "dism /online /cleanup-image /spsuperseded" command will actually purge the winsxs folder for windows 7 users?

  • Anonymous
    April 08, 2011
    Thats unfortunate. Riddle me this. What would happen if you were to restore an image/backup of just the winsxs folder to... maybe an earlier version of one's computer. What potential harm can be done by trying that? After all your not really deleting files, you're just restoring that folder to a much 'simpler' time. Does that make sense?

  • Anonymous
    April 08, 2011
    I'm concerned about C drive space. It just seemed like over the last few weeks i've been losing a lot of my C drive space--I think I'm down to about '3 GB' according to Windows. I decided to download one of those volume allocation programs (WinDirStat) and its saying that winsxs is consuming about 12.6GB. I understand the concept of hardlinks and how the winsxs folder doesn't technically take up space. But i was hoping to get to the bottom of this volume consumption. Before I found out about the winsxs folder I was perfectly fine with extending the C drive, and i still am. However I've tried several different times and methods, and I can not figure out how to allocate additional space to the C drive. BTW I'm no PC guru by any means, but I like to think of myself as pretty proficient. So if I'm a bit misguided any info you have would be appreciated.

  • Anonymous
    April 08, 2011
    The comment has been removed

  • Anonymous
    April 09, 2011
    I've tried that, using several different programs and no luck so far. I essentially have the 500GB harddrive broken down into two partitions, C & D. So in order to extend the drive, I have to shrink the D drive. So say I shrink the D drive by 15GB, so now I have 15GB of free unallocated space. At this point I should be able to right click the C drive to extend the volume, correct?

  • Anonymous
    April 09, 2011
    no. you also need to move D to the right to make room for extending C and that is afaik an offline operation.

  • Anonymous
    May 02, 2011
    Ok, well thats the part that I'm having difficulty doing. How do I go about making the space from my shrunken D drive contiguous with my C drive?

  • Anonymous
    May 11, 2011
    Finally figured out how to make the space contiguous with the C Drive, using Minitool Partition Wizard. So far that is the best FREE partitioning tool and iz compatible with win7 64-bit. I've now extended my C drive by an additional 10GB to solve the problem, hopefully glutton of a folder (winsxs) folder doesn't dissolve that space too soon.

  • Anonymous
    May 15, 2011
    Hi, It does not work for me :(. Throws an error as below : dism /online /cleanup-image /spsuperseded Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Error: 87 The spsuperseded option is not recognized in this context. For more information, refer to the help. The DISM log file can be found at C:WindowsLogsDISMdism.log

  • Anonymous
    August 25, 2011
    Hello Joseph, Is there a way (and is it ok?) if we can just not have any space taken up by WinSxS folder? This is esp. troublesome on VMs where we can not only have Restore points, but can also take snapshots just in case anything goes wrong and can always revert, so we don't really care about having to revert back if in case a windows update or SP doesn't work out for us. Space is more important with several 20-30GB VMs on a machine. Thanks R

  • Anonymous
    August 25, 2011
    Andre: Thanks for that. Yes, I do know that about restore points which is why "system protection" is off on all the VMs. We rely exclusively on snapshots which is much better strategy I believe. Joseph: Thanks. By unsupported state you mean that no one will help me if I have problems OR does that mean that Windows WILL have problems? Also, so far other than using the cleanup tool, deleting everything in the C:WindowsSoftwareDistributionDownload folder and running the DISM tool with those switches as you recommended. Is that the best I can do to keep Windows lean? By running the DISM tool, I gained about 2GB.

  • Anonymous
    August 26, 2011
    The comment has been removed

  • Anonymous
    August 28, 2011
    The comment has been removed

  • Anonymous
    December 05, 2012
    What can ido when i get Error:87 The source option is not recognized in this context. The DISM log file can be found at D:WindowsLogsDISMdism.log

  • Anonymous
    December 06, 2012
    dism /online /enable-feature /featurename:NetFx3 /All /SourceC:sxs /LimitAccess  .............am using dis command for enabling .NET framework 3.5(included 2.0 and 3.0) in windows 8

  • Anonymous
    December 08, 2012
    ya its working now..thnk u sir

  • Anonymous
    April 02, 2013
    DISM /online /Cleanup-Image /SpSuperseded  after executing this command server restart is mandatory for 2008R2?

  • Anonymous
    May 20, 2013
    I made SP1 permanent on many of my servers, How to check it's already done.Is there any key or clues!!!Please...

  • Anonymous
    May 20, 2013
    Hi joscon [Microsoft] , DISM /online /Cleanup-Image /SpSuperseded  after executing this command server restart is mandatory for 2008R2? Thanks for ur answer on my Q, but in my  env i didn't reboot any of my servers after this command.....

  • Anonymous
    May 20, 2013
    Yes U r correct !!!, by running again it says no backup files to clean up (means SP1 is permanent). In case if i run in normal server it starts clean- up ServicePack1 backup files and make it permanent, i dont wanna take the risk. I need to make sure SP1 is already permanent or yet to do it by looking some values instead running clean-up cmd....Thanks again for your response:):):)

  • Anonymous
    May 27, 2013
    C:Windowssystem32>dism /online /cleanup-image /spsuperseded Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Removing backup files created during service pack installation. [===========================97.3%========================  ] Error: 0x8000ffff DISM failed. No operation was performed. For more information, review the log file. The DISM log file can be found at C:WindowsLogsDISMdism.log C:Windowssystem32>

  • Anonymous
    May 27, 2013
    2013-05-27 21:13:02, Info                  DISM   DISM Package Manager: PID=1748 Package WUClient-SelfUpdate-Core-TopLevel~31bf3856ad364e35~amd64~~7.6.7600.256 with CBS state 7(CbsInstallStateInstalled) being mapped to dism state 5(DISM_INSTALL_STATE_INSTALLED) - CDISMPackage::LogInstallStateMapping 2013-05-27 21:13:48, Info                  DISM   DISM Package Manager: PID=1748  Error in operation: (null) (CBS HRESULT=0x8000ffff) - CCbsConUIHandler::Error 2013-05-27 21:13:48, Error                 DISM   DISM Package Manager: PID=1748 Failed finalizing changes. - CDISMPackageManager::Internal_Finalize(hr:0x8000ffff) 2013-05-27 21:13:48, Error                 DISM   DISM Package Manager: PID=1748 Failed processing package changes with session options - CDISMPackageManager::ProcessChangesWithOptions(hr:0x8000ffff) 2013-05-27 21:13:48, Error                 DISM   DISM Package Manager: PID=1748 Service Pack Cleanup: Internal_Finalize failed. - CDISMPackageManager::SPScavenge(hr:0x8000ffff) 2013-05-27 21:13:48, Error                 DISM   DISM Package Manager: PID=1748 Service Pack Cleanup:Failed to execute SP scavenge. - CPackageManagerCLIHandler::ProcessCmdLine_CleanupImage(hr:0x8000ffff) 2013-05-27 21:13:48, Error                 DISM   DISM Package Manager: PID=1748 Failed while processing command cleanup-image. - CPackageManagerCLIHandler::ExecuteCmdLine(hr:0x8000ffff)

  • Anonymous
    May 27, 2013
    Hi joscon, Thanks for the article here.  I tried cleaning up my small SSD drive but it fails - I have copied the logs and the error.  Can you please help. Mario

  • Anonymous
    June 13, 2013
    Thanks!