How can I shrink a Windows 10 partition?

78

31

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"?)

kdbanman

Posted 2015-12-24T22:59:40.657

Reputation: 1 466

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. – GiantTree – 2015-12-24T23:47:55.060

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. – Moab – 2015-12-25T00:11:35.567

If you want to further decrease the size run disk cleanup (cleanup up system files) and delete windows update files. Do this before defrag. – Moab – 2015-12-25T00:16:00.797

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! – Aganju – 2015-12-25T02:31:03.480

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. – dxiv – 2015-12-25T02:38:11.870

3

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

– phuclv – 2015-12-25T02:50:28.200

1I'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! – Journeyman Geek – 2015-12-25T02:51:24.800

It remains to be addressed, possibly elsewhere, how much space would you leave for these files recreating after the shrink, I guess – matt – 2017-12-18T07:07:07.133

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

– mpro – 2018-05-23T14:18:24.303

2Whilst 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. – Richard – 2018-05-23T14:57:04.880

Follow this https://www.disk-partition.com/articles/shrink-volume-with-unmovable-files-4348.html and use the program mentioned there. Save your time for better things.

– masterxilo – 2018-12-19T20:36:07.327

While this question targets Windows 7, it may still be of help.

– Alex Che – 2018-12-20T10:14:59.207

Answers

94

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.

sancho.s Reinstate Monica

Posted 2015-12-24T22:59:40.657

Reputation: 2 404

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

– crokusek – 2017-05-10T02:11:20.583

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). – User1291 – 2017-05-24T07:37:05.667

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? – edencorbin – 2017-08-20T20:32:17.667

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. – Sergei Gorbikov – 2017-08-26T19:40:50.757

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 – 2017-09-30T20:03:50.093

This procedure does not work with my freshly installed Windows 10. Apply good judgement before fiddling this. – matt – 2017-12-20T15:13:44.533

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... – Daniel Hillebrand – 2018-10-05T13:45:30.507

2Only 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. – brittAnderson – 2018-12-18T14:36:12.347

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. – masterxilo – 2018-12-19T20:34:31.140

@masterxilo - Only as an example, in a corporate PC, where one cannot install stuff. – sancho.s Reinstate Monica – 2018-12-31T05:38:02.480

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? – mistery_girl – 2019-02-21T21:34:45.307

1@mistery_girl - This is perhaps worth another question in SU. – sancho.s Reinstate Monica – 2019-02-22T07:18:21.053

30

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

F.D.Castel

Posted 2015-12-24T22:59:40.657

Reputation: 409

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.. – Marco Lackovic – 2017-06-10T16:18:06.453

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.... – bremen_matt – 2017-07-26T05:01:08.930

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. – xtian – 2017-09-30T20:08:12.897

4

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: http://www.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-.

– flen – 2018-03-18T03:12:51.577

7

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

kdbanman

Posted 2015-12-24T22:59:40.657

Reputation: 1 466

1It tells me my drive (on SSD) is too fragmented to shrink, The "Optimize Drives" program in Windows doesn't help. – Draex_ – 2016-06-30T19:35:35.813

2

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.

dxiv

Posted 2015-12-24T22:59:40.657

Reputation: 1 784

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. – kdbanman – 2015-12-29T18:39:50.490

Shrinking can be done, with built-in features (no need for third-party software), and very easily. See http://superuser.com/a/1060508/245595

– sancho.s Reinstate Monica – 2016-04-10T14:12:33.670

defragging might actually cost for an SSD – matt – 2017-12-20T14:09:14.903

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 – 2017-12-20T14:32:01.863

@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. – dxiv – 2017-12-20T16:26:41.990

1@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 – matt – 2017-12-20T17:12:59.433

@matt there is a "free space consolidation" switch (/X) in defrag – Mark Sowul – 2020-02-27T13:23:45.467

2

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 the AOMEI Partition Assistant (https://www.disk-partition.com/articles/shrink-volume-with-unmovable-files-4348.html) - 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.

sun2sirius

Posted 2015-12-24T22:59:40.657

Reputation: 121

4Add relevant parts of your link to the body of the answer. If the link rots, your answer would become obsolete. – Pritt Balagopal – 2018-04-13T02:50:38.590

2Sorry, 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. – sun2sirius – 2018-04-13T07:12:20.513

1

Use the Freeware AOMEI Partition Assistant Standard Edition

I decided to give this perfect utility for doing the job a better writeup to increase it's popularity.

It can shrink a partition beyond what is occupied by (on the current system disk) "unmovable" (= in-use) files, while the diskmgmt.msc (Disk Management) does not expose a possibility for doing this.

I wrote this down at greater length because I feel bad for people wasting precious time manually following instructions like

  1. Disable pagefile.
  2. Disable hibernation.
  3. Disable system protection.
  4. Disable the kernel memory dump

The posts containing these instructions occupy more space making them seem more important than the tiny interspersed posts containing the simplest solutions. Importance is inversely proportional to size... Also, if something to do with a computer can be written down as precise instructions, a program can be written to follow them and it can be executed by anyone without manual effort...

I have been able to shrink my drive (nvme ssd) to more or less precisely the size that I am using (from 200 GB down to 140 GB) in 5 minutes including researching the topic, installing this solution and executing it. Most importantly, I did not have to learn anything about typical large unmovable files in Windows which I did not care about at all.

You start up the program, select the partition you want to shrink (I assume it is your system partition/volume C:) then drag the slider to set the desired size. Because the disk is in use, the resizing process will be set up as a Windows PE (Preinstallation Environment) program, scheduled for execution at the next boot.

Here are their instructions including pictures to increase the size of this post:

  1. Download, install and launch this free partition manager software.

  2. Right-click on the partition or volume to be shrunk and select Resize Partition. enter image description here

  3. In the next screen, drag the slider leftwards to shrink the partition. enter image description here

  4. Click OK to preview the partition layout. If no problem, click Apply to run the operation.

> Apply

After you shrink volume with unmovable files, you will get an unallocated space.

Disclaimer: If you resize C:, it will require a reboot and the program will be executed one-time in the Windows PE environment which is a reduced windows desktop which you may not find very pretty but it gets the job done.

Further references:

Disclaimer: I am in no way associated with them, just a very happy user that installed and used this tool to solve the problem once and be done with it.

masterxilo

Posted 2015-12-24T22:59:40.657

Reputation: 333

Look no further than this answer ;) – masterxilo – 2018-12-19T20:32:33.483

0

In my case, following above instructions failed. Somehow I'm still not able to shrink the drive. What worked for me is to restart Windows in Safe Mode (hold shift and choose restart). In Safe Mode, go to advanced and drop to the command prompt. Use diskpart.exe to shrink the drive:

list volume 
select volume <volume number>
shrink [desired=<desiredsize>] [minimum=<minimumsize>]

This will need to be done after disabling hibernation, page file system and system protection.

Remember to enable them after the volume is shrunk.

Jasper Baniqued

Posted 2015-12-24T22:59:40.657

Reputation: 11

0

An important point. If you're repartioning, particularly when using a third party tool or to install linux, back up your bitlocker keys in advance. I successfully shrank my Windows partition and installed Linux, but the next time I tried to boot Windows it demanded the bitlocker recovery keys/codes.

Fortunately for me, the IT people HAD backed up bitlocker codes on this corporate laptop previously. Since we don't use Microsoft accounts for logging in, there was no cloud backup that I could access, so I would have been SOL!

Paul M

Posted 2015-12-24T22:59:40.657

Reputation: 131

-1

In addition to the steps outlined by sancho above:

  1. Disable hibernation. Restart.
  2. Disable pagefile. Restart.
  3. Disable system protection.
  1. Perform a disk cleanup to remove old backup files.
  2. Use an external defragment tool defraggler (by piriform, the same people who make speccy). This moved the files preventing partition reduction. For some reason, the built in Microsoft defragmenting tool doesn't move these.
  3. If it doesn't let you do a mass partition resize, you could try to do an incremental reduction. e.g. 50gb shrink, 2 x 25gb, or 10 x 5gb shrinks.

Jared

Posted 2015-12-24T22:59:40.657

Reputation: 41

-1

Important information for those who struggle to shrink the partition even taking all steps mentioned in the accepted answer.

It is possible to get the information what is the last unremovable file, which disturbs the shrinking process and delete it.

Look for the solution below.

Obviously, you can use 3rd party software, which I also tried to use, but most of the cases free versions will allow you only to shrink when running the system - for the bootable versions in most cases you need to pay.

Before you start, important things to remember:

  • Don't treat your SSD drive with any of defragmentation tools, because you can damage it or make it live shorter.
  • Before you start to play with partition tools, make a backup of important data.

BACKGROUND:

In my case under Windows 10 ran on SSD drive I performed all steps mentioned in this tutorial, which are:

  1. Disable pagefile.
  2. Disable hibernation.
  3. Disable system protection.
  4. Disable the kernel memory dump
  5. Restart the system.

It didn't work. I also performed partition optimization process, but it also didn't work. I keep getting the message:

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

I've also tried MiniTool Partition Wizard Free, however like mentioned above, I was unable to shrink while running the system. I've been asked to reboot, however the application froze. Fortunately, I was able to cancel the process without losing any data - system booted normally. One of the suggestions was to use bootable version, which is not free. So I dug more and found the solution.

SOLUTION:

It is possible to get the information what is the last unremovable file, which disturbs the shrinking process. Simply you need to run the Event Viewer.

  1. Start Menu > Run > eventvwr.msc
  2. In the left panel choose “Windows logs” > “Application”.
  3. Check last Defrag events details to see what is the possibly last unremovable file.
  4. Remove the file. If the file is somehow related to the system and protected, Google for a solution with the filename as a query.
  5. Perform partition shrinking attempt again.

enter image description here

If you succeed, remember to:

  1. Enable pagefile.
  2. Enable hibernation.
  3. Enable system protection.
  4. Enable the kernel memory dump

In my case, I need to look for last unremovable file 3 times and after each deletion, I was able to shrink the partition a little bit. Basically, you jump from the last unremovable file to another, until you reach the desired partition volume. It can take some time but still, you are able to do it without third-party apps.

I've found the solution there and sharing it here hope it will help more people.

mpro

Posted 2015-12-24T22:59:40.657

Reputation: 99