Skip to content

Instantly share code, notes, and snippets.

@changhoon-sung
Created February 24, 2024 17:43
Show Gist options
  • Save changhoon-sung/7a7b6a22354ab2b83d4810f927a343cf to your computer and use it in GitHub Desktop.
Save changhoon-sung/7a7b6a22354ab2b83d4810f927a343cf to your computer and use it in GitHub Desktop.
Run a QEMU VM with configuration
# Start a QEMU VM with configuration
# THIS IS A TEMPLATE FILE AND SHOULD BE MODIFIED TO SUIT YOUR NEEDS
# DO NOT RUN THIS FILE AS-IS
sudo qemu-system-x86_64 \
-enable-kvm \
-smp {number of cores} \
-m 4G \
# HDD block device
# -hda ./rootfs.qcow2 \
# NVMe block device
#-drive file=./rootfs.qcow2,if=none,id=disk0,format=qcow2 \
#-device nvme,drive=disk0,serial=deadbeef \
# -append "console=ttyS0 root=/dev/nvme0n1p2" \
# virtio block device
-drive file=./rootfs.qcow2,if=virtio \
# Kernel
# -kernel /path/to/linux-build/arch/x86/boot/bzImage \
# -append "console=ttyS0 root=/dev/sda2" \
# -initrd initramfs-5.18.0-rc6-readahead-split+ \
# Network
-net nic,model=virtio \
-net user,hostfwd=tcp:127.0.0.1:2222-:22 \
# Misc
-nographic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment