Light weight tool ( Native linux KVM or lkvm ) to boot a linux guest image in KVM setup

Hmm.. I tried lkvm or Native Linux KVM tool in past and was watching the patches coming into this space for this period. Its improved a lot from the time I first noticed it.

Today I decided to try native linux KVM tool again and here is the story.

First of all, let me point to the project itself :

For the people who doesn’t know what it is , I would suggest to watch this video and then follow the ‘github’:

The goal of this tool is to provide a clean, from-scratch, lightweight
KVM host tool implementation that can boot Linux guest images (just a
hobby, won’t be big and professional like QEMU) with no BIOS
dependencies and with only the minimal amount of legacy device

The steps to give a try with the tool is same as mentioned in the above URL.. How-ever in short you need below prerequisites:

1) Native linux kvm binary (lkvm)
2) A kernel image (bzimage)

The ‘rootfs’ can be created by below way:

Now lets see whats inside this ‘default’ rootfs:

Run a VM:

Then you got a shell:

In HOST system you can below process :

Wow, I like the process string : pretty light weight when compared to ‘qemu-kvm’ process output!!!

Let me explore some more on booted VM:

The running/created VM has a filesystem called “/host” inside it, its basically the fileystem of your host system mounted as READONLY volume using ‘virtfs-9p’ as shown below:

If you dont know whats virtfs-9p please refer:

You can see it from guest :

Along with above , other ‘pseudo’ filesystem are also mouned:

To exit the VM:

Now let me run a VM as sandbox and execute ‘cat /etc/resolv.conf’

Here you go:

#./lkvm sandbox -k ../../arch/x86/boot/bzImage — cat /etc/resolv.conf

The requested output was produced

(String starting with # Generated..

) and the session was exited.

ps # As expected ‘init’ created ‘’ with below entry 🙂

Reference #

Leave a Reply

Your email address will not be published. Required fields are marked *