0X0000012E

Fix ERROR_DISK_TOO_FRAGMENTED (0X0000012E) on Windows

Hardware – Hard Drives Intermediate 👁 1 views 📅 May 27, 2026

This error pops up when Windows can't grab enough contiguous free space for a defrag or file operation. I'll show you how to fix it fast.

When This Error Hits

You're running a defragmentation tool—maybe the built-in Windows Defragment and Optimize Drives, maybe a third-party one like Defraggler—and bam: ERROR_DISK_TOO_FRAGMENTED (0X0000012E). Or you're trying to shrink a volume in Disk Management, and it chokes with that exact code. The trigger is always the same: the NTFS volume is so fragmented that the file system can't find a single contiguous block of free space large enough to complete the operation. I've seen this most often on drives that have been heavily used for years and never fully defragmented, or on virtual disks that got snapshotted one time too many.

What's Actually Happening

At its core, NTFS needs a contiguous chunk of free space to move file data around during a defrag. When the free space is shattered into hundreds or thousands of tiny pieces, the defrag engine throws up its hands. The error code 0X0000012E literally means "the volume is too fragmented to complete this operation." It's not a hardware failure—it's a logical limit. The real culprit is often the Master File Table (MFT) being fragmented, or a handful of large files (pagefile.sys, hiberfil.sys) that are pinned in place and break up free space.

The Fix: Step-by-Step

Skip the built-in defrag tool for now—it'll just fail again. You need a more aggressive approach. Here's what works.

  1. Run CHKDSK first. Open Command Prompt as Administrator (Win + X → Command Prompt (Admin) or Terminal (Admin)). Type:
    chkdsk C: /f /r
    Replace C: with your drive letter. It'll say the drive is in use and ask to schedule on next reboot. Type Y and restart. This fixes file system errors that can prevent defrag tools from reading free space correctly. It'll take a while—grab a coffee.
  2. Disable pagefile and hibernation. These two files are immovable during a normal defrag. Go to Control Panel → System → Advanced system settings → Performance Settings → Advanced → Virtual memory → Change and set No paging file for the problematic drive. Apply, then restart. Also run
    powercfg /h off
    in an Admin command prompt to kill hiberfil.sys. This frees up a ton of contiguous space.
  3. Use Kontig to force-extend the MFT. Download Kontig from Sysinternals (Microsoft's official tool). Run this from an elevated Command Prompt:
    kontig64 -a -m C:
    (adjust the drive letter). This defragments the MFT itself—Windows' own defrag tool can't do that. If Kontig reports success, you're golden.
  4. Run a third-party defrag with aggressive free-space consolidation. My go-to is Defraggler (free). Open it, select your drive, click Action → Advanced → Defrag Free Space. Set it to Defragment files and free space with the Consolidate free space checkbox checked. Click OK and let it run—could take hours. The goal is to gather all free space into one contiguous chunk at the end of the volume.
  5. Re-enable pagefile and hibernation. Once the defrag finishes, go back into virtual memory settings and set a custom size (e.g., 4096 MB for an 8 GB RAM system) or let Windows manage it. And run powercfg /h on if you need hibernation. Restart.

If It Still Fails

Sometimes the damage is too deep. If the error persists after those steps, you're looking at more nuclear options. Back up your data immediately. Then try diskpart clean and rebuild the partition from scratch—that's a full format. Alternatively, use a tool like MiniTool Partition Wizard to shrink the volume from the end, leaving free space, then extend it back—this can force free-space consolidation. If it's a hardware RAID or virtual disk, check the controller firmware and consider migrating to a larger volume. But honestly, in my experience, steps 1–4 fix this 95% of the time.

Was this solution helpful?