Tip: How to shrink a volume beyond half its size using DiskPart or Disk Manager regardless of Microsoft’s NTFS restrictions and $MFTMirr

Tip: How to shrink a volume beyond half its size using DiskPart or Disk Manager regardless of Microsoft’s NTFS restrictions and $MFTMirr


Giveaway

If you use Disk Manager to shrink a volume, or when you go through the command line interface of DiskPart to do the same, you will often find out that it isn’t possible to shrink all available free space. And if you have a lot of free space, you cannot even ever shrink smaller than half the size of the disk. This article explains how you can solve this issue.

Method 1: how to shrink a volume with Disk Management

There are multiple ways of shrinking a volume. If you use a tool like Partition Magic, then this article does not apply to you, as it will take care of the problems that Windows XP, Vista or Windows 7 puts you in.

The easiest way is to use Control Panel > System and Security > Disk Management. Right-click the disk you want to shrink and select “Shrink volume…”. The system will now calculate the amount available to shrink and show that in a messabox, which has the following warning:

You cannot shrink a volume beyond the point where any unmovable files are located. See the “defrag” event int he Application log for detailed information about the operation when it has completed.

If you click Shrink, the volume (or partition) will be shrunken to the amount you requested. This will be succesful if there aren’t any unmovable files in that section of the volume.  If shrinking fails or the requested amount is not reached, you may find a warning in the eventlog as follows:

EventID 261
Provider Microsoft-Windows-Defrag
Level Warning (3)
Log Name Application
Task Category None
Keywords Classic
General description Error: a file blocked volume shrink on volume OS (V:).Diagnostic details:
- The last unmovable file appears to be: \Windows\winsxs\Manifests:$I30:$BITMAP
- The last cluster of the file is: 0x2b868c1
- Shrink potential target (LCN address): 0x1f54ac3
- The NTFS file flags are: —-S
- Shrink phase: <check>

To find more details about this file please use the “fsutil volume querycluster \\?\Volume{886db015-6083-11df-98f3-806e6f6e6963} \Windows\winsxs\Manifests:$I30:$BITMAP” command.

The file mentioned in the Event Log, “$BITMAP” is a hidden system file that’s unmovable and part of the necessary NTFS disk architecture. If you’d ever find a way to move that file by hand, you end up losing your disk due to MFT loading failures or worse. In case you wondered: it has nothing to do with pretty pictures, also sometimes called bitmaps.

Method 2: how to shrink a volume with DiskPart

After your first attempt proved unsuccessful, you decide to use the old-fashioned commandline, hoping this gets you further. Or perhaps this is your game anyway and you did this in the first place.  The tool DiskPart works slightly different then your average commandline in that it has its own command interface. If you use an operating system older then Windows Vista, Windows 2008 or Windows 7, you may need to download DiskPart, which is part of the SDK of your operating system.

The following commands are what you need to shrink a volume:

  • LIST VOLUME: lists the volume and their numeric ID. Use the ID or your volume for the next command;
  • SELECT VOLUME ###: replace ### with the number of the previous list, choose carefully!
  • SHRINK: without any parameters will shrink the currently selected volume by its maximum, or;
  • SHRINK DESIRED=50000: if you don’t want to shrink the maximum, specify the amount you want to shrink, note, this is not the desired target amount, but the amount that will be taken off your volume!

More information on how to shrink a volume usin this method or the previous method, can be found at Bleeping Computer here (the section on DiskPart is at the bottom). When you are done, you may receive the following error:

DISKPART> shrink desired=50000

Virtual Disk Service error:
The specified shrink size is too big and will cause the volume to be
smaller than the minimum volume size.

Or the following error:

DISKPART> shrink

DiskPart has encountered an  error: The parameter is incorrect.
See the System Event Log for more  information.

I asked about the first error on Serverfault.com and the second error was asked and answered here, but it comes down to the same reasons as with method 1 and 2: you need to defragment the drive to get rid of the error. But when you defragment the drive, it will not move the unmovable files which are in the middle of the disk….

After this, and after some hair-tearing, you may have tried method 3:

Method 3: backing up all data and restoring it

By now you should’ve come to the conclusion that something unmovable cannot be moved on your disks. But since you are in charge of your disks and you don’t want to delete your data, you figure: why not simply back it all up and then restore it. You choose System Backup and after you’re done, you find a nice VHD file that is smaller than the real size of your disk. So, happy with the prospect, you erase your volume and try to restore. Unfortunately, you have created a real System backup, and after you’ve restored (the system will tell you that the whole volume is needed), the same unmovable files are back in place.

Lessons learned about backup: it’s a true backup, but it’s time consuming and cannot be used with shrinking a volume.

Method 4: use the VHD (Virtual Disk) that the backup created and mount it as virtual disk

You can, indeed, use a VHD disk as if it were a real disk. You can even boot from it, or use it as the basis of a virtual Windows OS using either VMWare Viewer or Windows Virtual PC.  Because the VHD internally compresses all free space, not only the largest contiguous block, this makes sense. After this, you can remove the original volume and you can continue using the VHD (if you so prefer).

You can use the following commands with DiskPart to create the virtual disk and make it accessible:

SELECT VDISK="D:\WindowsImageBackup\CompName\Backup 2010-07-20 223352\4d591e27-f187-11dc-88fa-806e6f6e6963.vhd"
ATTACH VDISK
LIST VOLUME
SELECT VOLUME [New Volume Number]
ASSIGN LETTER=X

Tip: move the windows image backup to a more convenient location and a more convenient name. The quotes are necessary when the name contains spaces.

This actually JUST WORKS! In most cases…

The means it works when the disk is smaller than 128GB or 137GiB. That’s a hard limit of VHD, caused by historical reasons of the pre-ultra-large disk time. I won’t go into it, but suffice it to say, that some day Windows XP needed a new service pack to allow running at all on disks larger than this size. Because Virtual PC must be able to run Windows XP without these service packs, they took the shortcut and decided to hardwire this limit into VHD.

If your disk, after all the shrinking, is still above 128GB, the DiskPart commands will issue the following error:

DiskPart has encountered an  error: The parameter is incorrect.
See the System Event Log for more  information.

Again, we’re back at where we started, at least if our original disk was larger than 256GB, because in that case, some of these unmovable system files are right in the middle! Time to move on to more drastic measures and stop using Microsoft’s tools:

Method 5: use third party software to do the defragmenting

We know now that the issue is with unmovable files and the impossibility of Defrag to free up a large contiguous disk space. So perhaps there are some third party tools that can help us here.

I tried UltraDefrag and PerfectDisk (which comes in a free full functional 30 day version), but at first it seemed that these didn’t work either. The problem is: most of the defragmenting tools out there are using the same Windows Defragmentation API as Windows itself uses.

The report of UltraDefrag is left, the report of PerfectDisk is on the right (click to enlarge). Both clearly have trouble with typical NTFS system files that are part of the base structure of every disk. While technically these files could be moved (Microsoft has made that possible since Windows XP), doing so is intricate and dangerous and not available directly from the Defrag API that Microsoft provides. Maybe that’s the reason why most available defrag tools simply don’t do it.

The simple conclusion is, that these cheap and more expensive defrag tools are just a waste of your money, they only offer a more flexible interface to the already available API of Microsoft. But, there’s one exception,PerfectDisk. Risking to sound like a commercial ad, read on to the next section, Method 6:

Method 6: The Solution, using PerfectDisk in offline mode

I called the PerfectDisk company with my questions and explaining my problems so far. They pointed me at a simple tutorial, in which numer 5 (run a boot-time defrag) was of particular interest. If your disk is the OS disk and is currently active, this is your only option. But if you select this on an mounted, but not startup volume (whether it contains an OS or not doesn’t matter), PerfectDisk will offer you to take the disk offline and perform the defragmentation without restarting. The solution step-by-step:

Before you start: if you have an OS disk that is not active (i.e., you boot from another OS disk), reboot to the OS disk that you want to shrink and follow step 1 and 2 on that booted OS disk. Afterwards, restart and go back to your current OS.

Step 1: turn off system restore

This step will remove all your system restore points. Prior to doing this, you may want to create a full system backup (but prior to shrinking a volume, making a backup is always a good idea!), which will allow you to go back, including the restore points.

Step 2: disable hibernation

This step is rather harmless, but solves issues with moving the hibernation file and improves speed. You don’t necessarily need to do this, but I highly recommend it. If you later want your hibernation file back, simply turn it back on. It only improves performance when returning from a hibernate session.

Step 3: perform a first defragmentation with PerfectDisk or another defrag tool

If you haven’t downloaded PerfectDisk, you should do now, and run the installer. It will not install bloatware, nagware, spyware or adware, at least none that I have seen. It’s rare that system utilities that you pay for are really good, but this one seems to live up to its promises quite well. After startup, make sure it doesn’t do any default defragmenting (takes way too long for all disks), so make sure everything is set to “Manual”. Then:

  1. In the main screen, select your disk;
  2. Select Consolidate Free Space in the dropdown box in the top left;
  3. Click the green play button and make yourself some coffee.

After you’re done, the Drive Map may look something like the following, where the red circle-like mark shows the unmovable parts. If you don’t see these and the whole end part is white, it means that you’re lucky and the whole disk has its maximum free space already. Note that fields marked MFT, MFT Zone and Metadata are unmovable. If you want to know what’s in a particular sector, you can rightclick it and select Show files. For the Metadata section below, this screen is placed on the right:

Here, we see the cause of all the trouble, $MFTMirr. This is an essential file and contains a copy of the first four records of the MFT Table. You’ll never notice it, the operating system will use it when these first four entries in the MFT Table have become corrupted, and even then, not even a warning will be issued. For safety reasons, this mirror image must be on a physically different location from the MFT Table. That’s why Microsoft places this in the middle of the drive. The same safety reasons prevent it from being moved easily (there’s another spot on the drive, inside the MFT Table metadata, that points to this location).

Step 4: perform a second (and third) offline defragmentation with PerfectDisk

The last league:

  1. Select the Boot Time button on the Defragmentation tab;
  2. If the disk is not the currently booted OS disk, you’ll get the message as in the screenshot, I suggest you select Defrag Now. Otherwise, if the currently defraggable disk is the bootdisk, select Defrag On Next Boot.
  3. This defrag takes much longer, so make yourself a can of coffee.

After this defragmentation has finished, the final drive map or drive layout may look something like the following. The Metadata section containing the obnoxious $MFTMirr has been moved up a bit. If it still not completely at the end of your data. To solve that, you need to shrink the volume, and then do the offline defrag again. In my case, I didn’t mind a little free space, I just needed to get the whole size below 128GB, which I managed now. See Method 1 and Method 2 above for how to shrink the volume.

Conclusion

Microsoft has gone through great lengths to ensure NTFS integrity. One measure was to make sure that copies of vital data exist on both the beginning and the middle of the drive. In severe circumstances, this may save your day and in general, this is good design. Unfortunately, not being able to move this has backfired a bit in cases where you want to shrink your volume. Maybe nobody ever wants to shrink volumes, but considering the amount of reports on the subject, I take it that shrinking does happen and this $MFTMirr file should simply not be in our way.

I’ve come to appreciate the high level of security and safety that NTFS brings, but it really shouldn’t be this hard to do some simple repartitioning tasks. At least, thanks to PerfectDisk (haven’t found an open source alternative that can do this), I have managed to keep my sanity and old boot sections can now be turned into VHD’s of less then the required 128GB of size. That means: I can run Vista on top of Windows 7, which is what this was all about to begin with.

  • mkultra

    If you’re somewhat savvy with linux, just defrag in windows and resize the hard drive via booting on a ubuntu or centos livecd using gparted. It does move the MFT files automatically when it resizes. When I got to reading step #6 my thoughts were why in the world is this guy torturing himself with all of this… lmao

  • Pingback: pelerinaje interne luna mai 2014

  • Pingback: Dual boot – instalace dalšího operačního systému ke stávajícímu | Saly's software insights

  • Norio

    I had the same problem as discussed here. I had a 1 TB disk on a new computer, but I was not able to shrink by more than 460 GB with the Windows disk management tool. I read your post but was too lazy to try Method 6, and I went for more internet search. In the end, I did as described in post
    #6 by parminides on November 25th, 2012
    in
    http://ubuntuforums.org/showthread.php?t=2087466
    Then, disk management tool said I can shrink by 900 GB. I actually shrinked it by 700 GB successfully.

  • Manolo

    Worked like a charm, thanks a lot!

  • Sofia Lucifairy

    Very useful article, thank you!

  • Ale

    the Perfect disk you can download in the link you mention now has the option Prep for Shrink inside Drive Preferences (set up here, before start defrag). :)

  • Ethan

    All this is absolutely not necessary (PerfectDisk doesn’t work as mentioned above, lost an hour with it). Just use Gparted and it finishes the whole task in less than 3 mins!

    I tried a 2-yr old gparted disk on win8 and shrink 500MB down to 100MB, it took 2+ mins.

  • JoeB99

    Simple alternative – While not practical in most cases, I have found that if you have a new computer with a recovery partition (easy reinstallation of the factory settings) you can dramatically decrease the shrink volume in a couple of easy steps that take less than an hour. 1-On the new computer shrink the primary volume. 2-Do a factory install on this now shrunk volume. 3-Shrink the volume again. I was able to take a primary volume of approximately 700GB down to 360GB and then ultimately 35GB. Ultimately I extended to 200GB before formatting the remaining space.

    • http://undermyhat.org/ Abel Braaksma

      Yes, that’ll work, but unfortunately, it requires reinstall of everything, only suitable if you have a backup ready, or when you can do a factory install like you did.

  • Pingback: Resizing volume with DiskPart unsuccessful, while there's enough free space - Just just easy answers

  • Pingback: How do I move the physical location of $MFTMirr, to allow resizing the partition? - Just just easy answers

  • Tiger-Mouse

    Thank you for your article which helps me squeeze as much hard disk as I’d like to from my new Windows 8 PC to be used in Linux under the dual boot arrangement.

  • Ανώνυμος

    Shrink does not exists in Windows XP.

    http://www.dizzain.gr

  • sql server masters

    Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.http://www.sqlservermasters.com/

  • http://www.facebook.com/profile.php?id=594406076 Mohamed Hassan

    I’m reading this to fit my big Win8 OS partition into smaller SSD

  • Ramses

    This Perfect disk free trial is really good, i tried some other defragers (Ultradefrag, Mydefrag, Defragler, windows standard defrag) but this was the only one that moved the MFT files. Free trial works, no spy or adware, i am even thinking about buying, it, but then again how often do i need to do this. but this post was a great help. Thanks again.

  • Peter

    PD12.5 has an option “prep for shrink” … used that, no boot-defrag needed … took a 300Gb partition down to 68Gb

  • Carmine

    Great article. I was stymied by the NTFS system files until I came across your article. I shrunk a 960 Gig drive down to 210 in order to clone to a 300 Gig drive. Only took 3 passes with Perfect Disk. Booted up first try after cloning with EaseUS. Thanks for the great work

  • Jody Bruchon

    Or, Linux-capable users can use Linux “ntfsresize” or “parted” or the graphical variant “GParted” to do the resize work.

  • Naz

    Really useful article. I managed to shrink a 250gb volume down to 80gb but had to ‘defrag on next boot’ twice. Used up best part of the day though!

  • Haidi

    PD was not solving my issue, $MFT always very at the end of disk space.
    I tried something different, no commercial sw needed: reduce the partition size, then enlarge it again. As the partition was the active one, this needed booting. I used EASEUS part. mangr.

  • Nate

    Thank You! I was getting the idea of what was going on, but you provided very helpful info on how to solve. Wish every how-to contained accurate, helpful information like this. Was able to install perfectdisk in my guest and move the ‘unmovable’ files so I could make my partition a more resonalble size.

  • Nate

    Thank You! I was getting the idea of what was going on, but you provided very helpful info on how to solve. Wish every how-to contained accurate, helpful information like this. Was able to install perfectdisk in my guest and move the ‘unmovable’ files so I could make my partition a more resonalble size.

  • Andrew Teeluck

    For those of you on Windows 8, I was able to shrink the partition down entirely to about 70GB just from the first two steps of Method 6. So maybe Windows finally got it right? Hope it works for others. Now I can fill 850GB (instead of 450GB) with Linux! :)

  • Dan Aquinas

    Tried Method 6 on a Windows 7 Pro, 64-bit laptop where C: was the 2nd partition on the hard drive. Ran PD multiple time, both from Windows, and in offline mode, but could *not* shrink the disk because the $BadClus file occupied the very last block on the partition.

  • Samson

    (haven’t found an open source alternative that can do this)

    Personnaly, I did unsuccessfully try to download PerfectDisk before to found Gparted what is very useful for shrinking and move ntfs partitions.

  • Hiker613

    You are a genius.!!!!!

  • Alex

    Yes! Thank you so much for this guide! I was able to shrink my 300 GB C drive to about 78 GB! (could have shrunk more if I wanted too)!

  • http://seyi.ajetunmobi@facebook.com Ajetovski

    Thanks a lot for this article. I was able to turn off system restore & reduced the page file to the very minimum of 200MB, this allowed me to shrink all of the space available coz at that time, I had just freshly installed windows 7 on a 500GB HDD.

  • Norman

    Thanks for that article!
    It really helps me shrinking a Win7 partition of a friend’s laptop (processing 1st PerfectDisk defrag right now, while other tools I tried before didn’t work). If the drive is shrunk, it will get some good Linux partitions onto the PC to make it better usable :)

    I also got the idea from your site, to do as much of the Windows stuff as possible with the Windows onboard tools (like shrinking the partition – I would’ve used GParted for that), since the only (or best) compatibility to Windows is Windows itself. Glad to be free from that stuff, now liberating other people :-)

  • RR

    Thank you VERY much …. i followed your steps and i was able to shrink 200 Gb more ! (Initially i was allowed to shrink only 300 GB in my new comp…)

  • http://goneridin.blogspot.com/ Tod Schmidt

    You can do this just using the windows utilities without having to buy any 3rd party software. I took time out from sailing my boat to put instructions up here.

    http://goneridin.blogspot.com/2011/11/shrink-windows-7-volume-below-half.html

    • http://undermyhat.org Abel Braaksma

      What you describe in your blog is the basic way to do this, but that, unfortunately, fails on the MFT record. Your own blog links to another site that you suggest contains a workaround. It does not, in fact, it states:

      If you are encountering the MFT problem, then you won’t have too much luck even after running those utilities. What you’ll need to do is use one of the non-free defrag utilities that is able to move the MFT files. If somebody can suggest a free way to move the MFT, leave a note in the comments.

      In other words: no, you still cannot do this without third party tools. But if you have a working alternative, let me (and the community) know.

      • Tod Schmidt

        Sorry, didn’t see your reply until now, but shrinking it using DISKPART while booted from the system restore disk *did* work for me to shrink it beyond half. That is the key step that I did not see referenced in either your article or the howtogeek article and this did allow me to shrink it beyond half. The important thing is you are then working on an unmounted volume which enables you to bypass the MFT limitation.

  • Rockallite

    Very useful tips! Thank you!

  • Keith

    Abel – Many thanks for the concise list of methods to get the volume size down. I used your methods when migrating to an SSD. Before finding your site I did many defrag and shrink, but got stuck at around 200GB partition size (and only 60GB of data on disk). after following step 6 #1, #2, #3 – and then ran shrink again, I had success without needing PerfectDisk. Thanks!

  • Pingback: Resizing volume with DiskPart unsuccessful, while there’s enough free space - Admins Goodies

  • MPM1378

    Thanks a lot for your wonderful guidance, it really saved my day

  • Dan

    I just tried this and while PerfectDisk seemed to work OK, apparently it got something wrong because now “Disk Management” sees my system volume as having 100% free space and when I ask to shrink, it warns me that the file system is unrecognized and if I proceed, shrinking will erase any data. Fortunately, all other parts of Win7 seem to be calculating the free space correctly and not having a problem with the file system, but I still can’t shrink the volume

    • http://www.undermyhat.org Abel Braaksma

      Sounds to me that something indeed went wrong (sure hope you made a backup of your data, you should always do that when shrinking your disks). The team of PerfectDisk has quite a good helpdesk, I believe your best bet is with them as this goes beyond my knowledge of disk partitioning.

      What’s odd in your story is that your Windows 7 works OK, but Disk Manager shows that there’s 100% free space… Sounds like a potential problem with Windows and/or the disk driver.

  • bik

    where is the solution to shrink beyond half? method 1 and 2 just tell the problem. The title is misleading.

    • http://undermyhat.org Abel Braaksma

      Read on all the way to the final method, Method 6, as all other methods (found as “solutions” on the internet) fail.

      • Mike

        So booting into something like GParted and repartitioning from there doesn’t work:
        http://gparted.sourceforge.net/livecd.php

        • http://undermyhat.org Abel Braaksma

          It doesn’t. Because using GParted doesn’t suddenly move the MFT around.

  • mudit

    hey my d drive is having the same problem of BITmAP……i dont hv perfectdisk n my d drive is not the system drive….its my primary normal disk n i m not ablle to defrag it…..can u help me wht to do…

    • http://undermyhat.org Abel Braaksma

      Without PerfectDisk you’re out of luck, as I’ve tried many freeware / open source (and most commercial!) tools and none did this right, unfortunately.

      However, if you do get across a solution that doesn’t involve paid software, I’d love to hear from it.

  • http://www.gratefulweb.com Aaron D.

    hey! thanks for this great post. i was one of the lucky ones, in that I was able to shrink my 685gig hard drive and partition as I wanted after the first perfectdisk defrag. now i’m happy and very awake form a big cup of coffee.

    aaron

  • Tom

    Method #6 worked perfectly – only trouble is, I don’t drink coffee…

    Thanks

  • http://www.stogiepedia.com Cory

    This worked perfectly for me! Excellent guide!

  • Yucong Sun

    This is so cool, I highly recommend their software, it moved that DAMN BITMAPS and shrinked my huge C volume in no time!!!

Get Adobe Flash player