Advertisement
efxtv

KVM Virtualization Setup on Fedora

May 18th, 2025 (edited)
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | Cybersecurity | 0 0
  1. # ===========================================
  2. # KVM Virtualization Setup on Fedora
  3. # ===========================================
  4.  
  5. ##################################################################
  6. Join our telegram channel for more : https://t.me/LinuxClassesEFXTv
  7. ##################################################################
  8.  
  9. # Step 1: Check if virtualization is supported and enabled on the system
  10. egrep '^flags.*(vmx|svm)' /proc/cpuinfo # Look for virtualization CPU flags (vmx for Intel, svm for AMD)
  11. lsmod | grep kvm # Check if KVM modules are loaded
  12. modinfo kvm | head # View KVM module information
  13. lscpu | grep -i virtualization # Confirm virtualization support via lscpu
  14.  
  15. # Step 2: Check if KVM is built into the kernel
  16. zgrep CONFIG_KVM /boot/config-$(uname -r)
  17.  
  18. # Step 3: Install the virtualization group and core packages
  19. sudo dnf install -y @virtualization
  20.  
  21. # Step 4: Enable and start necessary services
  22. sudo systemctl enable --now libvirtd
  23.  
  24. # Step 5: Install additional virtualization tools and dependencies
  25. sudo dnf install -y qemu-kvm libvirt virt-install virt-manager virt-viewer edk2-ovmf swtpm qemu-img guestfs-tools libosinfo tuned
  26.  
  27. # Step 6: Add VirtIO driver repository for Windows VMs
  28. sudo wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo
  29.  
  30. # Step 7: Enable the repository (edit line 14 and set enabled=1)
  31. sudo sed -i 's/enabled=0/enabled=1/' /etc/yum.repos.d/virtio-win.repo
  32.  
  33. # Step 8: Install the VirtIO ISO package
  34. sudo dnf install -y virtio-win
  35.  
  36. # Optional: Download latest VirtIO ISO manually from:
  37. # https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/
  38.  
  39. # Step 9: Check the service file for virtqemud
  40. sudo dnf provides */virtqemud.service
  41.  
  42. # Step 10: Enable Modular libvirt daemons
  43. for drv in qemu interface network nodedev nwfilter secret storage; do
  44. sudo systemctl enable virt${drv}d.service
  45. sudo systemctl enable virt${drv}d{,-ro,-admin}.socket
  46. done
  47.  
  48. # Step 11: Validate your host’s virtualization setup
  49. sudo virt-host-validate qemu
  50.  
  51. # Step 12: Enable VT-d (for Intel IOMMU support)
  52. # Edit GRUB config
  53. sudo vim /etc/default/grub
  54.  
  55. # Add to GRUB_CMDLINE_LINUX:
  56. # GRUB_CMDLINE_LINUX="rhgb quiet intel_iommu=on iommu=pt"
  57.  
  58. # Update GRUB configuration
  59. sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  60.  
  61. # Reboot system to apply changes
  62. sudo reboot
  63.  
  64. # Step 13: Re-validate the virtualization setup after reboot
  65. sudo virt-host-validate qemu
  66.  
  67. # Step 14: Optimize the host system using TuneD
  68. sudo systemctl enable --now tuned
  69.  
  70. # Check current profile
  71. tuned-adm active
  72.  
  73. # List available tuned profiles
  74. tuned-adm list
  75.  
  76. # Set the profile optimized for virtualization
  77. sudo tuned-adm profile virtual-host
  78.  
  79. # Confirm the profile change
  80. tuned-adm active
  81.  
  82. # Step 15: Configure a network bridge (optional, for bridging VM network interfaces)
  83.  
  84. # List existing networks
  85. sudo virsh net-list --all
  86.  
  87. # Create a bridge interface (name it as needed, e.g., bridge0)
  88. sudo nmcli connection add type bridge con-name bridge0 ifname bridge0
  89.  
  90. # (Continue bridge setup as needed based on your specific networking requirements)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement