How can I shrink a Windows 10 partition?

222,494

Solution 1

There seems to be absolutely no need for any third party software.

I have followed the instructions here, and I successfully shrank my OS partition in about 10 minutes. Running under Windows 10, but I doubt it makes a difference here.

The steps are:

  1. Disable hibernation.

    At a an elevated (admin) command prompt, run the command

    powercfg /h off
    
  2. Disable pagefile.

    Open the System page in Control Panel (from “This PC”/“My computer”, open the Properties). Click “Advanced System Settings”, then in the “System Properties” dialog's “Advanced” tab, open the “Performance” settings, go to the “Advanced” tab, click “Change...” under “Virtual memory”, untick “Automatically manage paging file size for all drives”, select the drive you want to shrink, select “No paging file” and click the “Set” button.

  3. Disable system protection.

    In the “System Properties” dialog as above, go to the “System Protection” tab, click “Configure...” and select “Disable system protection”.

  4. Restart.

Now the three files that were preventing partition reduction are gone. Reduce partition size, and then restore the three items.

If Disk Management complains that “There is not enough space available on the disk(s) to complete this operation.” even though you entered a size that should work according to Disk Management's own figures, see Cannot shrink C: partition: Not enough space

I have later found similar instructions at other places, all of them mentioning only these 3 items.

Solution 2

The interesting fact which often goes unsaid is that after a partition shrink the minimum size is also reduced (of course, if you have free space, defragged, no unmovable files, etc).

I used this method to successfully shrink a System volume (C:) on Windows Server 2012R2 from 500GB (with only 50GB of actual data) to 80GB. The first time I tried to resize it the minimum size was around 425GB.

Tip: If your volume is not a System one you may wish to skip the initial steps (before Restart)

  • Open a Powershell prompt with administrative rights.

  • First, disable settings which can keep unmovable files

    • Disable Pagefile

      wmic computersystem set AutomaticManagedPagefile=False
      wmic pagefileset where name="C:\\pagefile.sys" delete
      
    • Disable Hibernation (desktop Windows only)

      powercfg /h off
      
    • Disable System Restore (desktop Windows only)

      Disable-ComputerRestore -Drive C:
      
    • Restart the computer

  • Defrag (equivalent to defrag C: /L /D /K /G /H)

    Optimize-Volume -DriveLetter C -ReTrim -Defrag -SlabConsolidate -TierOptimize -NormalPriority
    
  • Get the remaining size in GB

    (Get-Volume C).SizeRemaining /1GB
    374,10312271118       # Sample result!
    
  • Resize partition (use the above value plus 2~3GB)

    $part = Get-Partition -DriveLetter C
    $part | Resize-Partition -Size 375GB
    
  • Get the remaining size again. Resize-Partition reduced it.

    (Get-Volume C).SizeRemaining /1GB
    278,10312271118       # Magic!
    
  • Rinse & repeat until you reach the desired size.

  • Finally, restore computer settings

    • Enable Pagefile

      wmic pagefileset create name="C:\\pagefile.sys"
      wmic computersystem set AutomaticManagedPagefile=True
      
    • Enable Hibernation (desktop Windows only)

      powercfg /h on
      
    • Enable System Restore (desktop Windows only)

      Enable-ComputerRestore -Drive C:
      
    • Restart the computer

Solution 3

The answer by @sancho.s works, but I'll leave this here in case anyone is looking for a quicker approach and is comfortable with third party tools.

As the comments point out, the problem was files that couldn't move during a partition shrink or defrag because they were locked by running applications and by windows. The simplest way to unlock those files is to stop the processes, and the simplest way to stop the processes is to not let them start! Hence, I started looking for a boot time defragment tool.

As recommended by @LưuVĩnhPhúc, I used this (free) partition manager, so I didn't need to defragment after all. Just start the tool, queue a partition job, and restart your computer:

  1. Start the tool, click the partition to resize, and click Move/Resize:

    enter image description here

  2. Set the size and click OK:

    enter image description here

  3. Apply the changes!

    enter image description here

  4. If you're shrinking lots like I was, it will prompt you to do it at reboot. Just restart the computer from the dialog box and sip your coffee for a bit.

    enter image description here

Solution 4

The key point is this part of the info message you posted:

You cannot shrink the volume beyond the point where any unmovable files are located.

From Microsoft's Shrink a Basic Volume:

Additional considerations

  • When you shrink a partition, certain files (for example, the paging file or the shadow copy storage area) cannot be automatically relocated and you cannot decrease the allocated space beyond the point where the unmovable files are located. If the shrink operation fails, check the Application Log for Event 259, which will identify the unmovable file. If you know the cluster or clusters associated with the file that is preventing the shrink operation, you can also use the fsutil command at a command prompt (type fsutil volume querycluster /? for usage). When you provide the querycluster parameter, the command output will identify the unmovable file that is preventing the shrink operation from succeeding.

    In some cases, you can relocate the file temporarily. For example, if the unmovable file is the paging file, you can use Control Panel to move it to another disk, shrink the volume, and then move the page file back to the disk.

  • If the number of bad clusters detected by dynamic bad-cluster remapping is too high, you cannot shrink the partition. If this occurs, you should consider moving the data and replacing the disk.

    Do not use a block-level copy to transfer the data. This will also copy the bad sector table and the new disk will treat the same sectors as bad even though they are normal.

  • You can shrink primary partitions and logical drives on raw partitions (those without a file system) or partitions using the NTFS file system.

You should first check the Application Log as indicated. If the unmovable file is the paging file, you can try to (temporarily) relocate it to another drive, then retry shrinking. However, if there are other unmovable files that prevent shrinking which you can't remove/relocate, then you won't be able to shrink using the builtin facility. In that case you'll need to use a 3rd party partitioning/imaging tool - there exist both free and paid such tools.

Solution 5

None of the above worked for me - defraggler showed a couple dozen files at the very end of the drive that I could not move. The only way was to use a tool called AOMEI Partition Assistant - worked perfectly. It loads a preboot app that runs after reboot and does the job - apparently some system files cannot be touched from within the running system.

Share:
222,494

Related videos on Youtube

kdbanman
Author by

kdbanman

To me, software and data are nature's most interesting systems. Email me by evaluating this expression .ToString() + "[email protected]"

Updated on September 18, 2022

Comments

  • kdbanman
    kdbanman over 1 year

    I use a big single partition on a 1TB platter drive with Windows 10. I would like to shrink the partition down so that I can mirror the drive to a smaller but faster 256GB SSD.

    I bought the drive without planning much. (Oops.) I saw that I'm only using 195GB and thought, "damn why don't I speed this thing up?"

    enter image description here

    But after a (very time consuming) defragment/optimize using the Windows 10 tool "Optimize Drives", it seems I can only shrink to ~488GB.

    enter image description here

    As far as I know, I need to get the source partition smaller than the target partition before I can mirror. But short of the defrag that I've already done, I'm not sure what to do. I could cull a bunch of programs and reduce the space I'm using, but I'm already using far less than the "Total size after shrink".

    How can I reduce a partition's minimum size? (i.e. the "Total size after shrink"?)

    • Admin
      Admin over 8 years
      Defragment everything! Boot a live OS and then defragment every single file and consolidate the whole drive to the beginning. What you want is no free space between files, so that everything is contained in one big block of data.
    • Admin
      Admin over 8 years
      Disable hibernate, page file, system restore temporarily then defrag/compact C drive, then try shrink, if it is small enough, mirror the C partition, enable page, hibernate, system restore after you boot into the new drive.
    • Admin
      Admin over 8 years
      If you want to further decrease the size run disk cleanup (cleanup up system files) and delete windows update files. Do this before defrag.
    • Admin
      Admin over 8 years
      And a last one - Compress everything. Aside from it getting faster (or not), it saves about 30% throughout the whole disk. Do that before Defrag!
    • Admin
      Admin over 8 years
      In reply to previous comments, doing a disk cleanup every now and then is good practice, but will probably not help in this case. The disk usage is listed at 195 GB which is already below the target SSD size of 256 GB. The real problem is that Windows won't allow shrinking the partition below 488,941, most likely because of unmovable files.
    • Admin
      Admin over 8 years
      the shrink function of diskmgmt.msc is very bad. You should use a good partition editor like Partition Wizard or EaseUS Partition Master, they can shrink the partition to the minimum size
    • Admin
      Admin over 8 years
      I'd really consider what needs to be on the drive before I do something like this. 195gb is cutting it a little close, and most people end up having a ton of junk on their systems. Spring clean first!
    • Admin
      Admin over 6 years
      It remains to be addressed, possibly elsewhere, how much space would you leave for these files recreating after the shrink, I guess
    • Admin
      Admin almost 6 years
      If you performed all steps in the accepted answer, which are correct, but still getting the message You cannot shrink a volume beyond the point where any unmovable files are located, check my answer posted below
    • Admin
      Admin almost 6 years
      Whilst I get the appeal of not using third party solutions, I cannot help but think that sticking "gparted" onto a small USB stick, booting the computer from that and then using it to shrink the partition seems a hell of a lot quicker than faffing around disabling hibernation, pagefile and system protection, rebooting, shrinking, re-enabling them and then rebooting again.
    • Admin
      Admin over 5 years
      Follow this disk-partition.com/articles/… and use the program mentioned there. Save your time for better things.
    • Admin
      Admin over 5 years
      While this question targets Windows 7, it may still be of help.
  • kdbanman
    kdbanman over 8 years
    Thanks for the response! While this would have definitely worked, it could be very time consuming to iteratively defrag and relocate unmovable files until the diskmgmt.msc gods are sufficiently pleased. I ended up using a boot time partition manager to move the unmovable files before they were locked.
  • sancho.s ReinstateMonicaCellio
    sancho.s ReinstateMonicaCellio about 8 years
    Shrinking can be done, with built-in features (no need for third-party software), and very easily. See superuser.com/a/1060508/245595
  • Draex_
    Draex_ almost 8 years
    It tells me my drive (on SSD) is too fragmented to shrink, The "Optimize Drives" program in Windows doesn't help.
  • crokusek
    crokusek about 7 years
    Use at own risk--but I also had to Delete all VSS Shadows because event log said the last unmovable file was C:\System Volume Information\{guid}{guid}::$data
  • User1291
    User1291 almost 7 years
    OMG, THANK you so much. Very glad I did not have to use GParted (didn't need a re-installation, last time I did use it, but I was a bit wary, nonetheless).
  • Marco Lackovic
    Marco Lackovic almost 7 years
    On Windows 10, after executing Disable-ComputerRestore -Drive C: I get the error 'Disable-ComputerRestore' is not recognized as an internal or external command, operable program or batch file..
  • bremen_matt
    bremen_matt almost 7 years
    Some of these commands did not work for me. For instance, I could not delete the pagefile using the above command. Instead I had to do it by going through the "Advanced System Settings". Also, the /K option for defrag was not available on my computer, so I just excluded that flag. Finally, I had to delete all of my restore points before I could shrink the disk. Otherwise, simple....
  • edencorbin
    edencorbin over 6 years
    I did these steps and my C drive still shows 5000 mb available to shrink when I have ~120000 free space, any other steps/recommendations in this case?
  • Sergei Gorbikov
    Sergei Gorbikov over 6 years
    I did everything as said in the instruction. It worked, but only partially. Because of the error "There is not enough space available on the disk(s) to complete this operation." i was unable to shrink the partition. I gave up and installed MiniTool Partition Wizard Free - it worked fine.
  • xtian
    xtian over 6 years
    Weird! Missing Operating System Error. ouch. My 500GB SSD had Win 10 taking up ~34G of 475G Volume and 441G Free space. I resized using diskpart to 100G partition with 70G free. After restart I got the missing OS error. While I was trying to figure out what to do, I restarted into BIOS, noted the license and continued boot--right into a working system. Woot!
  • xtian
    xtian over 6 years
    I performed the accepted answer's steps, and then continued with these instructions for Win 10v1703 on 500G SSD. I wasn't able to perform the full optimization command and instead just gave the defrag arg. Also, the Resize-Partition wouldn't let me shrink the partition to the 100G that I wanted (only using ~34G), so I opted to use DiskPart. After a panic with first boot giving me Missing Operating System error, I rebooted into the system successfully.
  • matt
    matt over 6 years
  • matt
    matt over 6 years
    defragging won't move files at the end of the partition closer to its beginning to free up space, as it has no reason to optimize towards that. I've no idea why this is mentioned as advice in the contect of Windows 10 but happy to learn of my miscalculation. Windows 10 will put lots of files at the very end of the partition once installed, and defrag is the wrong tool as it won't move them away from there.
  • matt
    matt over 6 years
    This procedure does not work with my freshly installed Windows 10. Apply good judgement before fiddling this.
  • dxiv
    dxiv over 6 years
    @matt You are technically correct, but (a) the OP explicitly stated that they are preparing to move to an SSD, so the current drive is not an SSD, and (b) the limitations of the builtin defragger are clearly spelled out in my answer.
  • matt
    matt over 6 years
    @dxiv agreed, still I think many people nowadays might look at the title of the question alone and jump here, so it might be worth mentioning
  • flen
    flen about 6 years
    For everybody who is getting an error saying the commands are not recognized (or are not available), please note the answer says: open a PowerShell prompt with administrative rights (a tutorial for PowerShell here: computerperformance.co.uk/powershell/index.htm ). This is not the same as a regular cmd prompt. Just search on the start menu for "Windows PowerShell" and you'll find it. I haven't tested the commands, but note that some commands for PowerShell v.3+ are not available to PowerShell v.2-.
  • Pritt Balagopal
    Pritt Balagopal about 6 years
    Add relevant parts of your link to the body of the answer. If the link rots, your answer would become obsolete.
  • sun2sirius
    sun2sirius about 6 years
    Sorry, I do not understand. All relevant information is there - use AOMEI Partition Assistant, because I found no other way to move unmovable files, and no answer above helped.
  • Daniel Hillebrand
    Daniel Hillebrand over 5 years
    Saved my life! :-) Extra point for the link to "Cannot shrink C: partition: Not enough space", because I got that message and had to shrink in chunks...
  • brittAnderson
    brittAnderson over 5 years
    Only adding this comment to save clicking above link "cannot shrink". After trying above it still failed, so I just shrunk the disk in three smaller increments to reach the size I wanted.
  • masterxilo
    masterxilo over 5 years
    Look no further than this answer ;)
  • masterxilo
    masterxilo over 5 years
    Why would I do this when there is free software that can do it in fewer clicks? Unless of course I am trying to learn about Windows but I just want my space.
  • sancho.s ReinstateMonicaCellio
    sancho.s ReinstateMonicaCellio over 5 years
    @masterxilo - Only as an example, in a corporate PC, where one cannot install stuff.
  • ivva
    ivva about 5 years
    I did it in a dual-boot and I got the grub rescue mode. I have both Ubuntu and Windows installed. After I shrank C drive, the things messed up and it showed grub rescue. How to do this in dual-boot?
  • sancho.s ReinstateMonicaCellio
    sancho.s ReinstateMonicaCellio about 5 years
    @mistery_girl - This is perhaps worth another question in SU.
  • m1ke3d
    m1ke3d about 4 years
    @matt there is a "free space consolidation" switch (/X) in defrag
  • x-yuri
    x-yuri almost 4 years
    Doesn't it make more sense to find out what's in the way and act accordingly? Rather than disable everything that comes to mind. Apparently your steps wouldn't have helped me.
  • sancho.s ReinstateMonicaCellio
    sancho.s ReinstateMonicaCellio almost 4 years
    @x-yuri - Well, I wouldn't know. I repeated this procedure a few times, with no problem, in a few minutes (and it seems this helped quite a few other people as well). So I wouldn't really spend time trying to see if any of the steps is not really needed, as they seems to imply no harm whatsoever. Then, I don't see any advantage from doing that. Surely, one could learn something, which is potentially useful... It's up to each one deciding on what investing one's time.
  • x-yuri
    x-yuri almost 4 years
    To make it clear, I had files that has nothing to do with the steps suggested by your answer. Speaking of harm, doesn't disabling System Restore discard existing restore points? It's probably worth mentioning in the answer. Also, I see people struggling with turning it on. As such it seems wiser to consult the log, rather than follow a general checklist. I didn't mean that your answer is bad, but at least in my case the log helped me clarify what's the hindrance.
  • ddcruver
    ddcruver about 3 years
    While this question was for resizing a SSD partition it would be helpful to include a defrag command that is good for traditional Hard Drives. I ended up running this command for a traditional hard disk: Optimize-Volume -DriveLetter C -Defrag -NormalPriority
  • zpangwin
    zpangwin about 3 years
    since no comment was provided, I will assume the downvote(s) was due to someone simply doing a causal reading of "Windows 10" in the OP's question title and then seeing "tested on Windows 7" on my answer without continuing to read the very next part about that it "should be the same for any Windows using ntfs filesystem" and also without bothering to actually confirm the solution I provided. sancho.s isn't wrong but it will not work in all scenarios (it did not work for me). Any technical user will know this is a longstanding issue with ntfs that affects Windows XP/Vista/7/8/10
  • Aldor
    Aldor almost 3 years
    When deleting the pagefile, I got ERROR: Description = Invalid query. I had to quote the whole query like this: wmic pagefileset where 'name="C:\\pagefile.sys"' delete.
  • ThCollignon
    ThCollignon about 2 years
    Didn't work for me (Win 11)