From 9bdc2b4fec2f5d11c9648916f362206d31ab6e0d Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Sun, 17 Apr 2022 00:00:05 +0200 Subject: virtio: add script and make target to build ext2 device --- content/2021-12-02-toying-with-virtio/Makefile | 7 ++++++- content/2021-12-02-toying-with-virtio/build_ext2.sh | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 content/2021-12-02-toying-with-virtio/build_ext2.sh (limited to 'content/2021-12-02-toying-with-virtio') diff --git a/content/2021-12-02-toying-with-virtio/Makefile b/content/2021-12-02-toying-with-virtio/Makefile index 4009862..d4286af 100644 --- a/content/2021-12-02-toying-with-virtio/Makefile +++ b/content/2021-12-02-toying-with-virtio/Makefile @@ -6,6 +6,7 @@ help: @echo "Build targets:" @echo "* init - Build busybox based initramfs." @echo "* kernel - Build minimal linux kernel." + @echo " ext2 - Build minimal ext2 fs as virtio blkdev backend (uses sudo)." @echo " clean - Cleanup downloads & builds." @echo "" @echo "Run targets:" @@ -27,6 +28,9 @@ kernel: init: ./build_initramfs.sh +ext2: + ./build_ext2.sh + run: qemu-system-x86_64 \ -nographic \ @@ -38,7 +42,7 @@ run: -device virtio-serial-pci \ -device virtconsole,chardev=vcon,name=console.0 \ -chardev socket,id=vcon,ipv4=on,host=localhost,port=2222,server,telnet=on,wait=off \ - -drive format=raw,if=virtio,file=rootfs.ext2 \ + -drive format=raw,if=virtio,file=blk.ext2 \ -nic user,model=virtio-net-pci vcon: @@ -48,6 +52,7 @@ clean: $(RM) initramfs.cpio.gz $(RM) -r busybox-* $(RM) -r linux-$(VER)* + $(RM) blk.ext2 docker: DOCKER_BUILDKIT=1 docker build --build-arg UID=$(shell id -u) -t virtio-dev . diff --git a/content/2021-12-02-toying-with-virtio/build_ext2.sh b/content/2021-12-02-toying-with-virtio/build_ext2.sh new file mode 100755 index 0000000..6e6bff8 --- /dev/null +++ b/content/2021-12-02-toying-with-virtio/build_ext2.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +dd if=/dev/zero of=blk.ext2 bs=1M count=128 +mkfs.ext2 blk.ext2 +sudo mount -t ext2 -o loop blk.ext2 /mnt +echo world | sudo tee /mnt/hello +sudo umount /mnt -- cgit v1.2.3