Mike Levin SEO

Future-proof your technology-skills with Linux, Python, vim & git... and me!

A Tiny Virtual Machine That Runs Anywhere

by Mike Levin SEO & Datamaster, 08/23/2011

NOTE: What’ you’re looking for is Levinux. This is an article I wrote while making it. Please feel free to continue reading it, but the lightweight virtual Linux you can run in a few seconds from now is found here.

Okay, most of my purposes for these tiny servers is to run simple services. I don’t need all the device support, desktop GUIs and pre-installed components that come with so many Linux distributions. Also, now I’ve repositioned myself onto FOSS for my everyday desktop platform (thank-you, CommodoreUSA), and so it was time to trim down my virtual machine to the bare minimum possible. This article is about how I did that, and made it boot with a double-click from a Linux desktop now, as well as Mac and PCs.

Virtual Machine Runs Anywhere

I’m still no Linux guru yet, and when I started researching building my own distribution of Linux, doing all the things I’d like to do, like a nearly device-free compiled kernel, loading the entire OS into RAM for fast incorruptible virtual machine usage, and the like, I realized that I was at the base of a very, very steep learning curve. So, I started investigating all the lightweight Linux distributions that were out there.

The first thing you encounter is Damn Small Linux, or DSL. In fact, you encounter it over and over and over, including it’s derivatives, Not DSL. It took me awhile to get past it, then I found the other extreme, the Linux Router Project (LRP), which is basically fitting Linux onto a floppy disk with just enough to turn the host machine into a router, firewall or other network appliance. Surely there had to be something in the middle!

Then, I found Tiny Core, which is a desktop version of Linux that oddly advertises itself as a nomadic distribution. It further professes to be an ultra-small distribution that runs fast from ram, is Internet ready and unusually stable due to how it prevents writing to system files after boot. It further says that there is a console based version with CLI versions of the Tiny Core versions for the same functionality (installs, selective persistence, etc).

So, I fired up version one of my LittleSystem virtual machine (now, Levinux), where I test any old Linux version by renaming it’s iso file, dropping it into location, and double-clicking. Voila! I had Tiny Core and Micro Core Linux running just like any other distribution, so I followed their instructions for doing a Frugal hard drive install, and it is indeed frugal. The qcow2 image was about 30MB, then compressed down to 6.8 MB using qemu-img.

And now, since I’m on Ubuntu 11.04 as my everyday desktop machine now, I had to make my magic LittleSystem boot from a Linux desktop with a double-click, just like it did from OS X or Windows. So after a little research, I used Synaptic to install the entire Kernel-based Virtual Machine (KVM), tested whether I could run the existing harddrive.qcow, which worked perfectly, then proceeded to copy the dependency files into the LittleSystem directories and gave Linux it’s own launch bash script for double-click purposes. The only caveat is that since I’m not compiling my own QEMU binaries, I have to live with the locations it wants to find things, or override it with command-line arguments, which I did with the -L to make it find bios.bin in its own directory.

And voila! I now have a super-runnable, super-small, super-durable Linux keychain installation with network services! I’m thinking of terming this sort of thing yank-and-go, because so long as you have everything running from RAM, you don’t even need to keep the boot media installed after double-clicking the icon. It is actually acceptable to pop in the keychain or pendrive Linux (whatever you want to call it), double-click the icon, wait for it to boot, then eject the media!

It may be a little hard to grok the awesomeness or the utility, but it is like the gateway drug for FOSS server development. So unlike my last LittleSystem file, in which you had to find your own .iso file, and the download was only 3.4MB, LittleSystemV2 is 11.3MB (no longer available—now Levinux), but is a fully installed Micro Core Linux installation that will run with a double-click from a Windows, OS X and now, Linx desktop. You can’t do much with the resulting command-line console, but it does have network services, and represents a golden starting point for the yank-and-go keychain appliances that I have in mind.

I still have a steep learning curve in front of me, but perhaps thanks to Multi Core Linux, not quite as steep a learning curve as I thought. I still need to deal with the persistence issue, getting all the apps required to make this an appliance installed on hard drive but living in RAM on every boot. I also want to figure out how to lock down the box as much as reasonably possible and install a boot graphic like splashy. And finally, I’ll be turning this into a portable dev system, so I’ll need deal with the various persistence issues there.

Here’s a diagram of the Tiny Core architecture, credit to ixbrian. Click diagram to enlarge.