Firecracker VMM with additional disks

Adding more disks to the Firecracker VMM

Before looking at the networking options, I have looked at adding extra drives to my Firecracker VMMs. Storing data on the root file system will not scale well long term. Additional disks will be a good solution to persist application specific data across reboots and upgrades.

§Create the disk on the host

First, create an additional file system on the host:

1
2
dd if=/dev/zero of="/firecracker/filesystems/alpine-vol2.ext4" bs=1M count=500
mkfs.ext4 "/firecracker/filesystems/alpine-vol2.ext4"

§Reconfigure the VMM

Change the VMM drives configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  "drives": [
    {
      "drive_id": "rootfs",
      "path_on_host": "/firecracker/filesystems/alpine-base-root.ext4",
      "is_root_device": true,
      "is_read_only": false
    },
    {
      "drive_id": "vol2",
      "path_on_host": "/firecracker/filesystems/alpine-vol2.ext4",
      "is_root_device": false,
      "is_read_only": false
    }
  ],

and relaunch the VMM.

§Verify the configuration

In another terminal:

1
172:~$ sudo fdisk -l
Disk /dev/vda: 500 MiB, 524288000 bytes, 1024000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/vdb: 500 MiB, 524288000 bytes, 1024000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

I can mount it:

1
2
172:/home/alpine# mkdir /mnt
172:/home/alpine# mount /dev/vdb /mnt

Firecracker shows me:

[ 1800.756913] EXT4-fs (vdb): mounted filesystem with ordered data mode. Opts: (null)
[ 1800.758116] ext4 filesystem being mounted at /mnt supports timestamps until 2038 (0x7fffffff)

I can also write to it:

1
172:/home/alpine# ls -la /mnt/
total 14
drwxr-xr-x    3 root     root          1024 Feb 14 15:07 .
drwxr-xr-x   16 root     root          1024 Feb 14 15:49 ..
drwx------    2 root     root         12288 Feb 14 15:07 lost+found
1
2
172:/home/alpine# echo 1 > /mnt/test
172:/home/alpine# ls -la /mnt/
total 15
drwxr-xr-x    3 root     root          1024 Feb 14 15:50 .
drwxr-xr-x   16 root     root          1024 Feb 14 15:49 ..
drwx------    2 root     root         12288 Feb 14 15:07 lost+found
-rw-r--r--    1 root     root             2 Feb 14 15:50 test

§Live resize does not work

Not sure at this stage if this is because of how the system is built or if it’s a limitation of the VMM but I am not able to live resize the disk. Executing on the host:

1
dd if=/dev/zero bs=1M count=100 >> /firecracker/filesystems/alpine-vol2.ext4
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 0.0798364 s, 1.3 GB/s

and in the VMM:

1
2
172:/home/alpine# sudo blockdev --flushbufs /dev/vdb
172:/home/alpine# sudo blockdev --rereadpt /dev/vdb

does not reflect the change. The change only becomes visible after VMM restart.