On Friday, I went down the rabbithole of trying to free up hard-drive space on my MacBook. (I figure, if I write about it in full here, I'm less likely to inflict the story on anybody in conversation.)
This is actually a problem I'd been having for a while. I use my MacBook for work, and I have to have a few virtual machines installed on it, and I was used to, every month or so, poking around with Disk Inventory X and figuring out what 1GB file I could safely delete or symlink away to an external drive.
So this latest time, I poked around with df -h and determined that, yup, I had only a few gig free on my 125GB hard drive.
I figured it might be time to shop for a new and bigger one. I asked around and determined that, yes, it was an easy fix to upgrade the MacBook's hard drive. Then I looked for a drive that would fit my late-2013 Retina MacBook Pro. I found only one, and it had horrible reviews. So: back to the drawing board.
Then it occurred to me that nobody actually *makes* 125GB hard drives.
Aha! I had forgotten that this was a dual-boot system. There was a 250GB hard drive, and I had split it evenly between my Windows install and my OSX install. I poked around and discovered that my Windows install was only using 50GB of its 125GB drive. So obviously, the thing to do would be to shrink the Windows partition and expand the OSX partition. Easy, right?
I rebooted into Windows, went to its disk manager, and asked Windows to shrink its partition. It said I could shrink it by 10MB -- not "GB", but "MB", a thousand times smaller. Aha! I thought. I guess I should defragment the drive. If the 50GB of Windows stuff is scattered in blocks from the beginning of the partition to the end, then there's no way to shrink anything. So I did that. I went back to the disk manager. Then it said I could shrink it by 15MB. Hrm. I did some more checking and saw recommendations that I turn off the Windows hibernation and page files. I did that. Disk manager told me I could shrink the partition by 60GB -- yes! back to GB! Did I want to do that? Well, let's not be greedy, disk manager -- let's just shrink by 40GB.
Result: an error message. "Shrink size too large."
More checking. I discovered that there are certain files -- "MRT Files" -- that get stuck in particular blocks on a Windows drive and that defragmenting won't budge. And then if you try to shrink a partition past the MRT blocks, you just get that cryptic and useless error message.
Okay, then. I downloaded a software demo that could defragment *and* move the MRT files to the top of the partition. I ran that. It took a while, and required rebooting directly into the new program instead of starting up Windows, but it eventually did its work and kicked me into Windows.
I noticed that the laptop did a reboot and put me directly into Windows instead of defaulting to OSX. Odd, I thought, but I figured it was some handy housekeeping by the demo software -- obviously Peter's just messed around with his Windows drive, so for the moment, he wants to reboot into Windows. Off I went, yet again, to the disk manager, and hooray! It let me shrink my Windows partition by 40GB.
Time to reboot into OSX. I rebooted the machine and wandered off.
I came back later. I was back in Windows.
Maybe Boot Camp was acting funny. I rebooted again, and made sure to hold down the "Option" key on reboot, and lo and behold, that gave me my Startup Manager. I saw... my recovey drive, great, and the Windows drive. The OSX partition had vanished. I tried booting into Windows. Explorer had no listing of the OSX drive. Disk manager had no record of the partition.
I rebooted into OSX 'recovery mode'. I tried selecting "reinstall OSX from Time Machine". (Side note: thank $DEITY I had backups.) That wizard gave me a menu of drives to install into: all external drives. Still no sign of my OSX partition. I brought up recovery mode's "oh god, everything's broken, HELP" version of Disk Manager. Now I could see the 80GB Windows partition and the little sliver of recovery drive. And there was a 125GB chunk of blank space. (The extra 40GB of so I'd shrunk off of the Windows drive seemed to have vanished, too.) It took me a long time to realize I needed to click on the empty space, click the "+" button, and put a new partition in there.
A long, long time.
So after failing hard at UI, I switched over to reinstalling my OSX setup into that newly-recreated partition. One "wandering off to a party and chatting with old friends" later, I was back at my computer, looking at OSX.
Great. I figured I'd cut my losses at this point. I'd figure out how to scrape together some extra disk space -- I just needed to not lose any more hours to this time vampire. So I fired up Parallels and started my bootcamped Windows in its usual VM.
Then Windows had a load error.
Hmm. I tried rebooting to the Startup Manager and going into Windows.
Load error again. It didn't even get to a 'loading' icon, it just died immediately with cryptic screen text.
Here's what I *think* happened: at some point that demo software had rearranged things not just in the Windows partition, but had somehow moved things into the OSX partition as well. So that's what killed OSX. And then when I went back through and reloaded my OSX install, that killed whatever weird dependency the demo had introduced.
Anyway, now my Windows install was hosed.
This was turning into a long day.
I rebooted into OSX and had a look at my partitions via Disk Utility. I figured there was nothing for it but to kill my Windows partition and start over.
At this point I noticed something odd. The partitions on the disk were in this order: the 125GB OSX partition, then the tiny recovery partition, and then the 80GB Windows partition. Note that I can't move partitions around -- not easily anyway -- so this means that, no matter what I did, so long as the recovery partition was still in that spot, my OSX partition was maxed out at 125GB. There was no way to grow it by a single GB -- which, you'll recall, was the whole point of going down this rabbithole in the first place.
So I took a deep breath and deleted the recovery partition. Then I deleted the Windows partition. I put in a new 80GB partition and I called it "Windows". Then I downloaded a Windows 10 ISO, started up Boot Camp Assistant, and got ready to reinstall. I got very confused at this point, because I thought you used BCA to install Windows into an *existing* partition. But, no, BCA just cleaves off part of your OSX partition and installs Windows into that. After staring, puzzled, at BCA for a long, long time ("why is putting in an 80GB Windows partition shrinking my OSX partition to 45GB?"), I finally sussed out what was going on. So: back to Disk Utility, deleting that "Windows" partition, and expanding the OSX partition to the whole drive (somehow my 'missing' 40GB had reappeared and I could set it to the full 250GB). Whew. I was finally off and running: I told BCA to give me an 80GB Windows partition, told it where the ISO file was, and away it went.
N.B.: I did *not* have a Windows backup on my MacBook. My reasoning there was that my MacBook copy of Windows only works with cloud data -- there's nothing on that partition that I don't have mirrored to a cloud service, and to a Windows machine that I actually *do* regularly back up to external hard drives. But this meant that, right now, I had to get my Windows install up to speed with every piece of software I regularly run.
Fortunately, by this point, I've got a "Windows Install Checklist" text file that runs down all the things I do to make Windows usable and bearable. (Step one: use Microsoft Edge to download a ninite installer. Step two: have ninite install a ton of apps, including Chrome, so that I never have to see Microsoft Edge again.)
And once that was done, I rebooted into OSX one more time, got Parallels running, and put my bootcamped Windows into a virtual machine in there. And finally, I was all set, running my OSX and Windows apps, and -- I checked df -h one last time, and lo and behold I had 80GB free on my OSX drive. And as god is my witness, I'll never be hungry again.