Last active
November 1, 2022 12:49
-
-
Save andresbott/b09b4fb16113f02e20fa0ef39025064c to your computer and use it in GitHub Desktop.
Vagrant debian vbguest workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a quick workaround for https://github.com/dotless-de/vagrant-vbguest/issues/399 | |
instead of relying on the vagrant plugin, this solution bakes a new vagrant image with the guest additions installed, | |
this new image can then be used as base in your vagrant. | |
the main drawback is that you need to bake the image separetely every time you setup the project or make a change to the base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# clean before starting | |
vagrant box remove --force debian-11-guest | |
vagrant destroy -f | |
# start the vagrant machine and install guest additions | |
vagrant up | |
# package a box and install it locally | |
vagrant package | |
vagrant box add debian-11-guest ./package.box | |
# clean after done | |
rm package.box | |
vagrant destroy -f | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "install Virtualbox Guest Additions" | |
sudo apt-get update && sudo apt-get -y install dkms build-essential wget | |
echo "downloading linux headers from debian snapshot server" | |
# this is only valid for kernel 5.10.0-3-amd64 | |
LINUX_COMMONS="https://snapshot.debian.org/archive/debian/20211001T101807Z/pool/main/l/linux/linux-headers-5.10.0-9-common_5.10.70-1_all.deb" | |
wget -q "${LINUX_COMMONS}" | |
sudo dpkg -i linux-headers-5.10.0-9-common_5.10.70-1_all.deb | |
LINUX_HEADERS="https://snapshot.debian.org/archive/debian/20211001T101807Z/pool/main/l/linux/linux-headers-5.10.0-9-amd64_5.10.70-1_amd64.deb" | |
wget -q "${LINUX_HEADERS}" | |
sudo dpkg -i linux-headers-5.10.0-9-amd64_5.10.70-1_amd64.deb | |
echo "download and install guest additions" | |
# https://download.virtualbox.org/virtualbox | |
wget -q https://download.virtualbox.org/virtualbox/6.1.34/VBoxGuestAdditions_6.1.34.iso | |
sudo mkdir /mnt/cdrom | |
sudo mount -o loop /home/vagrant/VBoxGuestAdditions_6.1.34.iso /mnt/cdrom | |
cd /mnt/cdrom || exit 1 | |
sudo sh ./VBoxLinuxAdditions.run --nox11 || true | |
echo "clean" | |
apt-get autoremove | |
apt-get autoclean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# boxes at https://vagrantcloud.com/search. | |
# https://app.vagrantup.com/debian/boxes/bullseye64 | |
VAGRANT_VM_BASE = "debian/bullseye64" | |
# when updating the version, the header files need to be updates in install-guest.sh as well | |
VAGRANT_VM_VERSION = "11.20211018.1" | |
Vagrant.configure("2") do |config| | |
config.vm.box = "#{VAGRANT_VM_BASE}" | |
config.vm.box_version = "#{VAGRANT_VM_VERSION}" | |
#item.vm.hostname = "#{VAGRANT_VM_NAME}" | |
config.vm.provider "virtualbox" do |v| | |
# set the name of the VM | |
v.name = "debian-11-guest" | |
# use a linked clone of the imported machine | |
v.linked_clone = true | |
end | |
config.vm.provision "shell", inline: "echo 'vagrant:vagrant' | sudo chpasswd" | |
config.vm.provision "shell", path: "install-guest.sh" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment