qemu-img create -f qcow2 Image.img 10G
Note: cow stands for copy-on-write
For adding space to the image
qemu-img resize disk_image +10G
For removing space
qemu-img resize --shrink disk_image -10G
qemu-system-x86_64 -enable-kvm -cdrom OS_ISO.iso -boot menu=on -drive file=Image.img -m 4G
Note:
- change
4Gto appropriate RAM allocation for the system - remove the
cdromflag after installing the OS - use
-smp <CORE_NUM>to specified CPU cores - add
-vga virtio -display sdl,gl=onfor performance - add
-device ich9-intel-hda -device hda-outputfor audio support (intel audio specific)
qemu-img infofor information on the image-boot dflag to force boot the cdrom/iso-cpu host,+popcntis needed on RHEL and SUSE, see: https://forums.virtualbox.org/viewtopic.php?f=3&t=106666
for UEFI copy over /usr/share/edk2/x64/OVMF_VARS.4m.fd to be readable and then do the follow (source: archwiki in ref):
-drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/x64/OVMF_CODE.4m.fd \
-drive if=pflash,format=raw,file=/copy/of/OVMF_VARS.4m.fd
CTRL+ALT+F fullscreen
CTRL+ALT+Q quit
CTRL+ALT+G to unfocus from the VM
After resizing (growing) an image, you can do the following to grow the partition:
cfdisk /dev/<drive>and then resize the partition theree2fsck -f /dev/<partition>to check the partitionresize2fs /dev/<partition>to then grow the filesystem to the partition
#/usr/bin/sh qemu-system-x86_64 -enable-kvm -boot menu=on -drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/x64/OVMF_CODE.4m.fd -drive if=pflash,format=raw,file=OVMF_VARS.4m.4d -drive file=PopOS.img -m 4G -smp 3 -vga virtio -device ich9-intel-hda -device hda-outputExample script for running PopOS (after it has been installed into the img) in QEMU with UEFI.