You’re busy trying to use the Bootcamp Assistant to install a bootcamp partition on your shiny Macbook, when suddenly you’re greeted with the dreaded fragmentation dialog of death:

The disk cannot be partitioned because some files cannot be moved

So what does “The disk cannot be partitioned because some files cannot be moved” actually mean? I mean, I’ve got 25Gb free and I only want a 10Gb windows partition! The answer lies in fragmentation. OSX seems to want a contigious block of clean disk to write to, and fragments of your files are scattered across it.

I know what you’re thinking. “But it’s a Mac. I’ve got this fancy file system that isn’t prone to fragmentation”. Yeah, yeah. Well, dude, the crushing news is that you can fix the problem by defragmenting your hard disk then trying again, so I guess OSX isn’t as committed to defragmentation as you might suspect.

I’m sure there are many ways to defrag an OSX hard disk. I chose to fork out 20 Euro and make the problem go away using iDefrag. There may well be open source/free alternative out there (feel free to comment if you know of any – useful for other googlers who come on by). iDefrag does its best work when it’s not defragging the boot disk, so you’ll want to generate a bootable DVD to run it from. Fortunately it ships with the tool to generate that bootable DV for you.

iDefrag ships will a free product called “Coriolis CDMaker”. Stick your Snow Leopard disk in the drive, run the CDMaker app, and it will get busy generating a bootable DVD for you with iDefrag as the autorun. Stick your bootable DVD in the drive, restart OSX, and hold down the “C” key as the machine boots – and it will boot up your DVD and run iDefrag.

Defragging takes some time - mine took about 3 hours to run - but that’s a lot less hassle than reformatting and restoring my entire drive. After the defrag I could happily run the Bootcamp Assistant without any “some files cannot be moved” drama.