Qemu Simple Boot: Quick Start Guide for Beginners

Step-by-step: Setting up QEMU Simple Boot on Linux

Overview

QEMU Simple Boot is a lightweight way to boot a firmware image (UEFI/SeaBIOS) or small kernel/initramfs without a full OS install. This guide assumes Ubuntu or similar Debian-based Linux and that you want a quick, minimal VM to test bootable images.

1) Install required packages

  • Command:

Code

sudo apt update sudo apt install qemu-system-x86 ovmf

2) Prepare a bootable image

  • If you have an ISO, use it directly (e.g., ubuntu.iso).
  • To test a tiny kernel+initramfs, build or download a bootable image (e.g., bzImage and initramfs.cpio.gz) and combine them as needed.

3) Choose firmware mode

  • For UEFI use OVMF files provided by the ovmf package (usually under /usr/share/OVMF).
  • For legacy BIOS use QEMU’s built-in SeaBIOS.

4) Basic QEMU command examples

  • Boot from an ISO (UEFI):

Code

qemu-system-x86_64 -m 1024 -bios /usr/share/OVMF/OVMFCODE.fd -cdrom ubuntu.iso -boot d
  • Boot from a disk image:

Code

qemu-img create -f qcow2 disk.qcow2 10G qemu-system-x8664 -m 2048 -drive file=disk.qcow2,format=qcow2 -boot c
  • Boot a kernel with initramfs (no disk):

Code

qemu-system-x86_64 -m 512 -kernel bzImage -initrd initramfs.cpio.gz -append “root=/dev/ram rdinit=/init console=ttyS0” -serial stdio -nographic

5) Networking and shared folders (optional)

  • User-mode networking (easy, no root):
    • Add -netdev user,id=net0 -device e1000,netdev=net0 to command.
  • Host folder via 9p (for quick file sharing):
    • Add -virtfs local,path=/host/path,mount_tag=hostshare,security_model=passthrough,id=hostshare
    • Mount inside guest (example for Linux guest):
      • mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt

6) Tips and troubleshooting

  • If UEFI firmware not found, locate OVMF files: dpkg -L ovmf | grep OVMF
  • For serial console output use -serial stdio and kernel console=ttyS0.
  • Use -display none -serial mon:stdio to avoid graphical VM window.
  • Increase verbosity: add -d guest_errors for debug logs.

7) Example minimal workflow (UEFI ISO)

  1. Install packages.
  2. Create disk: qemu-img create -f qcow2 vm.qcow2 8G
  3. Boot installer:

Code

qemu-system-x86_64 -m 2048 -bios /usr/share/OVMF/OVMF_CODE.fd -drive file=vm.qcow2,format=qcow2 -cdrom ubuntu.iso -boot d -enable-kvm
  1. After install, boot from disk: replace -cdrom with -boot c.

If you want, I can provide a ready-to-run command tailored to your Linux distribution, CPU (virtualization support), or the image you have.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *