Blog: 2023-09-15
Jump to navigation
Jump to search
Setting up debian with qemu
First I made a larger qcow disk than the default cloud image:
qemu-img resize debian-12-larger-disk-amd64.qcow2 10G
Then I ran the installer
virt-install --memory 2048 --vcpus 2 --name qemu-debian-12 --disk debian-12-larger-disk-amd64.qcow2,device=disk,bus=virtio --graphics none --import --os-variant=debian12
When I was all done, I exited with CTRL-] - https://www.reddit.com/r/linuxadmin/comments/5gzdtk/properly_exiting_virtinstall/
Then I can boot the system with:
qemu-system-x86_64 -hda debian-12-larger-disk-amd64.qcow2 -nographic -m 2048
Finally...
Even got port forwarding working:
qemu-system-x86_64 -hda debian-12-larger-disk-amd64.qcow2 -nographic -m 2048 -nic user,model=virtio,hostfwd=tcp::8080-:80
Then from the host:
curl localhost:8080
Networking from guest to host appears to be working by default:
root@localhost:~# ip route default via 10.0.2.2 dev ens3 proto dhcp src 10.0.2.15 metric 100 10.0.2.0/24 dev ens3 proto kernel scope link src 10.0.2.15 metric 100 10.0.2.2 dev ens3 proto dhcp scope link src 10.0.2.15 metric 100 10.0.2.3 dev ens3 proto dhcp scope link src 10.0.2.15 metric 100 root@localhost:~# curl -I 10.0.2.2:8000 HTTP/1.0 200 OK Server: SimpleHTTP/0.6 Python/3.11.4 Date: Fri, 15 Sep 2023 07:53:21 GMT Content-type: text/html; charset=utf-8 Content-Length: 4348 root@localhost:~#
References
https://wiki.debian.org/QEMU#Usage
https://techviewleo.com/run-debian-11-bullseye-on-kvm-using-qcow2-cloud-image/