Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firecracker microVM: how to create custom Firecracker microVM and file system images [closed]

I went through the Getting Started guide of Firecracker microVM via building from source via Docker and following the steps. I have working knowledge of Docker via CLI/Visual Studio UI/ECS and remember building AWS AMIs manually before the Docker ubiquity...

However, this part is completely uncharted territory for me and several googling rounds over the past weeks did not help:

Next, you will need an uncompressed Linux kernel binary, and an ext4 file system image (to use as rootfs). You can use these files from our microVM image S3 bucket: kernel, and rootfs.

  1. What is hello-vmlinux.bin and how to build one with my pre-installed apps? Could it be done similarly to Docker or AMI, i.e. in a simple way?

  2. What is hello-rootfs.ext4 file and how to create a custom one for the same purpose as in 1. above?

like image 706
V.B. Avatar asked Dec 27 '18 01:12

V.B.


People also ask

What is a rootfs img?

A rootfs image is just a file system image, that hosts at least an init system. For instance, our getting started guide uses an EXT4 FS image with OpenRC as an init system. Note that, whichever file system you choose to use, support for it will have to be compiled into the kernel, so it can be mounted at boot time.

Does firecracker use KVM?

Firecracker is a virtual machine monitor (VMM) that uses the Linux Kernel-based Virtual Machine (KVM) to create and manage microVMs.

What is the Firecracker VMM?

The main component of Firecracker is a virtual machine monitor (VMM) that uses the Linux Kernel Virtual Machine (KVM) to create and run microVMs. Firecracker has a minimalist design. It excludes unnecessary devices and guest-facing functionality to reduce the memory footprint and attack surface area of each microVM.

Why Firecracker MicroVMS?

Each Firecracker microVM runs with a reduced memory overhead of less than 5 MiB, enabling a high density of microVMs to be packed on each server. Firecracker provides a rate limiter built into every microVM. This enables optimized sharing of network and storage resources, even across thousands of microVMs. How It Works

Why choose Firecracker?

This enables fast startup times. Firecracker initiates user space or application code in as little as 125 ms and supports microVM creation rates of up to 150 microVMs per second per host. Scale and efficiency

How do I control the Firecracker process?

You can control the Firecracker process via a RESTful API that enables common actions such as configuring the number of vCPUs or starting the machine. It provides built-in rate limiters, which allows you to granularly control network and storage resources used by thousands of microVMs on the same machine.


1 Answers

vmlinux.bin - it's linux kernel image which will be used by VM. Probably you can use provided kernel w/o any modifications.

hello-rootfs.ext4 - it's a file which contains root file system for your VM. You have to modify the file to add your application.

  1. Mount provided rootfs to do your changes

mkdir -p /tmp/myroot

sudo mount rootfs.ext4 /tmp/my-rootfs

  1. Copy your application and all dependencies to /tmp/my-rootfs/opt/
  2. Add start script for your application to /tmp/myroot/etc/init.d/ Start script have to be prepared for OpenRC init system.

  3. Unmount rootfs

    sudo umount /zprojects/modus/sketch/images/hello-rootfs.ext4

Start firecracker so your application will be started as a part of VM init system start up.

You probably would like to check how to provide network access to your VM also: vm network setup doc

like image 165
MaxV Avatar answered Nov 15 '22 06:11

MaxV