QEMU Quickstart
■ Installation on Mac
■ Creating a virtual hard disk
■ Running ISO
■ Snapshots
■ Plans
QEMU is a very interesting emulator. It is small, around 100MB in my mac. It is open source and very old piece of software. It is used in many places. But the most important one in my opinion is the Android Emulator. It is really powerful and has lot of features. I'm planning to use QEMU as a replacement of VMWare and VBox. They are really heavy. But for my requirements I need something lightweight.
Installation on Mac
It was very easy because of HomeBrew. Just run:
brew install qemu
Creating a virtual hard disk
I'm creating a virtual hard disk of size 0MB. This will expand when the OS write data to it. And the format I'm using is qcow2. This supports creating snapshots of VM.
qemu-img create -f qcow2 alpine.img 0M
Running ISO
I'm running a 64bit Alpine linux. I gave 128MB RAM to it and I'm using user mode networking. It has some limitations. But basic networking will work fine. It is possible to SSH to the VM. Thats enough for me.
The monitor flag gives control to the VM after launching it. I'm using it for making snapshots.
qemu-system-x86_64
-m 128M
-cdrom alpine-standard-3.7.0-x86_64.iso
-monitor stdio
-hda alpine.img
-net nic -net user
Snapshots
While running the VM we can save the entire state of it as a snapshots. Its like pausing and resuming the entire OS. It is useful because next time we can load the snapshots instead of booting the entire system. Just like hibernation.
To save a snapshot:
savevm snapshotname
To list saved snapshots:
info snapshots
To load a snapshot while running VM:
loadvm snapshotname
To load snapshot while starting QEMU for that add this flag to it:
-loadvm snapshotname
Plans
I loved its simplicity. But I might forget the commands. So I'm planning to make a wrapper around it like Vagrant did.