diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-04-17 00:00:05 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-04-17 00:00:05 +0200 |
commit | 9bdc2b4fec2f5d11c9648916f362206d31ab6e0d (patch) | |
tree | fa06a961c280a0a40167efcf42f5c09ec4c59f45 /content/2021-12-02-toying-with-virtio.md | |
parent | 0730e22f17dbbdcc8559d743494b20d5ca782b35 (diff) | |
download | blog-9bdc2b4fec2f5d11c9648916f362206d31ab6e0d.tar.gz blog-9bdc2b4fec2f5d11c9648916f362206d31ab6e0d.zip |
virtio: add script and make target to build ext2 device
Diffstat (limited to 'content/2021-12-02-toying-with-virtio.md')
-rw-r--r-- | content/2021-12-02-toying-with-virtio.md | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/content/2021-12-02-toying-with-virtio.md b/content/2021-12-02-toying-with-virtio.md index a46fb2a..56c34de 100644 --- a/content/2021-12-02-toying-with-virtio.md +++ b/content/2021-12-02-toying-with-virtio.md @@ -132,11 +132,7 @@ Next we are creating the ext2 filesystem image. This we'll do by creating an `128M` blob and format it with ext2 afterwards. Then we can mount the image via a `loop` device and populate the filesystem. ```sh -dd if=/dev/zero of=rootfs.ext2 bs=1M count=128 -mkfs.ext2 rootfs.ext2 -mount -t ext2 -o loop rootfs.ext2 /mnt -echo world > /mnt/hello -umount /mnt +{{ include_range(path="content/2021-12-02-toying-with-virtio/build_ext2.sh", start=3, end=7) }} ``` Before booting the guest we will attach the virtio block device to the VM. @@ -145,7 +141,7 @@ Therefore we add the `-drive` configuration to our previous qemu invocation. ```sh qemu-system-x86_64 \ ... - -drive if=virtio,file=rootfs.ext2,format=raw + -drive if=virtio,file=fs.ext2,format=raw ``` The `-drive` option is a shortcut for a `-device (front-end) / -blockdev @@ -339,6 +335,7 @@ following files: - [Makefile][makefile] - [build_initramfs.sh][build-initramfs] - [build_kernel.sh][build-kernel] +- [build_ext2.sh][build-ext2] Then run the following steps to build everything. The prefix `[H]` and `[C]` indicate whether this command is run on the host or inside the container @@ -355,9 +352,8 @@ respectively. # Build kernel and initramfs. [C]: make -# Create the rootfs.ext2 disk image as described in the virtio blk -# section above, or remove the drive from the qemu command line -# in the make `run` target. +# Build ext2 fs as virtio blkdev backend. +[H]: make ext2 # Start qemu guest. [H]: make run @@ -365,6 +361,7 @@ respectively. [build-initramfs]: https://git.memzero.de/johannst/blog/src/branch/main/content/2021-12-02-toying-with-virtio/build_initramfs.sh [build-kernel]: https://git.memzero.de/johannst/blog/src/branch/main/content/2021-12-02-toying-with-virtio/build_kernel.sh +[build-ext2]: https://git.memzero.de/johannst/blog/src/branch/main/content/2021-12-02-toying-with-virtio/build_ext2.sh [makefile]: https://git.memzero.de/johannst/blog/src/branch/main/content/2021-12-02-toying-with-virtio/Makefile [dockerfile]: https://git.memzero.de/johannst/blog/src/branch/main/content/2021-12-02-toying-with-virtio/Dockerfile [initramfs]: https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt |