sudo apt install qemu-utils
sudo apt install qemu-system-x86
qemu-img create -f qcow2 myVirtualDisk.qcow2 20G
qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -hda myVirtualDisk.qcow2 -boot d -cdrom linuxmint-21.2-mate-64bit.iso -netdev user,id=net0,net=192.168.0.0/24,dhcpstart=192.168.0.9 -device virtio-net-pci,netdev=net0 -vga cirrus -device AC97 -cpu host
Note: petite différence par rapport à l'article:
-vga cirrus
pour avoir le GPU le plus basique-cpu host
pour avoir le même CPU dans la VM que sur la machine hôteOnce the VM is installed, drop the -boot d -cdrom linuxmint-21.2-mate-64bit.iso
parameter from the command.
Pour utiliser SPICE
sudo apt install virt-viewers
And we need to make sure that the ~/.config/mimeapps.list file (on the host machine) contains the following:
[Added Associations]
[...]
x-scheme-handler/spice+unix=remote-viewer.desktop
And then run the VM with:
qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -hda myVirtualDisk.qcow2 -netdev user,id=net0,net=192.168.0.0/24,dhcpstart=192.168.0.9 -device virtio-net-pci,netdev=net0 -vga cirrus -device AC97 -device virtio-serial-pci -spice port=5930,disable-ticketing=on -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent -display spice-app -cpu host
Pour partager un répertoire entre l'hôte et la VM
sur la machine hôte:
mkdir VM_share
qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -hda myVirtualDisk.qcow2 -netdev user,id=net0,net=192.168.0.0/24,dhcpstart=192.168.0.9 -device virtio-net-pci,netdev=net0 -vga cirrus -device AC97 -device virtio-serial-pci -spice port=5930,disable-ticketing=on -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent -display spice-app -cpu host -virtfs local,path=./VM_share,mount_tag=host0,security_model=mapped,id=host0
Sur la VM:
sudo mkdir /mnt/9p
sudo mount -t 9p -o trans=virtio,version=9p2000.L host0 /mnt/9p
Finally, to make the mounting automatic on every guest reboot, we need to add the 9p modules to initramfs
and a line to /etc/fstab
. So, let’s add the following three lines to /etc/initramfs-tools/modules
:
9p
9pnet
9pnet_virtio
Then, let’s add the following line in /etc/fstab
:
host0 /mnt/9p 9p trans=virtio,version=9p2000.L 0 0