Simple guide for installing debian12 on qemu.
Requirements:
-
Your machine should have atleast 8gb of ram.
-
You should have an unix based operating system installed on your machines.
-
Stable internet connection.
-
qemu installed on your machine.
(assuming you have qemu installed on your system if not refer to qemu-wiki here https://www.qemu.org/download/ )
step1:
Download the iso image from the debians server.
ISO
Note: Don't go for the images where there is a gui as they tend be bloated and
are slow to run on vm. instead chose the standard debian img without any gui.
step2:
-
Create a folder with any name you want here we are creating one with name deb:
(this is done in order keep everything together in one folder)
$mkdir deb
$cd deb
-
Once you are in the folder make the virtual drive on which we will install debian.
$qemu-img create -f qcow2 disk.qcow 32g
-
here qemu-img is the utility provided by qemu to make virtual drives in qcow format which again is provided by qemu.
-
'create' tell the utility to create a new disk img,
-
'-f' flag specifies the format of the disk image
-
'qcow2' is the format name
-
'disk.qcow' is the name we are giving to the disk
-
'32G' will be the max size of the disk we are creating.
step3:
run the command:
$qemu-system-x86_64 -m 4096 -smp 2 -cdrom ../isos/debian-live-12.2.0-amd64-standard.iso -drive if=virtio,file=disk.qcow2,format=qcow2
-
'-m' flag tell the qemu to start with how much memory
-
'-smp' sets the number of cores to start with
-
'-cdrom' selects the booting media or installing media in our the case the iso we downloaded earlier
-
'-drive' selects the media or drive on where have to install the os.
-
(press enter assuming you know how to install debian (installing debian is not as easy as just clicking buttons(it might be but anyways)))
-
when you press return a new window will pop up with debians banner installation page.
-
after you have successfully gone through all the steps of installing,
step4:
To run your newly made vm run the command
$qemu-system-x86_64 -m 4096 -smp 2 -drive if=virtio,file=disk.qcow2,format=qcow2 -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 -device virtio-net,netdev=mynet0
this is the way you can run the newly created vm in gui format
To run vm in headless form just add the flag '-display none -daemonize' to the command and you can
acess the vm on port 7922 (assuming the guest os has a ssh server already running).