107

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

12
  • 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
    Dec 24 '15 at 23:47
  • 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
    Dec 25 '15 at 0:11
  • 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
    Dec 25 '15 at 2:50
  • 1
    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!
    – Journeyman Geek
    Dec 25 '15 at 2:51
  • 2
    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.
    – Richard
    May 23 '18 at 14:57

11 Answers 11

124

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.

15
  • 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
    May 10 '17 at 2:11
  • 2
    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
    Aug 20 '17 at 20:32
  • 2
    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. Dec 18 '18 at 14:36
  • 1
    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
    Dec 19 '18 at 20:34
  • 1
    @mistery_girl - This is perhaps worth another question in SU. Feb 22 '19 at 7:18
43

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

6
  • 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.. Jun 10 '17 at 16:18
  • 1
    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.... Jul 26 '17 at 5:01
  • 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
    Sep 30 '17 at 20:08
  • 5
    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-.
    – flen
    Mar 18 '18 at 3:12
  • 1
    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.
    – Johann
    May 13 at 14:57
8

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

1
  • 1
    It tells me my drive (on SSD) is too fragmented to shrink, The "Optimize Drives" program in Windows doesn't help.
    – Draex_
    Jun 30 '16 at 19:35
6

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.

7
  • 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
    Dec 29 '15 at 18:39
  • Shrinking can be done, with built-in features (no need for third-party software), and very easily. See superuser.com/a/1060508/245595 Apr 10 '16 at 14:12
  • 1
    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
    Dec 20 '17 at 14:32
  • 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
    Dec 20 '17 at 17:12
4

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.

2
  • 5
    Add relevant parts of your link to the body of the answer. If the link rots, your answer would become obsolete. Apr 13 '18 at 2:50
  • 3
    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.
    – sun2sirius
    Apr 13 '18 at 7:12
3

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.
  1. Disable hibernation.
  2. Disable system protection.
  3. 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.

1
  • Look no further than this answer ;)
    – masterxilo
    Dec 19 '18 at 20:32
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.

0

None of the solutions (without third-party) worked for me. I had a Ubuntu-Live USB so I tried with Gparted which worked (after a chkdsk C: /f). See the details in this answer.

It took 15min including the chkdsk C: /f

-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.
-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.

-1

Edit: For those coming in from search engines, here is an option that uses only native/pre-installed Windows apps + 1 open-source app

tested on Windows 7 x64 Pro but should be the same for any Windows using ntfs filesystem:

  1. Disable system restore, hibernation, virtual memory (pagefile), etc to prevent the most common types of 'locked' / unmovable files. This guide covers those steps.
  2. Optional: Install ccleaner (temporarily) and remove all the default junk or if you really don't like ccleaner, then PrivaZer might be an alternative.
  3. Run Windows Disk Cleanup
  4. Run Windows Disk Defragmenter on C:\
  5. Run Computer Managemenr (Win+R: compmgmt.msc) > Device Management and try to shrink drive. If the previous steps cleared things up, then complete ther shrink operation, reboot and re-enabled all the stuff you turned off in the first step.
  6. If you still have unmovable files shown, then head over to source forge and download the open-source Ultra Defrag app - make sure to get the installable one as the portable version will not work for this (relevant differences noted here). When I used it, I was on Win 7 Pro 64-bit and used ultradefrag-7.1.4.bin.amd64.exe
  7. You will also need either Notepad++ (open-source) or Sublime (never-ending free trial). This is because you have to edit a settings file that requires a specific encoding and the Windows notepad won't cut it. After it is installed, create a txt file and renamed it to test.cmd, then right-click and choose Open (or Open With) and select Notepad++/Sublime as the default application.
  8. After installs, open UltraDefrag > Settings menu > Boot time scan > Script. It should open automatically in Notepad++/Sublime if you followed the instructions in the previous step. But if it opens in Windows notepad, exit and run Notepad++/Sublime AS ADMIN and manually open the file. The file's full path on my system was: C:\Windows\System32\ud-boot-time.cmd
  9. In ud-boot-time.cmd, you need to comment out the two lines that define the variables UD_IN_FILTER and UD_EX_FILTER by putting a semi-colon (;) at the beginning of those lines - as noted in this post by Stefan Pendl - then save the file
  10. Back in UltraDefrag > Settings menu > Boot time scan > Enable. You should get prompted to reboot the PC (otherwise, confirm the box is checked in that menu, then exit the app and manually reboot).
  11. After the Windows logo but before the login screen, it should come up with a command line. IIRC you might have to press Enter or Esc on the keyboard - just follow the onscreen prompts. It will reboot when it gets done.
  12. Rerun Computer Managemenr (Win+R: compmgmt.msc) > Device Management and try to shrink drive. It should now have moved the unmovable files and you can shrink the drive.

If this doesn't work for you, you may have to either give in and resort to closed-source 3rd party apps (Easeus Partition Manager, Paragon Partition Manger, MiniTool Partition Wizard, PerfectDisk all seemed to be recommended by folks to varying degrees). I like the above approach bc IMO running a defrag is less likely to mess up your current install and make you need to whip out a recovery disc than a partition editor is. And even if you disagree, I would still rather run a FOSS app + a native windows app then be dependent on a closed-source app that might have a limited free trial / require me to fork over $40+ USD for a license so I can perform a one-time operation that Windows ought to have been able to do on its own in the first place (I use Linux most of the time so this is idea is especially not worth the money for me)

1
  • 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
    – zpangwin
    Apr 4 at 2:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.