Sunday, April 8, 2012

Resizing My Windows Partition

My laptop is dual boot -- Windows 7, Linux Mint 11 (Katya) -- and I ran out of space on the Windows partition. (Microsoft has never seen a disk drive it wasn't happy to fill up for you.) As it turns out, alleviating this was child's play (well, if your child is pretty advanced) once I figured out one little thing ... which I record here, since I'll not doubt forget it and then have to repeat the process.

I booted my laptop from the Katya CD.  Like all Mint distributions, you can run Linux from the CD, which allows you to screw with the hard drive. Mint comes with GParted, the Gnome partition editor, which deserves every accolade that anyone has ever thrown at it. My hard drive started with a small boot partition, followed by the Windows partition (NTFS), and then one extended partition for Linux containing three logical partitions (home, swap and the main partition).  All I had to do was:
  1. Shrink the main partition (which had the most free disk space) to create some unallocated space.
  2. Move the main partition all the way to the right.
  3. Move the swap partition all the way to the right. The unallocated space was now at the beginning of the extended partition.
  4. Shrink the extended partition to give up the unallocated space (placing it between the NTFS partition and the extended partition.
  5. Expand the NTFS partition to soak up the free space.
  6. Apply all operations.
The sticking point, which I discovered only by clicking anything that couldn't outrun me, was that I needed to right-click the swap partition and select "Swapoff" in order move stuff around within the extended partition. When all was said and done, I used "Swapon" to turn the swap partition back on.

Once that was done, I booted into Windows, which immediately ran chkdsk to square things away.  I rebooted into Windows, and all looks good.

Actually, the first time I did this, GParted showed the correct (new) partition scheme, but when I got into Windows it showed the old partition size.  Back to Mint and GParted, and sure enough, the old partition table was there. I'm not sure whether I screwed something up. The first time chkdsk ran, it rebooted when my back was turned, and so booted into Mint (the default) rather than Win 7. I don't know if that was the problem, or if somehow the modified partition table was not written the first time around.  Anyway, it's all good now.

4 comments:

  1. As much as I trust these partition modification programs, and have done something similar to what you did in the past, it always gives me the chills. I'm glad all is well with your laptop.

    ReplyDelete
  2. I know what you mean. I back up anything that can't be reloaded from source repositories or disks, but even so it makes me nervous. Reloading can be a long process. I'm just glad my disk wasn't bigger -- it's hard to hold my breath that long. :-)

    ReplyDelete
  3. It sounds complicated but you managed to fix ‘em up with ease. That shrink, move, and expand stuff is sure tough but you did it effortlessly. =) No wonder all things went well.

    ReplyDelete
  4. It's actually fairly painless once I deduced what in hindsight was obvious: I can't move the swap partition while I'm using it (or while Linux thinks I'm using it), so I need to "swapoff" (why did I just hear that in Mr. Miyagi's voice)?

    ReplyDelete

Due to intermittent spamming, comments are being moderated. If this is your first time commenting on the blog, please read the Ground Rules for Comments. In particular, if you want to ask an operations research-related question not relevant to this post, consider asking it on Operations Research Stack Exchange.