-
-
Save jvns/c8470e75af67deec2e91ff1bd9883e53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -eu | |
[ -e hello-vmlinux.bin ] || wget https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin | |
[ -e hello-rootfs.ext4 ] || wget -O hello-rootfs.ext4 https://raw.githubusercontent.com/firecracker-microvm/firecracker-demo/ec271b1e5ffc55bd0bf0632d5260e96ed54b5c0c/xenial.rootfs.ext4 | |
[ -e hello-id_rsa ] || wget -O hello-id_rsa https://raw.githubusercontent.com/firecracker-microvm/firecracker-demo/ec271b1e5ffc55bd0bf0632d5260e96ed54b5c0c/xenial.rootfs.id_rsa | |
TAP_DEV="fc-88-tap0" | |
# set up the kernel boot args | |
MASK_LONG="255.255.255.252" | |
MASK_SHORT="/30" | |
FC_IP="169.254.0.21" | |
TAP_IP="169.254.0.22" | |
FC_MAC="02:FC:00:00:00:05" | |
KERNEL_BOOT_ARGS="ro console=ttyS0 noapic reboot=k panic=1 pci=off nomodules random.trust_cpu=on" | |
KERNEL_BOOT_ARGS="${KERNEL_BOOT_ARGS} ip=${FC_IP}::${TAP_IP}:${MASK_LONG}::eth0:off" | |
ip link del "$TAP_DEV" 2> /dev/null || true | |
ip tuntap add dev "$TAP_DEV" mode tap | |
sysctl -w net.ipv4.conf.${TAP_DEV}.proxy_arp=1 > /dev/null | |
sysctl -w net.ipv6.conf.${TAP_DEV}.disable_ipv6=1 > /dev/null | |
ip addr add "${TAP_IP}${MASK_SHORT}" dev "$TAP_DEV" | |
ip link set dev "$TAP_DEV" up | |
cat <<EOF > vmconfig.json | |
{ | |
"boot-source": { | |
"kernel_image_path": "hello-vmlinux.bin", | |
"boot_args": "$KERNEL_BOOT_ARGS" | |
}, | |
"drives": [ | |
{ | |
"drive_id": "rootfs", | |
"path_on_host": "hello-rootfs.ext4", | |
"is_root_device": true, | |
"is_read_only": false | |
} | |
], | |
"network-interfaces": [ | |
{ | |
"iface_id": "eth0", | |
"guest_mac": "$FC_MAC", | |
"host_dev_name": "$TAP_DEV" | |
} | |
], | |
"machine-config": { | |
"vcpu_count": 2, | |
"mem_size_mib": 1024, | |
"ht_enabled": false | |
} | |
} | |
EOF | |
firecracker --no-api --config-file vmconfig.json |
The JSON file now also appears to fail with firecracker 1.0 with:
2022-03-01T14:56:05.112106369 [anonymous-instance:main:ERROR:src/firecracker/src/main.rs:453] Configuration for VMM from one single json failed: Invalid JSON: unknown field `ht_enabled`, expected one of `vcpu_count`, `mem_size_mib`, `smt`, `cpu_template`, `track_dirty_pages` at line 24 column 16
Removing the ht_enabled
field gets a bit further to:
[ 0.091330] List of all partitions:
[ 0.091665] No filesystem could mount root, tried:
[ 0.091666] ext3
[ 0.092067] ext4
[ 0.092217] squashfs
[ 0.092377]
[ 0.092733] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,0)
[ 0.093341] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.14.55-84.37.amzn2.x86_64 #1
[ 0.093893] Call Trace:
[ 0.094086] dump_stack+0x63/0x89
[ 0.094335] panic+0xdf/0x239
[ 0.094557] mount_block_root+0x27c/0x2af
[ 0.094880] ? set_debug_rodata+0x12/0x12
[ 0.095181] mount_root+0x65/0x68
[ 0.095428] prepare_namespace+0x12f/0x167
[ 0.095783] kernel_init_freeable+0x21a/0x247
[ 0.096059] ? rest_init+0xb0/0xb0
[ 0.096059] kernel_init+0x9/0x100
[ 0.096059] ret_from_fork+0x35/0x40
[ 0.096059] Kernel Offset: disabled
[ 0.096059] Rebooting in 1 seconds..
@alexellis The script will work if you use the images provided in firecracker repo readme.
Instead of
[ -e hello-vmlinux.bin ] || wget https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin
[ -e hello-rootfs.ext4 ] || wget -O hello-rootfs.ext4 https://raw.githubusercontent.com/firecracker-microvm/firecracker-demo/ec271b1e5ffc55bd0bf0632d5260e96ed54b5c0c/xenial.rootfs.ext4
[ -e hello-id_rsa ] || wget -O hello-id_rsa https://raw.githubusercontent.com/firecracker-microvm/firecracker-demo/ec271b1e5ffc55bd0bf0632d5260e96ed54b5c0c/xenial.rootfs.id_rsa
Use
arch=`uname -m`
dest_kernel="hello-vmlinux.bin"
dest_rootfs="hello-rootfs.ext4"
image_bucket_url="https://s3.amazonaws.com/spec.ccfc.min/img/quickstart_guide/$arch"
if [ ${arch} = "x86_64" ]; then
kernel="${image_bucket_url}/kernels/vmlinux.bin"
rootfs="${image_bucket_url}/rootfs/bionic.rootfs.ext4"
elif [ ${arch} = "aarch64" ]; then
kernel="${image_bucket_url}/kernels/vmlinux.bin"
rootfs="${image_bucket_url}/rootfs/bionic.rootfs.ext4"
else
echo "Cannot run firecracker on $arch architecture!"
exit 1
fi
if [ ! -f $dest_kernel ]; then
echo "Kernel not found, downloading $kernel..."
curl -fsSL -o $dest_kernel $kernel
echo "Saved kernel file to $dest_kernel."
fi
if [ ! -f $dest_rootfs ]; then
echo "Rootfs not found, downloading $rootfs..."
curl -fsSL -o $dest_rootfs $rootfs
echo "Saved root block device to $dest_rootfs."
fi
echo "Downloading public key file..."
[ -e hello-id_rsa ] || wget -O hello-id_rsa https://raw.githubusercontent.com/firecracker-microvm/firecracker-demo/ec271b1e5ffc55bd0bf0632d5260e96ed54b5c0c/xenial.rootfs.id_rsa
echo "Saved public key file."
For anyone running the initial script and failing with "unknown field ht_enabled
", have in mind that ht_enabled
has been renamed to smt
. See also https://github.com/search?q=repo%3Afirecracker-microvm%2Ffirecracker%20ht_enabled&type=code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jvns FYI there is a 404 on: [ -e hello-rootfs.ext4 ] || wget -O hello-rootfs.ext4 https://raw.githubusercontent.com/firecracker-microvm/firecracker-demo/ec271b1e5ffc55bd0bf0632d5260e96ed54b5c0c/xenial.rootfs.ext4
This has moved to an S3 bucket, see upstream if you want to keep this up to date.