Resizing a QEMU virtual machine, partition, and filesystem

I setup a QEMU virtual machine the other day so that I could play with Gentoo Linux, which we were talking about at work on Wednesday. Unfortunately, as I was halfway through the install process untarring the large Portage tree, I realized that I had made the root partition too small. Doh! Faced with the prospect of having to make a new virtual machine and repeat the length install process, I wondered if there was a way to expand the virtual machine image and repartition without losing any data.

Well, it’s possible and here’s how I did it.

First, use the dd command to expand the image. This is as simple as telling it to write 0 bytes at the point where you want the file to end. I used bs=1 because the seek parameter takes it value in blocks and setting the block size to 1 was the easiest way to make it do what I want without having to do any arithmetic.

dd bs=1 if=/dev/zero of=gentoo_disk.img seek=2G count=0

Then I checked that it worked with qemu-img info:

marc@ubuntu:~$ qemu-img info gentoo_disk.img
image: gentoo_disk.img
file format: raw
virtual size: 2.0G (2147483648 bytes)
disk size: 1.3G

Then I launched my virtual machine:

qemu -user-net -boot d -cdrom install-x86-universal-2005.1-r1.iso 
gentoo_disk.img

Within the virtual machine, I then used fdisk to delete last partition and add it back. And then I resized the ext2 filesystem with:

e2fsck -f /dev/hda3
resize2fs /dev/hda3

This was just beautiful. Another reason to love the flexibility of virtual machines. Essentially that dd command was the analog of saying, “Nah, a 1 GB hard drive is not going to do it for this machine so let me magically make it into a 2 GB drive and leave all my data intact.”

Actually, the parts of this recipe from the fdisk and beyond should be applicable to any Linux environment. It’s quite cool that you can resize a filesystem in Linux – I know of no way to do this in Windows, at least not without some kind of third-party tools. And on the Mac, I really have no idea.

Anyway, this little bit of magic put a smile on my face.

PyGTD

PyGTD, by Keith Martin, is an interesting little Python command-line program for GTD. You input your projects, tasks, and contexts into some specially formatted files and run this program and it spits out a todo.txt file which is your reference. As you complete tasks, you update the todo.txt file and run the program and it syncs the changes back to your context files.

This is cute and might be the ticket for certain die-hard Unix command-line freaks, but I found it a bit too complex and cumbersome. And for me, if it’s not drop-dead easy, I will end up not doing it in the heat of the moment when it’s a busy day and I have things flying at me from all directions.

As it happens, I’ve been playing a bit lately with my own homegrown Python-based command-line GTD setup. Mine I think is pretty simple and thus tenable as something that could be used on a daily basis, but I’ll have to test it in the real-world for a few weeks to see how it “scales”. If it goes well, I will be sure to post about it.

Fixing Windows Update error 0xC800021F

I was trying to run Windows Update and Microsoft Update to get all the updates for a Windows 2000 installation that I’m running in a QEMU virtual machine on my Ubuntu Linux box, but it kept failing with error 0xC800021F.

Luckily, I found this page which recommended the following sequence of steps which seemed to fix the problem:

regsvr32 MSXML3.dll /s
net stop wuauserv
cd /d %windir%\SoftwareDistribution
rd /s /q DataStore
net start wuauserv

Now that it’s working, I have 27 security updates to download!

DreamHost

Seidio Treo 650 Hotsync cable – with a Hotsync button!


Great accessory. My Boxwave miniSync seemed to be acting flakey (couldn’t get Hotsyncs to work, I suspect it takes too much abuse in my pocket) and I had long wanted the Seidio retractable sync charge cable after reading the review of it at treoAddicts . It’s just really convenient to have a Hotsync button on the cable. No more futzing around with the Treo itself and keyguard, etc. Just reach over and press the button. Simple and easy.

I smile every time I push the button. It’s funny how such a simple product can be so satisfying.

Xinha Here! Awesome Firefox extension

Great Firefox extension.

Xinha Here allows you to right click on any textarea in a page and select Xinha Here to fire up a nice WYSIWYG HTML editor in a separate window. Bolding, italics, bulleted lists, links, images, etc. are all supported and there are keyboard shortcuts in addition to toolbar icons. Do your editing as you see fit and then when you hit OK, the corresponding HTML is pasted into the textarea (unfortunately, it seems to get paste in as one long line, it would be nice if it broke my bullet lists on to separate lines, but oh well…maybe the next version).

This is a great way for me to get WYSIWYG editing for my blog postings without having to use a WordPress 2.0 beta (which may not be stable or might have security issues) and I get this WYSIWYG editing capability for other uses too.

Great stuff.