- Download Fedora DVD Image (Tested with 36 KDE)
- Create a QEMU/KVM libvirt VM (I use virt-manager) Attach this boot image as boot disk. I used 20GB as the disk size. Name this VM fedoraX
- Set installation destination to the local drive
- configure networking so that you have internet access (Should work out of the box with DHCP)
- Create a user "vagrant" with password "vagrant"
- Select minimal installation
- Proceed with installation
- After installation is complete, reboot
- Log in as vagrant user and elevate to root
sudo su
- Install necessary packages
yum install -y openssh wget gcc
- Enable SSH server
systemctl enable --now sshd
- Configure sudoers
visudo
Add a linevagrant ALL=(ALL) NOPASSWD: ALL
- Shut down the VM
- Create a directory for the box and navigate to it
mkdir fedoraX && cd fedoraX
- Compress the disk image to this directory
sudo qemu-img convert -c -O qcow2 /var/lib/libvirt/images/rhelX.Y.qcow2 box.img
- Make your user owner of this file
sudo chown USER:USER box.img
- Create a file
metadata.json
with the content
{
"provider" : "libvirt",
"format" : "qcow2",
"virtual_size" : 20
}
- Create a file Vagrantfile with the content
Vagrant.configure("2") do |config|
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.host = 'localhost'
libvirt.uri = 'qemu:///system'
end
config.vm.define "new" do |custombox|
custombox.vm.box = "fedoraX" # REPLACE THIS!!!
custombox.vm.provider :libvirt do |virt|
virt.memory = 2048
virt.cpus = 2
end
end
end
- Create Vagrant box file
tar cvzf fedoraX.box ./metadata.json ./Vagrantfile ./box.img
- Import box into Vagrant
vagrant box add --name fedoraX fedoraX.box
You can now use the box with
host.vm.box = "fedoraX"