Since Wednesday was annoying-Vista-feature-day, I thought today I should focus on a very annoying OSX feature, or should I say lack thereof.
If you’ve spent much time on one of the latest Macbooks, you may have noticed that OSX doesn’t provide a way to defragment the hard drive. When I first discovered this, I thought I was surely mistaken. Think again, Aaron. This is Apple you’re talking about. I guess I’m just spoiled by Window’s quest for all things practical.
Apparently, in Apple’s ongoing (and sometimes silly) quest for simplicity, they designed OSX to handle it for you behind the scenes. For most home users, that’s probably ok, but when you need specific control over your drive usage and the OSX algorithm isn’t doing things the way you need it to you’re simply out of luck, unless of course you’re willing to break out the wallet. Most devs will run into this at some point.
The place I’ve seen this bite people the most, including myself, is when using Apple’s Boot Camp— their drive partitioning software that makes it easy to dual-boot so you can run XP/Vista on your MacBook Intel-hardware. However, if your drive is seriously fragmented or simply not compact enough, Boot Camp will often fail when you ask it to create the Windows partition, complaining that “some files cannot be moved”. In my case, I was only using 20 GB for OSX and had 90 GB of disk space freeyet when I asked Boot Camp to create a 50 GB partition, it failed with that error. Again, what really sucks is that there is no way to diagnose or solve the problem using OSX provided tools. I had to resort to a 3rd party. Enter iDefrag.
So I downloaded the iDefrag trial and scanned my drive. I noticed a huge file (~2 GB, which happened to be the swap file) in the second half of the physical drive space, so if OSX was unable to move that file, that explains why my 50 GB partition failed in Boot Camp. You can’t do much beyond a scan with iDefrag until you purchase it, so purchase it I did ($30). Then I created an iDefrag boot disk (using the CD creator software they provide), booted to the CD, and ran iDefrag (this is necessary because you cannot boot from the HD you wish to defragment, unless you use the simple/quick defragment algorithm, but that wouldn’t have done what I needed here). Then I ran the compact algorithm to move everything to the front of the drive.
Once it finished, I rebooted to my HD and ran Boot Camp Assistant once again, and voila, it created the large partition no problem. In fact, I decided to dedicate 70 GB to my Vista partition since I’m spend more time there these days and it worked without a hitch.
In the end, I spent a bunch of time researching the issue, trying to figure out a built-in solution to no avail — what a waste of time. So my advice to those experiencing this problem: don’t waste time, spend the $30 and buy iDefrag or something like it. I personally found iDefrag to be a great product with great visuals:
Disclaimer: I have no affiliation with iDefrag, it’s authors, or the co. I simply found them on Google.
There were a few forums that helped me survey the scene and offered other possible solutions, but in the end, the only deterministic solution is to defragment/compact the drive, and Apple doesn’t provide it.
This is probably my #1 complaint with Apple as a developer — they simply don’t provide the necessary system tools that serious developers need to operate on a daily basis. Instead we have to buy them individually, which gets tiring after a while. And if you can’t cater to us, I’m sorry Steve, you’ll never see huge grassroots movements around building software for the Mac.