54

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

  • 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
  • 1
    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
69

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.

  • @kdbanman - Great! Did you have a chance of trying this? – sancho.s Apr 8 '16 at 22:48
  • Nope! My comuputer no longer needs partitioning. I'm sure your answer will be helpful to people in the future though. – kdbanman Apr 9 '16 at 14:22
  • 2
    @sancho.s You are the man! It worked. I am glad I did not have to use GParted and mess around with Windows re-installation – user1700890 Jul 15 '16 at 21:57
  • 1
    Sorry it took ages to accept. I wanted to make sure it worked before accepting, and I didn't have a chance to verify it myself. Now that @user1700890 has had success, I'll accept your answer. – kdbanman Aug 31 '16 at 16:47
  • 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
17

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

  • 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 Jun 10 '17 at 16:18
  • 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 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
  • 1
    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
5

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

  • 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
1

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.

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

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.

  • 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 – sancho.s Apr 10 '16 at 14:12
  • 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
0

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.

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

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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