Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 1f

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox

Previously, for a TypeScript training, I needed an environment with Visual Studio Code and Node.js (a JavaScript runtime). In a previous article, I shared with you the steps I took, to get this working within an Oracle VirtualBox appliance, with the help of Vagrant.
[https://technology.amis.nl/recent/installing-ubuntu-desktop-22-04-lts-visual-studio-code-and-node-js-on-a-virtual-machine-using-vagrant-and-oracle-virtualbox/]

This time, I needed a similar environment (for a Terraform training) that also included Terraform and the Azure Command-Line Interface (CLI).

Since the last time however, I received a new laptop with Windows 11 and I installed software on it, including vagrant 2.3.6 (as opposed to version 2.3.4, I used so far) and VirtualBox Graphical User Interface, Version 7.0.8 r156879 (Qt5.15.2).

After starting the environment described in that previous article, I did run into some errors, with regard to VirtualBox Guest Additions.

In this article, I will share with you the steps I took, to get my demo environment working again.

In a next article, I will describe how I extended this environment with Terraform and Azure CLI.

Vagrantfile and shell script

Since my previous article I had the following Vagrantfile in place:

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"
  
  config.vm.define "ubuntu_vsc_nodejs" do |ubuntu_vsc_nodejs|
    
    config.vm.synced_folder "C:\\My\\AMIS\\MySharedFolder", "/mnt/mysharedfolder", automount: true
    
    config.vm.provider "virtualbox" do |vb|
        vb.name = "Ubuntu Desktop, Visual Studio Code and Node.js"
        vb.memory = "8192"
        vb.cpus = "2"
        vb.customize ['modifyvm', :id, '--graphicscontroller', 'vmsvga']
        vb.customize ['modifyvm', :id, '--vram', '16']
        vb.customize ["modifyvm", :id, "--clipboard-mode", "bidirectional"]
        vb.customize ["modifyvm", :id, "--draganddrop", "bidirectional"]
        vb.gui = true
        
    args = []
    config.vm.provision "ubuntu_etc shell script", type: "shell",
        path: "scripts/ubuntu_etc.sh",
        args: args    end
    
  end

end

In the scripts directory I had a file ubuntu_etc.sh with the following content:

#!/bin/bash
echo "**** Begin installing Ubuntu, etc"

sudo apt update
sudo apt upgrade -y

echo "**** Begin installing ubuntu-desktop"
sudo apt install ubuntu-desktop -y
sudo timedatectl set-timezone Europe/Amsterdam
echo "**** End installing ubuntu-desktop"

echo "**** Begin installing Visual Studio Code"
#Install the apt repository and signing key to enable auto-updating using the system's package manager
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg

#Update the package cache and install the package
sudo apt install apt-transport-https
sudo apt update
sudo apt install code
echo "**** End installing Visual Studio Code"

echo "**** Begin installing Node.js"
# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
echo "**** End installing Node.js"

echo "**** End installing Ubuntu, etc"

As I described before, on my new laptop with Windows 11, I installed software, including vagrant 2.3.6 (as opposed to version 2.3.4, I used so far) and VirtualBox Graphical User Interface, Version 7.0.8 r156879 (Qt5.15.2).

From a subdirectory named env on my Windows laptop, I opened a Windows Command Prompt (cmd). In order to see the currently installed version, I used the following:

vagrant --version

With the following output:

Vagrant 2.3.6

Error: ‘/var/lib/VBoxGuestAdditions/skip-5.15.0-69-generic’: No such file or directory

As before I wanted to install some vagrant plugins. I used the following commands on the Windows Command Prompt:

vagrant plugin install vagrant-disksize
vagrant plugin install vagrant-vbguest

This last command, gave an error:

Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
ERROR:  SSL verification error at depth 3: unable to get local issuer certificate (20)
ERROR:  You must add /C=US/O=Starfield Technologies, Inc./OU=Starfield Class 2 Certification Authority to your local trusted store
Vagrant failed to load a configured plugin source. This can be caused
by a variety of issues including: transient connectivity issues, proxy
filtering rejecting access to a configured plugin source, or a configured
plugin source not responding correctly. Please review the error message
below to help resolve the issue:

  SSL_connect SYSCALL returned=5 errno=0 peeraddr=18.239.94.37:443 state=error: certificate verify failed (https://gems.hashicorp.com/specs.4.8.gz)

Source: https://gems.hashicorp.com/

In order to fix it, I used:

set SSL_CERT_FILE=C:\My\App\Tools\HashiCorp\Vagrant\embedded\gems\gems\excon-0.99.0\data\cacert.pem
vagrant plugin install --plugin-clean-sources --plugin-source https://rubygems.org vagrant-vbguest

[https://discuss.hashicorp.com/t/vagrant-2-3-5-unable-to-install-plugins/53916]

With the following output:

Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.31.0)'!

In order to list all installed plugins and their respective installed versions, I used the following command on the Windows Command Prompt:

vagrant plugin list

With the following output:

vagrant-disksize (0.1.3, global)
vagrant-vbguest (0.31.0, global)

Then, I ran the following command:

vagrant up

With the following output (only showing the relevant parts):

Bringing machine 'ubuntu_vsc_nodejs' up with 'virtualbox' provider...
==> ubuntu_vsc_nodejs: Importing base box 'generic/ubuntu2204'...
==> ubuntu_vsc_nodejs: Matching MAC address for NAT networking...
==> ubuntu_vsc_nodejs: Checking if box 'generic/ubuntu2204' version '4.2.16' is up to date...
==> ubuntu_vsc_nodejs: Setting the name of the VM: Ubuntu Desktop, Visual Studio Code and Node.js
==> ubuntu_vsc_nodejs: Clearing any previously set network interfaces...
==> ubuntu_vsc_nodejs: Preparing network interfaces based on configuration...
    ubuntu_vsc_nodejs: Adapter 1: nat
==> ubuntu_vsc_nodejs: Forwarding ports...
    ubuntu_vsc_nodejs: 22 (guest) => 2222 (host) (adapter 1)
==> ubuntu_vsc_nodejs: Running 'pre-boot' VM customizations...
==> ubuntu_vsc_nodejs: Booting VM...
==> ubuntu_vsc_nodejs: Waiting for machine to boot. This may take a few minutes...
    ubuntu_vsc_nodejs: SSH address: 127.0.0.1:2222
    ubuntu_vsc_nodejs: SSH username: vagrant
    ubuntu_vsc_nodejs: SSH auth method: private key
    ubuntu_vsc_nodejs: Warning: Connection reset. Retrying...
    ubuntu_vsc_nodejs: Warning: Connection aborted. Retrying...
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Vagrant insecure key detected. Vagrant will automatically replace
    ubuntu_vsc_nodejs: this with a newly generated keypair for better security.
    ubuntu_vsc_nodejs:
    ubuntu_vsc_nodejs: Inserting generated public key within guest...
    ubuntu_vsc_nodejs: Removing insecure key from the guest if it's present...
    ubuntu_vsc_nodejs: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ubuntu_vsc_nodejs: Machine booted and ready!
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.0
VBoxService inside the vm claims: 6.1.38
Going on, assuming VBoxService is correct...
[ubuntu_vsc_nodejs] A Virtualbox Guest Additions installation was found but no tools to rebuild or start them.
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.0
VBoxService inside the vm claims: 6.1.38
Going on, assuming VBoxService is correct...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package virtualbox-guest-dkms
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-5.15.0-69-generic is already the newest version (5.15.0-69.76).
linux-headers-5.15.0-69-generic set to manually installed.
The following additional packages will be installed:
  bzip2 cpp cpp-11 cpp-12 dctrl-tools dpkg-dev fakeroot fontconfig-config
  fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base gcc-12
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libasan8 libatomic1 libc-dev-bin libc-devtools libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgcc-12-dev libgd3 libgomp1 libisl23 libitm1
  libjbig0 libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-dev libtsan0 libtsan2 libubsan1 libwebp7
  libxpm4 linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
Suggested packages:
  bzip2-doc cpp-doc gcc-11-locales gcc-12-locales debtags menu debian-keyring
  g++-multilib g++-11-multilib gcc-11-doc gcc-multilib autoconf automake
  libtool flex bison gdb gcc-doc gcc-11-multilib gcc-12-multilib gcc-12-doc
  glibc-doc bzr libgd-tools libstdc++-11-doc make-doc
The following NEW packages will be installed:
  build-essential bzip2 cpp cpp-11 cpp-12 dctrl-tools dkms dpkg-dev fakeroot
  fontconfig-config fonts-dejavu-core g++ g++-11 gcc gcc-11 gcc-11-base gcc-12
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libasan8 libatomic1 libc-dev-bin libc-devtools libc6-dev libcc1-0
  libcrypt-dev libdeflate0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libfontconfig1 libgcc-11-dev libgcc-12-dev libgd3 libgomp1 libisl23 libitm1
  libjbig0 libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0
  libstdc++-11-dev libtiff5 libtirpc-dev libtsan0 libtsan2 libubsan1 libwebp7
  libxpm4 linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
0 upgraded, 59 newly installed, 0 to remove and 3 not upgraded.
Need to get 208 MB of archives.
After this operation, 673 MB of additional disk space will be used.
Ign:1 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 gcc-11-base amd64 11.3.0-1ubuntu1~22.04
…
Copy iso file C:\My\App\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
Installing Virtualbox Guest Additions 7.0.8 - guest version is 6.1.38
Verifying archive integrity...  100%   MD5 checksums are OK. All good.
Uncompressing VirtualBox 7.0.8 Guest Additions for Linux  100%
VirtualBox Guest Additions installer
VBoxControl: error: Could not contact the host system.  Make sure that you are running this
VBoxControl: error: application inside a VirtualBox guest system, and that you have sufficient
VBoxControl: error: user permissions.
This system appears to have a version of the VirtualBox Guest Additions
already installed.  If it is part of the operating system and kept up-to-date,
there is most likely no need to replace it.  If it is not up-to-date, you
should get a notification when you start the system.  If you wish to replace
it with this version, please do not continue with this installation now, but
instead remove the current version first, following the instructions for the
operating system.

If your system simply has the remains of a version of the Additions you could
not remove you should probably continue now, and these will be removed during
installation.

Do you wish to continue? [yes or no]
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-5.15.0-69-generic': No such file or directory
Copying additional installer modules ...
Installing additional modules ...
/opt/VBoxGuestAdditions-7.0.8/bin/VBoxClient: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
/opt/VBoxGuestAdditions-7.0.8/bin/VBoxClient: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Setting up modules
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 5.15.0-69-generic.
update-initramfs: Generating /boot/initrd.img-5.15.0-69-generic
VirtualBox Guest Additions: reloading kernel modules and services
currently loaded module vboxguest version (7.0.8 r156879) does not match to VirtualBox Guest Additions installation version (unknown unknown)
The log file /var/log/vboxadd-setup.log may contain further information.

Because in the VagrantfiIe, I choose to display the VirtualBox GUI when booting the machine
(vb.gui = true), at the end this GUI was visible:

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 2

Next, I logged in as user vagrant.

As mentioned in the output, I looked at the log file /var/log/vboxadd-setup.log for further information:

cat /var/log/vboxadd-setup.log

With the following output:

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 3

I searched on the Internet and as it turned out, the solution for this, was to uninstall the plugin.
[https://bugs.launchpad.net/cloud-images/+bug/2023758]

So, in order to solve this problem I uninstalled the plugin:

vagrant plugin uninstall vagrant-vbguest

With the following output:

Uninstalling the 'vagrant-vbguest' plugin...
Successfully uninstalled micromachine-3.0.0
Successfully uninstalled vagrant-vbguest-0.31.0

In order to list all installed plugins and their respective installed versions, I used the following command on the Windows Command Prompt:

vagrant plugin list

With the following output:

vagrant-disksize (0.1.3, global)

Finally, I closed the system, via the VirtualBox menu File | Close | Power off the machine.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 4

In order to stop the running machine and destroy its resources, I used the following command on the Windows Command Prompt: vagrant destroy

With the following output:

    ubuntu_vsc_nodejs: Are you sure you want to destroy the 'ubuntu_vsc_nodejs' VM? [y/N] y
==> ubuntu_vsc_nodejs: Discarding saved state of VM...
==> ubuntu_vsc_nodejs: Destroying VM and associated drives...

This command stops the running machine Vagrant is managing and destroys all resources that were created during the machine creation process. After running this command, your computer should be left at a clean state, as if you never created the guest machine in the first place.
[https://www.vagrantup.com/docs/cli/destroy.html]

From here on in this blog, for simplicity, I will no longer mention the vagrant destroy command preceding the vagrant up command.

Before trying again, I changed the content of Vagrantfile (to represent the new environment I want to create) to:
[in bold, I highlighted the changes]

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"
  
  config.vm.define "ubuntu_vsc_terraform_azurecli" do |ubuntu_vsc_terraform_azurecli|
    
    config.vm.synced_folder "C:\\My\\AMIS\\MySharedFolder", "/mnt/mysharedfolder", automount: true
    
    config.vm.provider "virtualbox" do |vb|
        vb.name = "Ubuntu Desktop, Visual Studio Code, Terraform and Azure CLI"
        vb.memory = "8192"
        vb.cpus = "2"
        vb.customize ['modifyvm', :id, '--graphicscontroller', 'vmsvga']
        vb.customize ['modifyvm', :id, '--vram', '16']
        vb.customize ["modifyvm", :id, "--clipboard-mode", "bidirectional"]
        vb.customize ["modifyvm", :id, "--draganddrop", "bidirectional"]
        vb.gui = true
        
    args = []
    config.vm.provision "ubuntu_etc shell script", type: "shell",
        path: "scripts/ubuntu_etc.sh",
        args: args
    end
    
  end

end        

Then, again I ran the following command:

vagrant up

With the following output (only showing the relevant parts):

Bringing machine 'ubuntu_vsc_terraform_azurecli' up with 'virtualbox' provider...
==> ubuntu_vsc_terraform_azurecli: Importing base box 'generic/ubuntu2204'...
==> ubuntu_vsc_terraform_azurecli: Matching MAC address for NAT networking...
==> ubuntu_vsc_terraform_azurecli: Checking if box 'generic/ubuntu2204' version '4.2.16' is up to date...
==> ubuntu_vsc_terraform_azurecli: Setting the name of the VM: Ubuntu Desktop, Visual Studio Code, Terraform and Azure CLI
==> ubuntu_vsc_terraform_azurecli: Clearing any previously set network interfaces...
==> ubuntu_vsc_terraform_azurecli: Preparing network interfaces based on configuration...
    ubuntu_vsc_terraform_azurecli: Adapter 1: nat
==> ubuntu_vsc_terraform_azurecli: Forwarding ports...
    ubuntu_vsc_terraform_azurecli: 22 (guest) => 2222 (host) (adapter 1)
==> ubuntu_vsc_terraform_azurecli: Running 'pre-boot' VM customizations...
==> ubuntu_vsc_terraform_azurecli: Booting VM...
==> ubuntu_vsc_terraform_azurecli: Waiting for machine to boot. This may take a few minutes...
    ubuntu_vsc_terraform_azurecli: SSH address: 127.0.0.1:2222
    ubuntu_vsc_terraform_azurecli: SSH username: vagrant
    ubuntu_vsc_terraform_azurecli: SSH auth method: private key
    ubuntu_vsc_terraform_azurecli: Warning: Connection reset. Retrying...
    ubuntu_vsc_terraform_azurecli: Warning: Connection aborted. Retrying...
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Vagrant insecure key detected. Vagrant will automatically replace
    ubuntu_vsc_terraform_azurecli: this with a newly generated keypair for better security.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Inserting generated public key within guest...
    ubuntu_vsc_terraform_azurecli: Removing insecure key from the guest if it's present...
    ubuntu_vsc_terraform_azurecli: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ubuntu_vsc_terraform_azurecli: Machine booted and ready!
==> ubuntu_vsc_terraform_azurecli: Checking for guest additions in VM...
    ubuntu_vsc_terraform_azurecli: The guest additions on this VM do not match the installed version of
    ubuntu_vsc_terraform_azurecli: VirtualBox! In most cases this is fine, but in rare cases it can
    ubuntu_vsc_terraform_azurecli: prevent things such as shared folders from working properly. If you see
    ubuntu_vsc_terraform_azurecli: shared folder errors, please make sure the guest additions within the
    ubuntu_vsc_terraform_azurecli: virtual machine match the version of VirtualBox you have installed on
    ubuntu_vsc_terraform_azurecli: your host and reload your VM.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Guest Additions Version: 6.1.38
    ubuntu_vsc_terraform_azurecli: VirtualBox Version: 7.0
==> ubuntu_vsc_terraform_azurecli: Mounting shared folders...
    ubuntu_vsc_terraform_azurecli: /mnt/mysharedfolder => C:/My/AMIS/MySharedFolder
==> ubuntu_vsc_terraform_azurecli: Running provisioner: ubuntu_etc shell script (shell)...
    ubuntu_vsc_terraform_azurecli: Running: C:/Users/marc_l/AppData/Local/Temp/vagrant-shell20230702-17104-ltqo9e.sh
    ubuntu_vsc_terraform_azurecli: **** Begin installing Ubuntu, etc
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
    ubuntu_vsc_terraform_azurecli: Get:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease [119 kB]
 ...
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No containers need to be restarted.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No user sessions are running outdated binaries.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_terraform_azurecli: **** Begin installing ubuntu-desktop
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Reading package lists...
    ubuntu_vsc_terraform_azurecli: Building dependency tree...
    ubuntu_vsc_terraform_azurecli: Reading state information...
    ubuntu_vsc_terraform_azurecli: The following additional packages will be installed:
    ubuntu_vsc_terraform_azurecli:   accountsservice acl acpi-support acpid adwaita-icon-theme aisleriot
    ubuntu_vsc_terraform_azurecli:   alsa-base alsa-topology-conf alsa-ucm-conf alsa-utils anacron apg apport-gtk
 ...
    ubuntu_vsc_terraform_azurecli: Fetched 652 MB in 1min 3s (10.3 MB/s)
    ...
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No containers need to be restarted.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No user sessions are running outdated binaries.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_terraform_azurecli: **** End installing ubuntu-desktop
    ubuntu_vsc_terraform_azurecli: **** Begin installing Visual Studio Code
    ubuntu_vsc_terraform_azurecli: Reading package lists...
    ubuntu_vsc_terraform_azurecli: Building dependency tree...
    ubuntu_vsc_terraform_azurecli: Reading state information...
    ubuntu_vsc_terraform_azurecli: wget is already the newest version (1.21.2-2ubuntu1).
    ubuntu_vsc_terraform_azurecli: gpg is already the newest version (2.2.27-3ubuntu2.1).
    ubuntu_vsc_terraform_azurecli: gpg set to manually installed.
    ubuntu_vsc_terraform_azurecli: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Reading package lists...
    ubuntu_vsc_terraform_azurecli: Building dependency tree...
    ubuntu_vsc_terraform_azurecli: Reading state information...
    ubuntu_vsc_terraform_azurecli: The following NEW packages will be installed:
    ubuntu_vsc_terraform_azurecli:   apt-transport-https
    ubuntu_vsc_terraform_azurecli: 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    ubuntu_vsc_terraform_azurecli: Need to get 1,510 B of archives.
    ubuntu_vsc_terraform_azurecli: After this operation, 169 kB of additional disk space will be used.
    ubuntu_vsc_terraform_azurecli: Get:1 https://mirrors.edge.kernel.org/ubuntu jammy-updates/universe amd64 apt-transport-https all 2.4.9 [1,510 B]
    ubuntu_vsc_terraform_azurecli: dpkg-preconfigure: unable to re-open stdin: No such file or directory
    ubuntu_vsc_terraform_azurecli: Fetched 1,510 B in 1s (2,425 B/s)
    ubuntu_vsc_terraform_azurecli: Selecting previously unselected package apt-transport-https.
(Reading database ... 199753 files and directories currently installed.)
    ubuntu_vsc_terraform_azurecli: Preparing to unpack .../apt-transport-https_2.4.9_all.deb ...
    ubuntu_vsc_terraform_azurecli: Unpacking apt-transport-https (2.4.9) ...
    ubuntu_vsc_terraform_azurecli: Setting up apt-transport-https (2.4.9) ...
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Pending kernel upgrade!
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Running kernel version:
    ubuntu_vsc_terraform_azurecli:   5.15.0-69-generic
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Diagnostics:
    ubuntu_vsc_terraform_azurecli:   The currently running kernel version is not the expected kernel version 5.15.0-76-generic.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. [Return]
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Services to be restarted:
    ubuntu_vsc_terraform_azurecli:  systemctl restart irqbalance.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart multipathd.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart packagekit.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart polkit.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart rsyslog.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart ssh.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart udisks2.service
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Service restarts being deferred:
    ubuntu_vsc_terraform_azurecli:  /etc/needrestart/restart.d/dbus.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart networkd-dispatcher.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart systemd-logind.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart user@1000.service
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No containers need to be restarted.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No user sessions are running outdated binaries.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Get:1 https://packages.microsoft.com/repos/code stable InRelease [3,569 B]
...
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No containers need to be restarted.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No user sessions are running outdated binaries.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_terraform_azurecli: **** End installing Visual Studio Code
    ubuntu_vsc_terraform_azurecli: **** Begin installing Node.js
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: ## Installing the NodeSource Node.js 18.x repo...
    ubuntu_vsc_terraform_azurecli:
 ...
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Pending kernel upgrade!
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Running kernel version:
    ubuntu_vsc_terraform_azurecli:   5.15.0-69-generic
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Diagnostics:
    ubuntu_vsc_terraform_azurecli:   The currently running kernel version is not the expected kernel version 5.15.0-76-generic.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. [Return]
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: Services to be restarted:
...
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No containers need to be restarted.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No user sessions are running outdated binaries.
    ubuntu_vsc_terraform_azurecli:
    ubuntu_vsc_terraform_azurecli: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_terraform_azurecli: **** End installing Node.js
    ubuntu_vsc_terraform_azurecli: **** End installing Ubuntu, etc

By the way, importing this base box and creating the virtual machine takes quite some time!

In the VirtualBox GUI, I logged in as user: vagrant

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 5

I used the following command on the VirtualBox GUI shell: sudo reboot
After a while, the login screen appeared.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 6

After I logged in as user vagrant, I had to step through some welcome screens.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 7

Here, I chose to skip for now.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 8

Here, I chose not to send system info.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 9

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 10

Finally, I clicked on the ‘Done’ button.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 11

This showed the desktop, but I could not Auto-resize Guest Display. This was not working.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 12

This was to be expected because for this feature you need the VirtualBox Guest Additions to be installed.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 13

From the menu I clicked on Devices | Insert Guest Additions CD image…

With the following error message:

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 14

From the menu I clicked on Devices | Upgrade Guest Additions…

With the following error message:

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 15

For now, I closed the system, via the VirtualBox menu File | Close | Save the machine state.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 16

It was time to investigate and fix these problems.

VirtualBox Guest Additions

As mentioned in Section 1.2, “Some Terminology”, the Guest Additions are designed to be installed inside a virtual machine after the guest operating system has been installed. They consist of device drivers and system applications that optimize the guest operating system for better performance and usability. See Section 3.1, “Supported Guest Operating Systems” for details on what guest operating systems are fully supported with Guest Additions by Oracle VM VirtualBox.

The Oracle VM VirtualBox Guest Additions for all supported guest operating systems are provided as a single CD-ROM image file which is called VBoxGuestAdditions.iso. This image file is located in the installation directory of Oracle VM VirtualBox. To install the Guest Additions for a particular VM, you mount this ISO file in your VM as a virtual CD-ROM and install from there.

The Guest Additions offer the following features:

  • Mouse pointer integration. To overcome the limitations for mouse support described in Section 1.9.2, “Capturing and Releasing Keyboard and Mouse”, this feature provides you with seamless mouse support. You will only have one mouse pointer and pressing the Host key is no longer required to free the mouse from being captured by the guest OS. To make this work, a special mouse driver is installed in the guest that communicates with the physical mouse driver on your host and moves the guest mouse pointer accordingly.
  • Shared folders. These provide an easy way to exchange files between the host and the guest. Much like ordinary Windows network shares, you can tell Oracle VM VirtualBox to treat a certain host directory as a shared folder, and Oracle VM VirtualBox will make it available to the guest operating system as a network share, irrespective of whether the guest actually has a network. See Section 4.3, “Shared Folders”.
  • Better video support. While the virtual graphics card which Oracle VM VirtualBox emulates for any guest operating system provides all the basic features, the custom video drivers that are installed with the Guest Additions provide you with extra high and non-standard video modes, as well as accelerated video performance.
  • In addition, with Windows, Linux, and Oracle Solaris guests, you can resize the virtual machine’s window if the Guest Additions are installed. The video resolution in the guest will be automatically adjusted, as if you had manually entered an arbitrary resolution in the guest’s Display settings. See Section 1.9.5, “Resizing the Machine’s Window”.

    If the Guest Additions are installed, 3D graphics and 2D video for guest applications can be accelerated. See Section 4.5, “Hardware-Accelerated Graphics”.

  • Seamless windows. With this feature, the individual windows that are displayed on the desktop of the virtual machine can be mapped on the host’s desktop, as if the underlying application was actually running on the host. See Section 4.6, “Seamless Windows”.
  • Generic host/guest communication channels. The Guest Additions enable you to control and monitor guest execution. The guest properties provide a generic string-based mechanism to exchange data bits between a guest and a host, some of which have special meanings for controlling and monitoring the guest. See Section 4.7, “Guest Properties”.
  • Additionally, applications can be started in a guest from the host. See Section 4.9, “Guest Control of Applications”.

  • Time synchronization. With the Guest Additions installed, Oracle VM VirtualBox can ensure that the guest’s system time is better synchronized with that of the host.
  • For various reasons, the time in the guest might run at a slightly different rate than the time on the host. The host could be receiving updates through NTP and its own time might not run linearly. A VM could also be paused, which stops the flow of time in the guest for a shorter or longer period of time. When the wall clock time between the guest and host only differs slightly, the time synchronization service attempts to gradually and smoothly adjust the guest time in small increments to either catch up or lose time. When the difference is too great, for example if a VM paused for hours or restored from saved state, the guest time is changed immediately, without a gradual adjustment.

    The Guest Additions will resynchronize the time regularly. See Section 9.11.3, “Tuning the Guest Additions Time Synchronization Parameters” for how to configure the parameters of the time synchronization mechanism.

  • Shared clipboard. With the Guest Additions installed, the clipboard of the guest operating system can optionally be shared with your host operating system. See Section 3.4, “General Settings”.
  • Automated logins. Also called credentials passing. See Section 9.1, “Automated Guest Logins”.

Each version of Oracle VM VirtualBox, even minor releases, ship with their own version of the Guest Additions. While the interfaces through which the Oracle VM VirtualBox core communicates with the Guest Additions are kept stable so that Guest Additions already installed in a VM should continue to work when Oracle VM VirtualBox is upgraded on the host, for best results, it is recommended to keep the Guest Additions at the same version.

The Windows and Linux Guest Additions therefore check automatically whether they have to be updated. If the host is running a newer Oracle VM VirtualBox version than the Guest Additions, a notification with further instructions is displayed in the guest.

[https://www.virtualbox.org/manual/ch04.html]

Error: Could not insert the C:\My\App\Oracle\VirtualBox/VBoxGuestAdditions.iso disk image file into the virtual machine …

So, as I mentioned before, I got the following error message (after choosing Insert Guest Additions CD image…):

Can’t mount image…

Could not insert the C:\My\App\Oracle\VirtualBox/VBoxGuestAdditions.iso disk image file into the virtual machine Ubuntu Desktop, Visual Studio Code, Terraform and Azure CLI, as the machine has no optical drives. Please add a drive using the storage page of the virtual machine settings window.

So, I apparently there was no optical drive, that according to the error message, can be added by using the storage page of the virtual machine settings window.

I also had a look at:
https://forums.virtualbox.org/viewtopic.php?t=96382
https://www.virtualbox.org/manual/ch04.html#additions-windows

So, In the Oracle VM VirtualBox Manager for my appliance, I selected Settings | Storage:

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 17

Unfortunately the icons I needed were disabled. To fix this, I started the appliance and closed it again, this time with: Power off the machine. Then again, I selected Settings | Storage:

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 18

I clicked on the “Adds optical drive” icon.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 19

Next, I selected “VBoxGuestAdditions.iso” and clicked on button “Choose”.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 20

In the Settings window, I clicked on button “OK” .

In the Oracle VM VirtualBox Manager I selected Start | Normal start.
Next, I logged in as user vagrant

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 21

And now the CD “VBox_GAs_7.0.8” was visible on the left side.

Then again, from the menu I clicked on Devices | Upgrade Guest Additions…

But I still got the same error message as before. Before concentrating on that error, I first wanted to automate my environment some more, with the manual steps I just executed.

So, I closed the system, via the VirtualBox menu File | Close | Power off the machine.

Vagrantfile

In order to automate the manual changes I made for creating the optical drive, I changed the Vagrantfile:
[in bold, I highlighted the changes]

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"
  
  config.vm.define "ubuntu_vsc_terraform_azurecli" do |ubuntu_vsc_terraform_azurecli|
    
    config.vm.synced_folder "C:\\My\\AMIS\\MySharedFolder", "/mnt/mysharedfolder", automount: true
    
    config.vm.provider "virtualbox" do |vb|
        vb.name = "Ubuntu Desktop, Visual Studio Code, Terraform and Azure CLI"
        vb.memory = "8192"
        vb.cpus = "2"
        vb.customize ['modifyvm', :id, '--graphicscontroller', 'vmsvga']
        vb.customize ['modifyvm', :id, '--vram', '16']
        vb.customize ["modifyvm", :id, "--clipboard-mode", "bidirectional"]
        vb.customize ["modifyvm", :id, "--draganddrop", "bidirectional"]
        vb.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "0", "--device", "0", "--type", "dvddrive", "--medium", "C:\\My\\App\\Oracle\\VirtualBox\\VBoxGuestAdditions.iso"]
        vb.gui = true
        
    args = []
    config.vm.provision "ubuntu_etc shell script", type: "shell",
        path: "scripts/ubuntu_etc.sh",
        args: args
    end
    
  end

end

[ https://www.virtualbox.org/manual/ch08.html#vboxmanage-storageattach]

Then, I executed the vagrant up command and did the usual things to get the GUI started.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 22

And again the CD “VBox_GAs_7.0.8” was visible on the left side.

I closed the appliance, saving the state and started it again in the usual way.

Error: VBOX_E_IPRT_ERROR

So, as I mentioned before, I got the following error message (after choosing Upgrade Guest Additions…):

Name: C:\My\App\Oracle\VirtualBox/VBoxGuestAdditions.iso

Running update file "/bin/sh" on guest failed: VERR_INTERNAL_ERROR_5.
Result Code:
VBOX_E_IPRT_ERROR (0X80BB0005)
Component:
GuestSessionWrap
Interface:
IGuestSession {234f0627-866d-48c2-91a5-4c9d50f04928}

To solve this problem, I had a look at:

https://www.reddit.com/r/virtualbox/comments/yd3tfc/guest_additions_isnt_installing_or_working/
https://bjordanov.com/install-guest-additions-virtual-machine-vm-virtualbox/

Based on the provided solution I found, I used vagrant ssh to open a Linux Command Prompt where I used the following commands:

sudo apt-get update
sudo apt-get install -y build-essential module-assistant
sudo m-a prepare
cd /media/vagrant/VBox_GAs_7.0.8
sudo sh ./VBoxLinuxAdditions.run

With the following output:

vagrant@ubuntu2204:~$ sudo apt-get update
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
Hit:5 https://packages.microsoft.com/repos/code stable InRelease
Hit:6 https://deb.nodesource.com/node_18.x jammy InRelease
Reading package lists... Done
vagrant@ubuntu2204:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
vagrant@ubuntu2204:~$ sudo apt-get install -y build-essential module-assistant
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  dpkg-dev fakeroot g++ g++-11 gcc gcc-11 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev libdpkg-perl libfakeroot libfile-fcntllock-perl
  libgcc-11-dev libitm1 liblsan0 libnsl-dev libquadmath0 libstdc++-11-dev libtirpc-dev libtsan0 libubsan1
  linux-libc-dev lto-disabled-list make manpages-dev rpcsvc-proto
Suggested packages:
  debian-keyring g++-multilib g++-11-multilib gcc-11-doc gcc-multilib autoconf automake libtool flex bison gcc-doc
  gcc-11-multilib gcc-11-locales glibc-doc bzr libstdc++-11-doc make-doc
The following NEW packages will be installed:
  build-essential dpkg-dev fakeroot g++ g++-11 gcc gcc-11 libalgorithm-diff-perl libalgorithm-diff-xs-perl
  libalgorithm-merge-perl libasan6 libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev libdpkg-perl libfakeroot
  libfile-fcntllock-perl libgcc-11-dev libitm1 liblsan0 libnsl-dev libquadmath0 libstdc++-11-dev libtirpc-dev libtsan0
  libubsan1 linux-libc-dev lto-disabled-list make manpages-dev module-assistant rpcsvc-proto
0 upgraded, 34 newly installed, 0 to remove and 0 not upgraded.
Need to get 50.9 MB of archives.
After this operation, 172 MB of additional disk space will be used.
…
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.9ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
vagrant@ubuntu2204:~$ sudo m-a prepare
Getting source for kernel version: 5.15.0-78-generic
Kernel headers available in /usr/src/linux-headers-5.15.0-78-generic
Creating symlink...
apt-get install build-essential
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
build-essential is already the newest version (12.9ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Done!
vagrant@ubuntu2204:~$ cd /media/vagrant/VBox_GAs_7.0.8
vagrant@ubuntu2204:/media/vagrant/VBox_GAs_7.0.8$ sudo sh ./VBoxLinuxAdditions.run
Verifying archive integrity...  100%   MD5 checksums are OK. All good.
Uncompressing VirtualBox 7.0.8 Guest Additions for Linux  100%
VirtualBox Guest Additions installer
This system appears to have a version of the VirtualBox Guest Additions
already installed.  If it is part of the operating system and kept up-to-date,
there is most likely no need to replace it.  If it is not up-to-date, you
should get a notification when you start the system.  If you wish to replace
it with this version, please do not continue with this installation now, but
instead remove the current version first, following the instructions for the
operating system.

If your system simply has the remains of a version of the Additions you could
not remove you should probably continue now, and these will be removed during
installation.

Do you wish to continue? [yes or no]
yes
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-5.15.0-69-generic': No such file or directory
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-5.15.0-78-generic': No such file or directory
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Setting up modules
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 5.15.0-78-generic.
update-initramfs: Generating /boot/initrd.img-5.15.0-78-generic
VirtualBox Guest Additions: Running kernel modules will not be replaced until
the system is restarted or 'rcvboxadd reload' triggered
VirtualBox Guest Additions: reloading kernel modules and services
Cannot reload kernel modules: one or more module(s) is still in use
The log file /var/log/vboxadd-setup.log may contain further information.
vagrant@ubuntu2204:/media/vagrant/VBox_GAs_7.0.8$

As you can see in the output, with this last command I had to type yes when asked to continue.

The following error message was shown:

Cannot reload kernel modules: one or more module(s) is still in use

As mentioned in the output, I looked at the log file /var/log/vboxadd-setup.log for further information:

cat /var/log/vboxadd-setup.log

With the following output:

Cannot reload kernel modules: one or more module(s) is still in use

On my first try to solve this problem, I did a sudo reboot and then I repeated the following commands:

cd /media/vagrant/VBox_GAs_7.0.8
sudo sh ./VBoxLinuxAdditions.run

With the following output:

Connection to 127.0.0.1 closed by remote host.
Connection to 127.0.0.1 closed.

And:

Verifying archive integrity...  100%   MD5 checksums are OK. All good.
Uncompressing VirtualBox 7.0.8 Guest Additions for Linux  100%
VirtualBox Guest Additions installer
Removing installed version 7.0.8 of VirtualBox Guest Additions...
update-initramfs: Generating /boot/initrd.img-5.15.0-78-generic
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Setting up modules
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 5.15.0-78-generic.
update-initramfs: Generating /boot/initrd.img-5.15.0-78-generic

So, this looked like it worked.

Just to be sure, I did a sudo reboot and then did the usual things to get the GUI started.

I could now Auto-resize Guest Display and in order to try out the copy and paste from guest to host, I opened a Terminal, and typed some text, that I was able to copy to notepad on my Windows laptop.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 23

I wanted to automate my environment some more, with the manual steps I just executed.

So, I closed the system, via the VirtualBox menu File | Close | Power off the machine.

Vagrantfile and shell script

In order to automate the manual changes I made for adding the VirtualBox Guest Additions, I changed the Vagrantfile:
[in bold, I highlighted the changes]

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu2204"
  
  config.vm.define "ubuntu_vsc_terraform_azurecli" do |ubuntu_vsc_terraform_azurecli|
    
    config.vm.synced_folder "C:\\My\\AMIS\\MySharedFolder", "/mnt/mysharedfolder", automount: true
    
    config.vm.provider "virtualbox" do |vb|
        vb.name = "Ubuntu Desktop, Visual Studio Code, Terraform and Azure CLI"
        vb.memory = "8192"
        vb.cpus = "2"
        vb.customize ['modifyvm', :id, '--graphicscontroller', 'vmsvga']
        vb.customize ['modifyvm', :id, '--vram', '16']
        vb.customize ["modifyvm", :id, "--clipboard-mode", "bidirectional"]
        vb.customize ["modifyvm", :id, "--draganddrop", "bidirectional"]
        vb.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "0", "--device", "0", "--type", "dvddrive", "--medium", "C:\\My\\App\\Oracle\\VirtualBox\\VBoxGuestAdditions.iso"]
        vb.gui = true
    
    args = []
    config.vm.provision "ubuntu_etc shell script", type: "shell",
        path: "scripts/ubuntu_etc.sh",
        args: args
    
    args = []
    config.vm.provision "fix_vboxguestadditions shell script", type: "shell",
        path: "scripts/fix_vboxguestadditions.sh",
        args: args
    end
    
  end

end

In the scripts directory I created a file fix_vboxguestadditions.sh with the following content:

#!/bin/bash
echo "**** Begin preparations for installing VBoxGuestAdditions"

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y build-essential module-assistant
sudo m-a prepare
#cd /media/vagrant/VBox_GAs_7.0.8
#sudo sh ./VBoxLinuxAdditions.run

echo "**** End preparations for installing VBoxGuestAdditions"

Remark:
For the VBox_GAs_7.0.8 to be present you actually have to be in the GUI. So I commented out these lines, but left them for my own convenience (when I have to manually execute them later on).

Then, I executed the vagrant up command and did the usual things (including sudo reboot) to get the GUI started.

With the following output:

    ubuntu_vsc_terraform_azurecli: **** Begin preparations for installing VBoxGuestAdditions
    ubuntu_vsc_terraform_azurecli: Hit:1 https://deb.nodesource.com/node_18.x jammy InRelease
    ubuntu_vsc_terraform_azurecli: Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
    ubuntu_vsc_terraform_azurecli: Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
    ubuntu_vsc_terraform_azurecli: Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
    ubuntu_vsc_terraform_azurecli: Hit:5 https://packages.microsoft.com/repos/code stable InRelease
    ubuntu_vsc_terraform_azurecli: Hit:6 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
    ubuntu_vsc_terraform_azurecli: Reading package lists...
    ubuntu_vsc_terraform_azurecli: Reading package lists...
    ubuntu_vsc_terraform_azurecli: Building dependency tree...
    ubuntu_vsc_terraform_azurecli: Reading state information...
    ubuntu_vsc_terraform_azurecli: Calculating upgrade...
    ubuntu_vsc_terraform_azurecli: The following packages have been kept back:
    ubuntu_vsc_terraform_azurecli:   initramfs-tools initramfs-tools-bin initramfs-tools-core
    ubuntu_vsc_terraform_azurecli: 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
    ubuntu_vsc_terraform_azurecli: Reading package lists...
    ubuntu_vsc_terraform_azurecli: Building dependency tree...
    ubuntu_vsc_terraform_azurecli: Reading state information...
    ubuntu_vsc_terraform_azurecli: The following additional packages will be installed:
    ubuntu_vsc_terraform_azurecli:   dpkg-dev fakeroot g++ g++-11 gcc gcc-11 libalgorithm-diff-perl
    ubuntu_vsc_terraform_azurecli:   libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan6 libc-dev-bin
    ubuntu_vsc_terraform_azurecli:   libc-devtools libc6-dev libcc1-0 libcrypt-dev libdpkg-perl libfakeroot
    ubuntu_vsc_terraform_azurecli:   libfile-fcntllock-perl libgcc-11-dev libitm1 liblsan0 libnsl-dev
    ubuntu_vsc_terraform_azurecli:   libquadmath0 libstdc++-11-dev libtirpc-dev libtsan0 libubsan1 linux-libc-dev
    ubuntu_vsc_terraform_azurecli:   lto-disabled-list make manpages-dev rpcsvc-proto
    ubuntu_vsc_terraform_azurecli: Suggested packages:
    ubuntu_vsc_terraform_azurecli:   debian-keyring g++-multilib g++-11-multilib gcc-11-doc gcc-multilib autoconf
    ubuntu_vsc_terraform_azurecli:   automake libtool flex bison gcc-doc gcc-11-multilib gcc-11-locales glibc-doc
    ubuntu_vsc_terraform_azurecli:   bzr libstdc++-11-doc make-doc
    ubuntu_vsc_terraform_azurecli: The following NEW packages will be installed:
    ubuntu_vsc_terraform_azurecli:   build-essential dpkg-dev fakeroot g++ g++-11 gcc gcc-11
    ubuntu_vsc_terraform_azurecli:   libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
    ubuntu_vsc_terraform_azurecli:   libasan6 libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
    ubuntu_vsc_terraform_azurecli:   libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-11-dev libitm1
    ubuntu_vsc_terraform_azurecli:   liblsan0 libnsl-dev libquadmath0 libstdc++-11-dev libtirpc-dev libtsan0
    ubuntu_vsc_terraform_azurecli:   libubsan1 linux-libc-dev lto-disabled-list make manpages-dev
    ubuntu_vsc_terraform_azurecli:   module-assistant rpcsvc-proto
    ubuntu_vsc_terraform_azurecli: 0 upgraded, 34 newly installed, 0 to remove and 3 not upgraded.
    ubuntu_vsc_terraform_azurecli: Need to get 50.9 MB of archives.
    ubuntu_vsc_terraform_azurecli: After this operation, 172 MB of additional disk space will be used.
...
    ubuntu_vsc_terraform_azurecli: Setting up build-essential (12.9ubuntu3) ...
    ubuntu_vsc_terraform_azurecli: Processing triggers for man-db (2.10.2-1) ...
    ubuntu_vsc_terraform_azurecli: Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: Pending kernel upgrade!
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: Running kernel version:
    ubuntu_vsc_terraform_azurecli:   5.15.0-69-generic
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: Diagnostics:
    ubuntu_vsc_terraform_azurecli:   The currently running kernel version is not the expected kernel version 5.15.0-78-generic.
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting. [Return]
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: Services to be restarted:
    ubuntu_vsc_terraform_azurecli:  systemctl restart irqbalance.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart multipathd.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart packagekit.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart polkit.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart udisks2.service
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: Service restarts being deferred:
    ubuntu_vsc_terraform_azurecli:  /etc/needrestart/restart.d/dbus.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart networkd-dispatcher.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart systemd-logind.service
    ubuntu_vsc_terraform_azurecli:  systemctl restart user@1000.service
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: No containers need to be restarted.
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: No user sessions are running outdated binaries.
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: No VM guests are running outdated hypervisor (qemu) binaries on this host.
    ubuntu_vsc_terraform_azurecli: Getting source for kernel version: 5.15.0-69-generic
    ubuntu_vsc_terraform_azurecli: Kernel headers available in /usr/src/linux-headers-5.15.0-69-generic
    ubuntu_vsc_terraform_azurecli: Creating symlink...
    ubuntu_vsc_terraform_azurecli: apt-get install build-essential
    ubuntu_vsc_terraform_azurecli: Reading package lists...
    ubuntu_vsc_terraform_azurecli: Building dependency tree...
    ubuntu_vsc_terraform_azurecli: Reading state information...
    ubuntu_vsc_terraform_azurecli: build-essential is already the newest version (12.9ubuntu3).
    ubuntu_vsc_terraform_azurecli: 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
    ubuntu_vsc_terraform_azurecli: 
    ubuntu_vsc_terraform_azurecli: Done!
    ubuntu_vsc_terraform_azurecli: **** End preparations for installing VBoxGuestAdditions

I used vagrant ssh to open a Linux Command Prompt where I repeated the following commands:

cd /media/vagrant/VBox_GAs_7.0.8
sudo sh ./VBoxLinuxAdditions.run

With the following output:

Verifying archive integrity...  100%   MD5 checksums are OK. All good.
Uncompressing VirtualBox 7.0.8 Guest Additions for Linux  100%
VirtualBox Guest Additions installer
This system appears to have a version of the VirtualBox Guest Additions
already installed.  If it is part of the operating system and kept up-to-date,
there is most likely no need to replace it.  If it is not up-to-date, you
should get a notification when you start the system.  If you wish to replace
it with this version, please do not continue with this installation now, but
instead remove the current version first, following the instructions for the
operating system.

If your system simply has the remains of a version of the Additions you could
not remove you should probably continue now, and these will be removed during
installation.

Do you wish to continue? [yes or no]
yes
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-5.15.0-69-generic': No such file or directory
touch: cannot touch '/var/lib/VBoxGuestAdditions/skip-5.15.0-78-generic': No such file or directory
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Setting up modules
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 5.15.0-78-generic.
update-initramfs: Generating /boot/initrd.img-5.15.0-78-generic
VirtualBox Guest Additions: Running kernel modules will not be replaced until
the system is restarted or 'rcvboxadd reload' triggered
VirtualBox Guest Additions: reloading kernel modules and services
Cannot reload kernel modules: one or more module(s) is still in use
The log file /var/log/vboxadd-setup.log may contain further information.

As you can see in the output, with this last command I had to type yes when asked to continue.

The following error message was shown:

Cannot reload kernel modules: one or more module(s) is still in use

Of course, we have seen this error before.

This time, to solve it, I only did a sudo reboot and logged in.

Again, as I did before, I could Auto-resize Guest Display and also tried out the copy and paste from guest to host.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 24

This all worked ?.

I also wanted to check my shared folder. Via Files, I navigated to /mnt/mysharedfolder.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 25

I could see the dummy.txt file, so this worked also.

Thankfully, I now had an environment that I again can use as a base for further functional enhancements.

Trouble shooting Vagrant 2.3.6 and VirtualBox Guest Additions while upgrading a VM with Ubuntu Desktop 22.04 LTS, on my Windows laptop using Vagrant and Oracle VirtualBox lameriks 2023 08 26

I closed the system, via the VirtualBox menu File | Close | Save the machine state.

So, that is it. In this article, I shared with you the steps I took, to get my demo environment working again, after I run into some errors, with regard to VirtualBox Guest Additions in relation to Vagrant 2.3.6.

In a next article, I will describe how I extended this now improved environment with Terraform and Azure CLI.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.