Since I decommissioned my home server in favour of an NSLU2 (a NAS), I’ve found myself without a Linux machine to much about with or develop on while on the go (well, whenever I can’t use my laptop). So instead I’ll be using a virtual machine by running QEMU from my USB drive. Since my old server ran Debian, and since I haven’t checked it out in a while other than using it’s offspring Ubuntu.
Note: I would recommend getting this set up running on a folder on your hard drive, then copying it to your USB drive if you intend to do that. It will probably be faster, and it will save you trouble if your disk image isn’t large enough.
To get a QEMU binary for Windows, you can download from here, although this is no longer outdated and uses the 0.9.0 release. Unzip it wherever.
Open up a command prompt. cd to the QEMU directory. Create two disk images by running:
qemu-img create -f qcow2 debian.img 1024M .
qemu-img create -f qcow2 home.img 1024M .
This creates two 1024Mb sized qcow images for you to work with – one for your system and applications, and one for your home directory(ies). Obviously you can change the name and size to suit. My USB drive is 4Gb – if you have something smaller like 2Gb, use 768M for debian.img and 512M for home.img. If you have a 1Gb drive, you could try smaller sizes, but you’d probably have more luck trying something like DSL (Damn Small Linux) or puppylinux. I originally tried this with a cumulative 512M for the root and swap partitions, and it wasn’t large enough.
Grab a Debian CD image. I would recommend one of the netinst images. I’m using the Lenny Beta 2 image (here, or the .torrent), but you can use a stable image, or one of the weekly / daily snapshots. Put the image in the same directory as QEMU.
Create a file debian.bat, with the command:
qemu.exe -net user,vlan=1 -net nic,model=rtl8139,vlan=1 -L . -m 128 -hda debian.img
-cdrom debian-LennyBeta2-i386-netinst.iso -boot d -soundhw all -localtime
You can change the -m option for more or less virtual RAM, you can leave out the model=rtl8139 to use the default ne2k driver (I just like Realteks, even virtual ones ;-)), and obviously change the -cdrom option if you use a different image. You can also use Kqemu, but I’m not going to go into that.
Additionally, you can use the command
-M isapc (ISA network card), but for that you will have to remove the model=rtl8139; and before using the installer, press [TAB] and add
noacpi nolacpi to the installer startup options, otherwise QEMU will crash.
Debian can then be installed as normal. I didn’t install anything that depends on X as I don’t want a graphical system, thought QEMU should handle it fine if you do. I used the partition manager to create a swap partition of about 128 megs. Mount your second ‘hard drive’ (home.img) under “/home”. if you don’t do this now you can do it later by editing
(My second disk image / hard drive is mounted as:
/dev/hdb1 /home ext3 errors=remount-ro 0 1
Depending on the CPU of your host machine, whether or not you are using Kqemu, and the speed of your internet connection it will take anywhere from 10 minutes to two hours to install.
Once installed you can
apt-get install build-essential, or
apt-get install nethack, or
apt-get install python, or whatever floats your boat. Or, if you’re like me, you can faff about trying to enlarge your partitions because they aren’t big enough.