From 544fd379ff8537ee2d48a4322aec854f2574fb46 Mon Sep 17 00:00:00 2001 From: Somesh Bhalsing Date: Tue, 8 Nov 2022 19:49:54 +0530 Subject: [PATCH] feat: qemu exploration --- .gitignore | 2 ++ qemu/commands.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ qemu/solution.md | 22 ++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 .gitignore create mode 100644 qemu/commands.md create mode 100644 qemu/solution.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..137617d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +qemu/alpine* diff --git a/qemu/commands.md b/qemu/commands.md new file mode 100644 index 0000000..27380cd --- /dev/null +++ b/qemu/commands.md @@ -0,0 +1,67 @@ +someshbhalsing@Velotios-MacBook-Air k8s-dev-training % mkdir qemu + +someshbhalsing@Velotios-MacBook-Air k8s-dev-training % cd qemu + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-img create -f qcow2 alpine.qcow2 8G +Formatting 'alpine.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=8589934592 lazy_refcounts=off refcount_bits=16 + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-system-x86_64 -m 512 -boot d -cdrom alpine-standard-3.16.2-x86_64.iso -hda alpine.qcow2 -display default -vga virtio -machine type=q35 + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-system-x86_64 -m 512 -hda alpine.qcow2 + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-img info alpine.qcow2 +image: alpine.qcow2 +file format: qcow2 +virtual size: 8 GiB (8589934592 bytes) +disk size: 352 MiB +cluster_size: 65536 +Format specific information: + compat: 1.1 + compression type: zlib + lazy refcounts: false + refcount bits: 16 + corrupt: false + extended l2: false + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-img snapshot -c snapshot-1 alpine.qcow2 + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-img snapshot -l alpine.qcow2 +Snapshot list: +ID TAG VM SIZE DATE VM CLOCK ICOUNT +1 snapshot-1 0 B 2022-11-08 19:23:00 00:00:00.000 0 + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-img create -f qcow2 -b alpine.qcow2 -F qcow2 alpine-copy.qcow2 +Formatting 'alpine-copy.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=8589934592 backing_file=alpine.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16 + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-img info alpine-copy.qcow2 +image: alpine-copy.qcow2 +file format: qcow2 +virtual size: 8 GiB (8589934592 bytes) +disk size: 196 KiB +cluster_size: 65536 +backing file: alpine.qcow2 +backing file format: qcow2 +Format specific information: + compat: 1.1 + compression type: zlib + lazy refcounts: false + refcount bits: 16 + corrupt: false + extended l2: false + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-img commit alpine-copy.qcow2 +Image committed. + + +someshbhalsing@Velotios-MacBook-Air qemu % qemu-img compare alpine.qcow2 alpine.qcow2 +Images are identical. + diff --git a/qemu/solution.md b/qemu/solution.md new file mode 100644 index 0000000..f6b88e5 --- /dev/null +++ b/qemu/solution.md @@ -0,0 +1,22 @@ +#### QEMU + +- free and open-source emulator +- emulates the machine's processor through dynamic binary translation +- provides a set of different hardware and device models for the machine +- enables machine run a variety of guest operating systems. +- better performance as compared to virtualbox + +#### QCOW2 + +- file format used by the qemu images +- delays allocation of storage until it is actually needed + +#### Virtual size vs Disk size + +- virtual size is the size chosen while creating the drive. +- disk size is the size that is actully allocated + +#### Backing chain + +- chains and overlays are created for snapshotting the image. +- make it possible to apply any particular snapshot OR merge multiple images with same backing chain. \ No newline at end of file