Layers of abstraction

I’m a geek. I know it.

In the lulls between scrambling around this week, I’ve gotten to dig into PC emulation some more. Professionally, I can use this to set up sandboxes and load software not widely available on our network more safely. Personally, I get a kick out of running a computer within another computer.

Emulators work by basically creating a software interface to the hardware on your machine and then fooling an operating system into thinking it has physical hardware. I’ve got a 4 gigabyte file that is the machine “image” (the C:\ drive) that is loaded when the virtual machine starts up. The virtual machine knows nothing about the physical PC that hosts it – as far as it can tell, it’s another computer all its own. So, for example, I’m running Windows XP virtually on my Windows 2000 laptop. It runs in its own window and voil, I’ve now got two computers. Pretty nifty, eh?

(If your eyes have glazed over, stop now. It only gets worse.)

For Windows emulation, the main tool I use is Microsoft VirtualPC. It’s complete, robust, and plays nicely with everything on my work machine. I keep all the PC images on an external drive, so they can move to my home computer as needed. It’s easy to set up and manage, and hasn’t given me any problems.

Linux emulation gets even cooler, because I’ve got three ways of doing it. The first option is to install Linux in a virtual image like I would a Windows machine. I can use the packages mentioned above, or use the newcomer coLinux. I had seen this a few releases ago when it was more proof-of-concept than usable, but it’s improved substantially since then. It’s clean, fast, and fairly easy to set up.

Secondly, I can grab a bootable CD Linux such as Knoppix and play. I could boot that on my laptop itself – it doesn’t damage the existing system – but then I can’t switch back and forth easily. Much cooler is to take the ISO image of Knoppix and boot a virtual machine with it. I don’t need to use up my CD drive as I’m working totally with image files, and I can swap back and forth between the virtual and physical machines to my heart’s content.

Lastly, I can set up coexisting Linux environments. This isn’t emulation like above, but more a way to bolt on Unix functionality to an existing Windows system. I can start either a traditional DOS prompt, or I can start a Bash shell, all on my Windows machine. This gives tighter integration with the native operating system, but isn’t a full-fledged Linux system. The oldest of the bunch for these is Cygwin, which has come a long way in the last couple of years (when I played with it last) but still gave me some setup headaches on XP. Microsoft also has an entry in this world with Services for Unix, which set up cleanly and ran smoothly.

So, what do I have running right now? I’m running Knoppix on top of Windows XP inside my Windows 2000 machine. And I smile every time I say that. Whee!