Blog: 2023-09-15

From razwiki
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-] -

Then I can boot the system with:

qemu-system-x86_64 -hda debian-12-larger-disk-amd64.qcow2 -nographic -m 2048


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 dev ens3 proto dhcp src metric 100 dev ens3 proto kernel scope link src metric 100 dev ens3 proto dhcp scope link src metric 100 dev ens3 proto dhcp scope link src metric 100
root@localhost:~# curl -I
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