Power in society comes from running your code where you want, when you want. But it takes a really long time to get to that point, so the meanwhile, there’s QEMU—a computer emulator that runs on all x86 platforms without even needing an install. That means you can carry around a virtual computer on your USB keychain drive that you can fire-up on anyone’s Windows machine, on a Mac OS X machine, or even on computers running Ubuntu Linux, and the like. You don’t need admin privileges. This gives you a whack-a-mole foundation on which you can run your code, and sets you on the road towards doing the same with the Amazon or Rackspace clouds, rack-mounted server-class hardware, or even a new breed of micro-servers that you can fit in your pocket and host out of your home.
Here is a FAQ about Hardware, Virtualization and The Cloud
…and a FAQ about QEMU in particular
One of the things you might like to do with a QEMU virtual machine is run it like a server so it can receive and answer requests from the "outside world" like a webserver or SSH server. QEMU's default security context makes this uniquely challenging, and even once you know the trick, you will only ever be able to make the services work on "high ports" of the host machine's address. By this, I mean the standard port for http is 80, but if you're running a webserver on QEMU, it has to be mapped (NAT) to port 8080 on the host machine and there's no way to change this unless you patch the source code. This is a security precaution because QEMU can be run clandestinely on a host machine and intercept traffic intended for the host, processing and relaying it for nefarious purposes. Once you accept the fact that your services are going to appear as if on host machine high-ports, then allowing traffic sent to the host machine to reach QEMU is a simple matter of running QEMU with the -redir parameter. For example, qemu -redir tcp:8080::80 will redirect any TCP/IP traffic sent to the IP of the host machine on port 8080 to port 80 of QEMU, where you might be running Apache, nginx or g-wan on port 80. QEMU will respond and it will be returned seemingly from the host machine on port 8080, and the entire process is transparent.
QEMU has dependencies that are not normally "baked in" to the binary and relies on common libraries on the host machine. The exact set of libraries that are required varies based on the version of QEMU, and this makes it a bit challenging to make a truly portable QEMU of the type you can carry around on USB and run with a double-click on any host machine without an install. However, there are various tricks you can use to know what those dependencies are and then put them in the same directory as the QEMU binary and set an environment variable before running QEMU so that it looks for its library dependencies in the same folder its run from. This is what I have done with Levinux
for various host OSes including Mac OS X, Windows, and various versions of Linux.
Well, you can but every time you restart your computer, you're going to have to remember to restart your virtual machines as well, or figure out a way to auto-start them. There are other complications that make it almost not worth doing, such as attempting to create a static IP on the network for your virtual machine, while the host machine in all likelihood is getting a dynamic IP. It's possible, but kooky. Also, you'll probably have to use something other than QEMU for your VM's, unless you want to use strange high-number ports for your services, like putting your webserver on port 8080 (instead of the default 80). That's because the security context of QEMU only lets you route high-port traffic into your VM, in an attempt to cut down the type of trojan abuses that QEMU could be used for when running secretly. For these and about a dozen other reasons, its really best to just run your hobby servers on real hardware. The good news is that real hardware can be real cheap these days, like the $35 Raspberry Pi, and ultimately save you money because leaving a Raspi running 24x7 will take a lot less electricity and cost less on your electric bill than preventing your main desktop computer from being able to go into hibernate or sleep-mode—another thing you'll have to do to allow a VM server to always be available. This is the point I advise people who are gradually getting acquainted with Linux server to just throw some dedicated 24x7 always-on low-power hardware to the cause.
I've never done this myself, but it is theoretically possible—more-so than on the other platforms like VirtualBox, VMWare and Virutal PC that require an install. Now the problem is that the things that happen during the install actually greatly enhance the performance of the virtual machine (makes virtual Windows faster), while QEMU using its very non-intrusive no-install approach has fewer choices to achieve acceleration, so while your portable Windows may run from a USB thumb drive or Dropbox with no install, it may not be very fast. The exception to this is when your host machine is a new enough Linux to have KVM (the kernel virtual machine), which QEMU should automatically detect and provide much higher hardware-enhanced performance. But if your host machine is another Windows box or OS X, you are unlikely to see this performance enhancement, and may go nuts waiting for things to happen, in which case you'd be better off with VMWare, VirtualBox or Virtual PC.
That's like half the point of QEMU. QEMU doesn't need to be installed. Unlike VMWare, which completely transforms your system with all the virtual network interfaces and other software it permanently wedges into your host OS, QEMU can run with a double click from a USB thumb drive you pop into a PC, Mac or Linux box to which you have no administrative privileges. If you use Dropbox and keep a QEMU virtual machine in the cloud, you can automatically just run a virtual machine with a double-click on nearly any x86-based machine
you log into Dropbox with—meaning all modern Macs, Windows and other Linux desktops and laptops. Once you quit out of QEMU, it doesn't even leave a trace on the host machine. It's like it was never there—making QEMU a uniquely (versus VirtualBox, VMWare, Virtual PC, etc) nomadic virtual machine. QEMU is very special not only because it's a totally free and open source VM, but because of how it doesn't need to alter the host OS at all to work.
There is one main default networking setup under QEMU which is poorly understood, but extremely intelligent and worth understanding. Then you can just go with it, instead of fighting it. The main thing to know is that QEMU has a DHCP server and router built-in, much like your home WiFi router, but essentially secret, only known to your host machine (the computer running QEMU) and your QEMU virtual machine guest. So long as your Linux boot image is setup to ask for a dynamic IP from a DHCP server (a common setup), QEMU networking should just automatically work. This is smart, because the presence of QEMU itself is kept secret from your network, because it never asks for an IP or otherwise advertises its presence. This is an excellent security context for VMs.
Instead of asking your network's DHCP server for an IP, your QEMU guest always just gets the IP 10.0.2.15, issued by the built-in DCHP server at 10.0.2.2, which is also QEMU's firewall and router for when your guest makes outbound requests to reach the Internet at large—but which makes it look like normal traffic from the host machine and not a virtual machine running on it. When you run QEMU, you are essentially running a virtual local area network (VLAN) on your one physical machine shared by guest and host. Once you truly understand this fact, you can embrace it and then start to expand on the default to suit your needs—like using NAT rules (redir params when running QEMU) to make QEMU servers available to your host machine on addresses like localhost:8080, such as I do with Levinux
. Unarchive. Double-click. Server set up.
Note: Why not try my respin of Tiny Core Linux called Levinux, which runs from your Mac, Windows or Linux desktop with a double-click and no install?
Tiny Core Linux. This is for all the same reasons that it's the best Linux distribution for a USB drive. The two questions are very related. QEMU is the best choice for the virtual machine, because it can be configured so that a double-click will allow your virtual machine to run from the desktop of either a PC, Mac or Linux desktop—complete x86 machine portability! The files are so small, that if you partition your drives right, you can even run it from a Dropbox cloud drive without causing too much network traffic as your VM is running. This is an amazing way to work, and I highly recommend it.
Note: Download Levinux and see the Core Linux (text-only) portion of Tiny Core Linux running with a double-click from your Mac, Windows or Linux desktop without even an install. It's set up as a full-fledged persistent development environment.
Tiny Core Linux... hands-down. Thanks to busybox, and minimal necessary hardware support, it comes in at about 12MB, and only about 8MB if you don't want graphics. That's 1/10th the size of the smallest Linux images using debootstrap, or even the stripped-down AMI virtual machines in the Amazon EC2 cloud. And that's with a modern Linux kernel and its own repository system for installing software! Of course, this makes also makes it a very strange Linux to use for most people—but for the same reasons, a very good one to learn on. It also makes Tiny Core Linux the ideal choice for a USB stick based Linux, particularly with QEMU, so it's portable between all x86 platforms, and can run without an install or admin privileges.
Until there is a better solution, you use the Q port of QEMU
. Problem is, the last update to their site was FOUR YEARS AGO! And while the version they're giving out works just fine—even on Lion—it's feeling a bit crusty. The main branch of QEMU has come out of beta and is at version 1 stable. If anyone knows a way to get some basic, competent, minimally patched compile of QEMU off the main branch to work on the Mac, please let me know. This is key to one of my projects!
Here are some articles about Hardware and QEMU:
- Using QEMU Ubuntu Tutorial NOTE: Want a QEMU Tutorial? Download Levinux and run Linux server with a double-click from your Mac, Windows or Linux desktop with no install. Lesson #1: software that doesn’t require an install is easy to start using.
I’m tempted to walk you through some of the different devices to be used as a micro-server. Those would ...
- How to Partition Hard Drive with QEMU After all that to start the Ubuntu Server install, I’m going to backtrack for this post and talk about using a more friendly LiveCD, namely Knoppix. If you make a copy of your QEMU directory so far, you can freely go through a complete Ubuntu Server install, knowing that you have the ultimate “undo” of ...
- Configuring Lilo on Debian and QEMU At this point, I’m actually going to shut down and copy out the hard drive file for the ultimate undo. So far, I’ve done that three times. I have:
This way, I can rename any of them back to harddisk.raw, drop it into the QEMU directory, and go back to that state. After doing that, all ...
- Your Debian QEMU JeOS Box Ready to Boot Note: If you’re looking for the juiciest jeOS box, download Levinux, my personal Linux distro (actually, a remix), which is ~15MB to download, and inflates to only about ~50MB even after pulling down Python, vim & git for web development!
Okay, I think we’re all getting a bit impatient now to see our Noah’s Arc JeOS ...
- How To Use QEMU on Mac OS X Note: You can instantly download and start playing around with QEMU and Linux on Mac OS X using my own respin distribution of Linux called Levinux. <– Visit this page and download it!
Welcome everyone searching for qemu on the Mac. Let’s get it out of the way: this article is about Q, the still-viable, but ...