Host Linux / QEMU KVM Virtualisation

Programming, Wireless, Physical Security, OS, Courses and More
User avatar
ethical hacker
Posts: 62
Joined: Thu Feb 29, 2024 10:48 pm

Host Linux / QEMU KVM Virtualisation

Postby ethical hacker » Fri Mar 15, 2024 6:38 am

We abstain from virtualising through proprietary software such as VMWare Workstation or similar. Our approach entails the utilisation of QEMU/KVM in conjunction with virt-manager, an open-source hypervisor:

Code: Select all

nsa@debian:~# sudo apt install libvirt0 virt-manager dnsmasq bridge-utils
sudo systemctl enable --now libvirtd
nsa@debian:~# sudo usermod -a -G libvirt nsa
nsa@debian:~# sudo usermod -a -G kvm nsa
nsa@debian:~# sudo vim /etc/libvirt/libvirtd.conf
nsa@debian:~# cat /etc/libvirt/libvirtd.conf  | grep sock_group
unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"
nsa@debian:~# sudo chmod 770 -R VMs
nsa@debian:~# sudo chown nsa:libvirt -R VMs
nsa@debian:~# cat /etc/libvirt/qemu.conf
group = "libvirt"
user = "nsa"
nsa@debian:~# systemctl restart libvirtd.service
virt-manager


To ensure the establishment of the NAT network and the appropriate permissions for the ISOs and VMs directories, it is imperative to navigate to QEMU/KVM and select "Details". Subsequently, activate the "Autostart: On Boot" option and confirm the changes. This meticulous process guarantees the seamless operation of the network and the correct configuration of essential folders within the virtual environment.
In terminal:

Code: Select all

mkdir ISOs
mkdir VMs
sudo chmod 770 -R VMs 
sudo chmod 770 -R ISOs
sudo chown nsa:libvirt -R VMs
sudo chown nsa:libvirt -R ISOs


Subsequently, within virt-manager, the inclusion of file directories can be accomplished with precision: Commence by selecting QEMU/KVM, proceed to "Storage", and initiate the addition of a new storage pool by clicking on the "+" symbol. Specify "ISOs" under Name and "/home/user/ISOs" as the Target Path, then complete the process by clicking 'finish'. To finalise, navigate to the Storage section, consecutively choose ISOs and VMs, and activate the "On Boot" option under Autostart for both directories. This methodical approach ensures the seamless integration of file directories within the virtual environment, enhancing operational efficiency and organisation.

With the necessary configurations in place, you are now prepared to create virtual machines while adhering to the open-source mandate. Should there be a preference for utilising a closed-source operating system, it can be accommodated within a QEMU virtual machine through virt-manager. It is essential to bear in mind that closed-source operating systems such as Windows are best contained within a virtual machine environment and should not be operated outside of it.

Return to “Others”