Skip to main content

📦 Vagrant + VirtualBox + LFCS Lab (Fedora)

1. Objectif

Environnement LFCS avec 2 VM Ubuntu gérées par Vagrant + VirtualBox.


2. Installation

Vagrant

sudo dnf install -y vagrant

VirtualBox

sudo dnf install -y VirtualBox

3. Vagrantfile (2 VM)

config.vm.define "ubuntu1" do |vm|
  vm.vm.box = "ubuntu/focal64"
  vm.vm.network "private_network", ip: "192.168.56.101"
end

config.vm.define "ubuntu2" do |vm|
  vm.vm.box = "ubuntu/focal64"
  vm.vm.network "private_network", ip: "192.168.56.102"
end

4. Commandes Vagrant essentielles

vagrant up
vagrant halt
vagrant ssh ubuntu1
vagrant destroy -f
vagrant status

5. Commandes réseau / debug Vagrant

vagrant status
vagrant ssh ubuntu1
ip a

---

6. DEBUG — VirtualBox & Kernel (IMPORTANT)

6.1 Vérifier module kernel VirtualBox

lsmod | grep vbox

Si rien n’apparaît :

sudo modprobe vboxdrv

---

6.2 Vérifier VirtualBox

VBoxManage --version
which VBoxManage
rpm -qa | grep -i virtualbox

---

6.3 Problème kernel modules (akmods)

Sur Fedora, VirtualBox dépend des modules kernel :

sudo akmods --rebuild --force
sudo modprobe vboxdrv

Si problème persiste :

sudo reboot

---

7. DEBUG — Installation / réinstallation VirtualBox

Réinstallation complète

sudo dnf reinstall -y VirtualBox-server akmod-VirtualBox VirtualBox-kmodsrc

Ou nettoyage total :

sudo dnf remove -y VirtualBox-server akmod-VirtualBox VirtualBox-kmodsrc

Puis :

sudo dnf install -y VirtualBox

---

8. DEBUG — Vagrant + provider VirtualBox

Plugins Vagrant

vagrant plugin list
vagrant plugin install vagrant-virtualbox2

Réparation plugins

vagrant plugin repair
vagrant plugin expunge --reinstall
vagrant plugin update

---

9. DEBUG — libvirt (ancien essai Fedora)

Problèmes rencontrés

  • No URI provided (Vagrant libvirt)
  • virtqemud / virtstoraged sockets manquants
  • SELinux bloque ports VNC (5701)

Commandes de diagnostic utilisées

virsh net-list --all
virsh domifaddr all-courses_ubuntu1
virsh domiflist all-courses_ubuntu1
virsh dumpxml all-courses_ubuntu1
systemctl status libvirtd

Conclusion

Libvirt fonctionne mais est trop complexe sur Fedora 44 pour ce lab. VirtualBox est plus stable pour LFCS.

---

10. Secure Boot / MOK (Fedora)

Problème

Modules kernel VirtualBox bloqués par Secure Boot

Solution

  • EnrĂ´ler MOK key
  • RedĂ©marrer machine
  • Valider dans interface Secure Boot
sudo mokutil --list-enrolled

---

11. Cycle de travail recommandé

vagrant up
vagrant ssh ubuntu1
vagrant halt
vagrant up

---

12. Résumé troubleshooting

  • vboxdrv absent → modprobe ou akmods
  • VBoxManage cassĂ© → reinstall VirtualBox
  • Vagrant incompatible → update Vagrant
  • libvirt complexe → abandon dans ce lab
  • MOK obligatoire sur Fedora Secure Boot