Shauna's Blog

When you just need space...

Originally at http://www.shaunagm.net/blog/2013/11/when-you-just-need-space/

Recording this for posterity, in case it helps someone the way random websites helped me today.

About a month ago my computer started complaining about a lack of memory. At first I managed this by carefully deleting unnecessary files, but eventually annoyance overcame laziness, and I decided to try and find myself space somewhere.

A quick search found me the command for listing the partitions on my computer: df -k. That site led me to expect that I’d find partitions labeled something like /dev/sda1, where dev means the part of the directory tree containing devices, sd means that it’s a block device, a means that it’s the first block device found, and 1 means that it’s the first partition on the block device a. Awesome. And df -k did show me such wonders. But when I looked for the partition I was currently in (the one with a / under the column “mounted on”) it didn’t have that format - it was, instead, /dev/loop.

It turns out a loop device is a fake device that’s actually running within some other filesystem. (Though I wasn’t able to figure out why it’s called a loop device. Maybe its name is fake, too.) When I installed Ubuntu on my new computer last spring, I must have used Wubi, which created a disk image within Windows, and promptly forgotten about it. In my defense, I got the computer a) after a friend accidentally dumped water on my old laptop and fried it and b) in the middle of PyCon sprints, so I wasn’t exactly documenting everything I was doing. Anyway, this explains a problem I had a few months ago, where I went into Windows to watch Netflix, and then couldn’t load Ubuntu - apparently Wubi doesn’t run when you shut down Windows improperly, which I must have done.

This left me with a clear, if complicated, plan of action. I needed to:

a) back up all my data!! b) change the partition sizes as planned, minimizing the Windows partition and making a new one I could migrate Wubi to c) migrate my Ubuntu install from /dev/loop to the new partition d) change partition sizes again, as migrating to a new partition would free up significant unused space in Windows

I immediately ran into difficulty when I didn’t see my live USB drive on the start up menu. Nor did I see the option to boot from a usb drive on the BIOS setup menu. Where I needed to be, apparently, was the boot menu, a fact I learned while clicking through every possible option in the BIOS menu and grumbling under my breath. From there, I was able to load Ubuntu (I was unsure if the “Try Ubuntu” option would work, but it was fine) and open GParted, the partition editing tool. I asked GParted about the size of my Windows partition, which sent it into a panic:

NTFS is inconsistent. Run chkdsk /f on Windows then reboot it TWICE! The usage of the /f parameter is very IMPORTANT! No modification was and will be made to NTFS by this software until it gets repaired.

I appreciate a piece of software with strong opinions. I dutifully logged into Windows and ran chkdsk /f, where I was told that I needed to restart my computer. (If I learned anything today, it’s that changing a partition you’re currently using is Very Bad News.) As I restarted Windows, before it actually booted, chkdsk worked its magic. Then I rinsed and repeated, since GParted was so insistent.

I went back to my /dev/loop Ubuntu faux-partition, where I followed these instructions. Except for a brief pause to reformat the destination drive from NTFS to EXT4, it went very smoothly. “Migrating” Wubi really means copying it - after all, to move it via a shell script from inside Wubi would be to change the partition you’re currently on - so a df -k showed no change, but when I restarted Ubuntu and tried again, it told me that I was now on /dev/sda4. Success!

I restarted into Windows where I deleted Wubi to save room, then restarted again into the live USB (I swear I have never restarted my computer as many times as I did today) so I could readjust the partition size. I gave most of the free space on the Windows partition to the new Ubuntu partition. GParted warned me that moving the start of the partition could cause GRUB to fail to boot, and I was all ready to re-install GRUB, but Ubuntu booted just fine. So here I am, writing this blog post from a luxurious, real partition three times the size of my old one. It feels good.

image of a resort