110 lines
3.3 KiB
Bash
110 lines
3.3 KiB
Bash
#!/bin/sh
|
|
#
|
|
if [ ! -f /etc/debian_version ]; then
|
|
echo "Unsupported Linux Distribution. Prepared for Debian"
|
|
exit 1
|
|
fi
|
|
################################################################################
|
|
#
|
|
#
|
|
# Install KVM @Linux Mint 22
|
|
#
|
|
#
|
|
################################################################################
|
|
#
|
|
# Preperations:
|
|
# - Warning your GPU has to support UEFI.
|
|
# - Check if your motherboard BIOS version is recent. (this can help you with having better IOMMU groups)
|
|
# - Check if your system is installed in UEFI mode. (CSM disabled in bios for AMD)
|
|
#
|
|
# AMD:
|
|
# - IOMMU = enabled
|
|
# - NX mode = enabled
|
|
# - SVM mode = enabled
|
|
#
|
|
################################################################################
|
|
#
|
|
# wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
|
|
#
|
|
# https://www.youtube.com/watch?v=_JTEsQufSx4
|
|
#
|
|
################################################################################
|
|
#
|
|
# journalctl -xeu libvirtd.service
|
|
#
|
|
################################################################################
|
|
sudo apt install -y \
|
|
qemu-kvm \
|
|
qemu-system \
|
|
libvirt-clients \
|
|
libvirt-daemon-system \
|
|
bridge-utils \
|
|
virt-manager \
|
|
ovmf \
|
|
swtpm \
|
|
virgl-server \
|
|
libvirglrenderer1 \
|
|
libguestfs-tools \
|
|
libosinfo-bin
|
|
|
|
|
|
echo -e '\033[33m------Enable IOMMU------\033[33m'
|
|
echo -e "\033[0m"
|
|
sleep 2
|
|
sudo cp /etc/default/grub /etc/default/grub_kvm
|
|
sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/GRUB_CMDLINE_LINUX_DEFAULT="amd_iommu=on iommu=pt video=efifb:off quiet splash"/g' /etc/default/grub
|
|
sudo update-grub
|
|
|
|
|
|
echo -e '\033[33m------Configuring of Libvirt------\033[33m'
|
|
echo -e "\033[0m"
|
|
sleep 2
|
|
sudo sed -i 's/#unix_sock_group = "libvirt"/unix_sock_group = "libvirt"/g' /etc/libvirt/libvirtd.conf
|
|
sudo sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf
|
|
|
|
# IMPORTANT: You need this for detailed logs:
|
|
echo -e 'log_filters="1:qemu"' | sudo tee -a /etc/libvirt/libvirtd.conf
|
|
echo -e 'log_outputs="1:file:/var/log/libvirt/libvirtd.log"' | sudo tee -a /etc/libvirt/libvirtd.conf
|
|
|
|
sudo usermod -a -G libvirt $(whoami)
|
|
|
|
sudo sed -i 's/#user = "root"/user = "$USER"/g' /etc/libvirt/qemu.conf
|
|
|
|
sudo systemctl enable --now libvirtd
|
|
|
|
# Verify libvirt has been added to your users:
|
|
# sudo groups $(whoami)
|
|
|
|
|
|
echo -e '\033[33m------Configuring QEMU------\033[33m'
|
|
echo -e "\033[0m"
|
|
sleep 2
|
|
sudo cp /etc/libvirt/qemu.conf /etc/libvirt/qemu.conf.default
|
|
sudo sed -i 's/#user = "libvirt-qemu"/user = "zulumann"/g' /etc/libvirt/qemu.conf
|
|
sudo sed -i 's/#group = "kvm"/group = "zulumann"/g' /etc/libvirt/qemu.conf
|
|
|
|
sudo usermod -a -G kvm,libvirt $(whoami)
|
|
|
|
# Verify libvirt and kvm has been added to your users groups:
|
|
# sudo groups $(whoami)
|
|
|
|
|
|
echo -e '\033[33m------Enabling the virtual machine default network------\033[33m'
|
|
echo -e "\033[0m"
|
|
sleep 2
|
|
sudo virsh net-autostart default && sudo virsh net-start default
|
|
|
|
|
|
echo -e '\033[33m------Enabling copy-and-paste between the guest and the host------\033[33m'
|
|
echo -e "\033[0m"
|
|
sleep 2
|
|
sudo apt install spice-vdagent
|
|
sudo systemctl enable --now spice-vdagentd.service
|
|
|
|
|
|
echo -e '\033[33m------Setup Directorys------\033[33m'
|
|
echo -e "\033[0m"
|
|
sleep 2
|
|
#mkdir -p /home/$USER/VM-Images && sudo chown :kvm ~/VM-Images
|
|
#mkdir -p /home/$USER/ISOs && sudo chown :kvm ~/ISOs
|