dotless-de / vagrant-vbguest

A Vagrant plugin to keep your VirtualBox Guest Additions up to date
MIT License
2.88k stars 206 forks source link

GuestAdditions seems to be installed (6.1.18) correctly, but not running #405

Closed cedricroijakkers closed 9 months ago

cedricroijakkers commented 3 years ago

Software versions:

VirtualBox: 6.1.18 Vagrant: 2.2.14 Plugin vagrant-vbguest: 0.29.0

When booting my box for the first time, when provisioning, I get the following message:

==> default: Machine booted and ready!
[default] GuestAdditions seems to be installed (6.1.18) correctly, but not running.
Redirecting to /bin/systemctl start vboxadd.service
Redirecting to /bin/systemctl start vboxadd-service.service
VirtualBox Guest Additions: Starting.
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 
3.10.0-1160.11.1.el7.x86_64.
VirtualBox Guest Additions: Running kernel modules will not be replaced until 
the system is restarted
Restarting VM to apply changes...
==> default: Attempting graceful shutdown of VM...

After the reboot, the guest additions are no longer checked (or at least, not a message is printed) and the provisioning continues as normal.

However, I'm sure the guest additions are running in the box:

$ sudo systemctl status vboxadd-service
● vboxadd-service.service
   Loaded: loaded (/opt/VBoxGuestAdditions-6.1.18/init/vboxadd-service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-01-26 16:51:58 CET; 2min 18s ago
  Process: 4310 ExecStart=/opt/VBoxGuestAdditions-6.1.18/init/vboxadd-service start (code=exited, status=0/SUCCESS)
    Tasks: 9
   Memory: 2.2M
   CGroup: /system.slice/vboxadd-service.service
           └─4344 /usr/sbin/VBoxService --pidfile /var/run/vboxadd-service.sh

Jan 26 16:51:58 ccam-dev-vagrant systemd[1]: Starting vboxadd-service.service...
Jan 26 16:51:58 ccam-dev-vagrant vboxadd-service[4310]: vboxadd-service.sh: Starting VirtualBox Guest Addition service.
Jan 26 16:51:58 ccam-dev-vagrant systemd[1]: Started vboxadd-service.service.
[vagrant@ccam-dev-vagrant ~]$ ps -ef | grep -i vb
root       550     2  0 16:51 ?        00:00:00 [iprt-VBoxWQueue]
root      4344     1  0 16:51 ?        00:00:00 /usr/sbin/VBoxService --pidfile /var/run/vboxadd-service.sh
vagrant  24362 24034  0 16:54 pts/0    00:00:00 grep --color=auto -i vb

I've also disabled the vagrant-vbguest plugin in Vagrant, destroyed en provisioned the box again, and things like vboxsf are working file, so the guest additions are running just fine.

Te reproduce, you can init Vagrant with the following box: mrvantage/centos7-minikube and version 1.2.0-20210126.

Note: After later reboots (vagrant reload) the guest additions are detected correctly:

==> default: Machine booted and ready!
[default] GuestAdditions 6.1.18 running --- OK.
==> default: Checking for guest additions in VM...
glasswalk3r commented 3 years ago

Hi @cedricroijakkers,

I'm running CentOS Linux release 7.9.2009 (Core) and got the same problem with the same guest additions version (6.1.18).

I'm trying to figure out why vagrant-vbguest is trying to reinstall every time guest additions, but I guess the problem is with the script /opt/VBoxGuestAdditions-6.1.18/init/vboxadd. After I several times booting and reinstalling, I decided to manually try to setup and the issue remained.

This shell script is responsible for loading the kernel modules, in special vboxsf, which is not being loaded anyway. I used modprobe vboxsf manually, all worked fine. Reboot the VM, the module is not loaded.

I then disabled vagrant-vbguest in the Vagrantfile:

Vagrant.configure('2') do |config|
  config.vbguest.auto_update = false if Vagrant.has_plugin?('vagrant-vbguest')

And start seeing this message during VM boot:

==> default: Checking for guest additions in VM...
==> default: Rsyncing folder: /home/alceu/Projetos/vagrant-centos-vbguest/playbooks/ => /vagrant

Which means (I guess) the module is not being loaded and Vagrant is falling back to rsync.

After hacking the shell script, I enabled again the plugin and got this:

==> default: Machine booted and ready!
[default] GuestAdditions 6.1.18 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Rsyncing folder: /home/alceu/Projetos/vagrant-centos-vbguest/playbooks/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
alceu@yggdrasil:~/Projetos/vagrant-centos-vbguest$ vagrant ssh
Last login: Sun Feb  7 02:22:17 2021 from 10.0.2.2
[vagrant@localhost ~]$ lsmod | grep vbox
vboxsf                 81005  0 
vboxvideo              35867  0 
ttm                    96673  2 vmwgfx,vboxvideo
drm_kms_helper        186531  2 vmwgfx,vboxvideo
drm                   456166  5 ttm,drm_kms_helper,vmwgfx,vboxvideo
vboxguest             349038  2 vboxsf
[vagrant@localhost ~]$ 

I changed the start() function on the shell script like this:

[root@localhost ~]# diff -c /tmp/vboxadd /opt/VBoxGuestAdditions-6.1.18/init/vboxadd
*** /tmp/vboxadd    2021-02-07 02:36:27.407963028 +0000
--- /opt/VBoxGuestAdditions-6.1.18/init/vboxadd 2021-02-07 02:19:01.375108736 +0000
***************
*** 497,504 ****
              rm -f $userdev || {
                  fail "Cannot remove $userdev"
              }
-             $MODPROBE vboxsf > /dev/null 2>&1 ||
-                 info "modprobe vboxsf failed"
              $MODPROBE vboxguest >/dev/null 2>&1 ||
                  fail "modprobe vboxguest failed"
              case "$no_udev" in 1)
--- 497,502 ----
***************
*** 506,511 ****
--- 504,510 ----
              esac
          }

+         $MODPROBE vboxsf > /dev/null 2>&1 || info "modprobe vboxsf failed"

          case "$no_udev" in 1)
              do_vboxguest_non_udev;;

I don't get this previous logic, using modprobe vboxsf should happen independently of running_vboxguest setting $? as 0 or not. Maybe this hack will break something else, but so far it seems to work. I was able to setup shared folders and mount then automatically (and manually) and all worked.

pingram3030 commented 3 years ago

FWIW my vboxadd script was a little different for the same version as @glasswalk3r, which is rather odd, but this one works for me:

--- /opt/VBoxGuestAdditions-6.1.18/init/vboxadd 2021-03-16 04:06:15.928284593 +0000
+++ /opt/VBoxGuestAdditions-6.1.18/init/vboxadd 2021-03-16 04:07:36.249727179 +0000
@@ -499,9 +499,10 @@
             case "$no_udev" in 1)
                 sleep .5;;
             esac
-            $MODPROBE vboxsf > /dev/null 2>&1 ||
-                info "modprobe vboxsf failed"
         }
+        # HACK
+        $MODPROBE vboxsf > /dev/null 2>&1 ||
+            info "modprobe vboxsf failed"
         case "$no_udev" in 1)
             do_vboxguest_non_udev;;
         esac

Putting in the # HACK makes the patched file easily grep-able for programmatic use; patch exits non-zero if it's already been applied. patch -s -N -u /opt/VBoxGuestAdditions-6.1.18/init/vboxadd -i /tmp/vbox-add-6.1.18.patch

cscholze-atiba commented 3 years ago

@lisawoodruff I've been having the same issue. I had a machine working just fine a few weeks ago, and then one day it was unable to map a shared drive. Here's my stack of versions:

Mac OS: Big Sur 11.2.3 Vagrant: 2.2.16 Vagrant VBGuest Plugin: 0.29.0 VirtualBox: 6.1.22 Virtualbox Extension Pack: 6.1.22 Vagrant Ubuntu/Xenial64: 20210429.0.0

When running vagrant up I get:

==> default: Machine booted and ready!
[default] GuestAdditions seems to be installed (6.1.22) correctly, but not running.
update-initramfs: Generating /boot/initrd.img-4.4.0-210-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
VirtualBox Guest Additions: Starting.
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 4.4.0-210-generic.

VirtualBox Guest Additions: Look at /var/log/vboxadd-setup.log to find out what
went wrong

I can enter the machine and in /var/log/vboxadd-setup.log I see Could not find the X.Org or XFree86.

I've tried destroying the machine and re-provisioning. I've tried installing guest additions by inserting the .iso and manually mounting and installing. I've tried re-installing the guest kernel headers with sudo apt-get install kernel-headers.

One thing that does appear to work is if I uninstall or disable the vagrant-vbguest plugin. At that point the ubuntu/xenial box uses the default guest additions that came packaged in the ubuntu/xenial image.

glasswalk3r commented 3 years ago

It looks like a problem with Virtualbox Guest Additions, or at least, the integration between it and CentOS, I just have the same issue to build this version here. I had to disable the vagrant-vbguest plugin in the Vagrantfile with config.vbguest.auto_update = false and configure everything manually. :-( @pingram3030 , do you think it would be possible to apply this patch with installer_hooks[:before_install]? Although I'm not sure the best way to provide the patch file (I can only think about downloading with wget or something else).

rugabarbo commented 3 years ago

Workaround

Install guest additions manually.

Example for Ubuntu box

  1. First, remove vagrant-vbguest entries from Vagranfile.
  2. Then:
vagrant destroy -f
vagrant plugin uninstall vagrant-vbguest
vagrant up # May stop with an error. It doesn't matter now.
vagrant ssh
sudo apt-get update
sudo apt-get install build-essential linux-headers-$(uname -r)
sudo apt-get install virtualbox-guest-dkms
exit
vagrant halt
vagrant up

It's okay now.

My configuration

Mac OS: Catalina 10.15.7 Vagrant: 2.2.16 VBGuest plugin: 0.29.0 VirtualBox: 6.1.22 Vagrant box: bento/ubuntu-16.04 (virtualbox, 202104.19.0)

wizonesolutions commented 3 years ago

The 5.x VirtualBox Guest Additions from virtualbox-guest-dkms work without issue?

rugabarbo commented 3 years ago

The 5.x VirtualBox Guest Additions from virtualbox-guest-dkms work without issue?

My builds are fine. The folders are mounted.

Perhaps there may be problems in some cases. There is no guarantee. I have not tested all cases.

Any other method can be used for manual installation. It is not necessary to use dkms package.

lisawoodruff commented 3 years ago

I recently updated ubuntu from 16 to 18 and guest additions didn't seem to have a problem updating (to 6.1.22) after that. It's been booting reliably since the update so far.

rugabarbo commented 3 years ago

I recently updated ubuntu from 16 to 18 and guest additions didn't seem to have a problem updating (to 6.1.22) after that. It's been booting reliably since the update so far.

I also recently updated some VMs to Ubuntu 18.04. If you use box bento/ubuntu-18.04, then vbguest plugin is not needed, because guest additions are already preinstalled in this box.

glasswalk3r commented 3 years ago

I also recently updated some VMs to Ubuntu 18.04. If you use box bento/ubuntu-18.04, then vbguest plugin is not needed, because guest additions are already preinstalled in this box.

AFAIK, that only happens with CentOS. I tested my self against the boxes generic/centos8 and centos/7.

jakec-dev commented 3 years ago

Experiencing the same issue here with Red Hat 8. Issue here: https://github.com/dotless-de/vagrant-vbguest/issues/414

XSERJ commented 3 years ago

I've been struggling with this issue for a month or so. Got rid of it by simply removing vagrant-bguest plugin. I guess it's not needed for 'bento/ubuntu-20.04' box.

Configuration: Mac OS: Big Sur 11.4 Vagrant: 2.2.17 VirtualBox: 6.1.22 Vagrant box: bento/ubuntu-20.04 (virtualbox, 202107.07.0)

OnceUponALoop commented 3 years ago

On CentOS 8 (specifically centos/8) I was able to workaround this issue by just adding vboxsf to the systemd module-load service configuration. It accomplishes the same end result without having to patch the vbox script.

This should be considered a temporary fix until virtualbox fixes the script, at which point we'll just need to delete /etc/modules-load.d/vboxsf.conf

I used the :before_install hook as follows

Vagrant.configure("2") do |config|
  # Ensure virtualbox guest plugins are installed and latest
  config.vagrant.plugins = ["vagrant-vbguest"]

  # Box
  config.vm.box = "centos/8"

  # VM Properties
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "4096"
    vb.cpus = "2"
  end

  # Install Mock
  config.vm.provision "shell", inline: <<-SHELL
    sudo dnf update -y
  SHELL

  # Force Virtualbox sync
  config.vm.synced_folder ".", "/vagrant", type: "virtualbox"

  # VBox Guest options
  config.vbguest.auto_update = true
  config.vbguest.installer_options = { allow_kernel_upgrade: true }
  config.vbguest.installer_hooks[:before_start] = [
    "echo 'vboxsf' > /etc/modules-load.d/vboxsf.conf", 
    "systemctl restart systemd-modules-load.service", 
    "echo '=== Verifying vboxsf module is loaded'", 
    "cat /proc/modules | grep vbox" 
  ]

end
eldho-varghese commented 3 years ago

Hi All

Same issue for me as well.

[user@centos rhcsa8env]$ vagrant vbguest --status [server2] GuestAdditions seems to be installed (6.1.26) correctly, but not running. [repo] GuestAdditions seems to be installed (6.1.26) correctly, but not running. [workstation] GuestAdditions seems to be installed (6.1.26) correctly, but not running. [server1] GuestAdditions seems to be installed (6.1.26) correctly, but not running. [user@centos rhcsa8env]$

However, All the boxes are up and running with guest addition services

[root@server2 ~]# systemctl list-units |grep vboxadd vboxadd-service.service loaded active running vboxadd-service.service vboxadd.service loaded active exited vboxadd.service [root@server2 ~]#

following modules are loaded, However I can't see "vboxsf" and "vboxadd" module as loaded [root@server2 ~]# lsmod |grep vbox vboxvideo 49152 1 drm_kms_helper 200704 1 vboxvideo ttm 131072 1 vboxvideo drm 520192 4 drm_kms_helper,vboxvideo,ttm vboxguest 393216 1 [root@server2 ~]#

and the service startup script "/opt/VBoxGuestAdditions-6.1.26/init/vboxadd" always build the module for kernel. Could be the modules are not loaded correctly ? Why vagrant thinks thinks guest additions are installed but not running ?

[user@centos ~]$ vboxmanage --version 6.1.26r145957 [user@centos ~]$ vagrant --version Vagrant 2.2.18 [user@centos ~]$ vagrant plugin list vagrant-guest_ansible (0.0.4, global)

Version Constraint: > 0 vagrant-vbguest (0.30.0, global) [user@centos ~]$

OnceUponALoop commented 2 years ago

@eldho-varghese did you try the workaround above?

eniel commented 2 years ago

Hello, I had the same issue; after switching to nfs for synced folders.

It seems de vboxsf module is not loaded in that case. This can be seen with the command cat /proc/modules |grep 'vboxsf' in the client.

As a last resort I read the readme file more carefully. It states the following for Linux type installers:

Linux

This option is available on all Linux type installers.

  • :running_kernel_modules (default: ["vboxguest", "vboxsf"]) The list used to check for the "running" state. Each of these modules need to appear at the beginning of a line in /proc/modules.

So the solution was to add the following line to the plugin configuration: config.vbguest.installer_options = { running_kernel_modules: ["vboxguest"] }

my vbguest configuration:

if Vagrant.has_plugin?("vagrant-vbguest")
        config.vbguest.installer_options = { running_kernel_modules: ["vboxguest"] }
        config.vbguest.auto_update = true
end

This solved it for me.

aitseitz commented 2 years ago

On CentOS 8 (specifically centos/8) I was able to workaround this issue by just adding vboxsf to the systemd module-load service configuration. It accomplishes the same end result without having to patch the vbox script.

This should be considered a temporary fix until virtualbox fixes the script, at which point we'll just need to delete /etc/modules-load.d/vboxsf.conf

I used the :before_install hook as follows

Vagrant.configure("2") do |config|
  # Ensure virtualbox guest plugins are installed and latest
  config.vagrant.plugins = ["vagrant-vbguest"]

  # Box
  config.vm.box = "centos/8"

  # VM Properties
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "4096"
    vb.cpus = "2"
  end

  # Install Mock
  config.vm.provision "shell", inline: <<-SHELL
    sudo dnf update -y
  SHELL

  # Force Virtualbox sync
  config.vm.synced_folder ".", "/vagrant", type: "virtualbox"

  # VBox Guest options
  config.vbguest.auto_update = true
  config.vbguest.installer_options = { allow_kernel_upgrade: true }
  config.vbguest.installer_hooks[:before_start] = [
    "echo 'vboxsf' > /etc/modules-load.d/vboxsf.conf", 
    "systemctl restart systemd-modules-load.service", 
    "echo '=== Verifying vboxsf module is loaded'", 
    "cat /proc/modules | grep vbox" 
  ]

end

Thank you very much, The workaround provided worked for me ;-) The only issue I had was that centos/8 box image is now outdated and I've you're trying it now, it will give you the internal mirrorlist error while booting up:

==> default: Machine booted and ready!
[default] No Virtualbox Guest Additions installation found.
CentOS Linux 8 - AppStream                      105  B/s |  38  B     00:00    
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
Unmounting Virtualbox Guest Additions ISO from: /mnt
umount: /mnt: not mounted.

Reason is, that CentOS 8 has reached its end-of-life and all official package mirrors have been removed by CentOS Team by the end of January 31, 2022.

Solution is to use another CentOS Stream version with the official https://vault.centos.org/ mirrors. In your vagrant file you can use

  # Box
  config.vm.box = "centos/stream8"

and virtualbox guest extensions will be installed properly:

Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
Installing Virtualbox Guest Additions 6.1.32 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.32 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
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 
4.18.0-365.el8.x86_64.
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

echeadle commented 1 year ago

GuestAdditions 7.0.4 gives the same error message as the 6.1.18 version did. I am running it on Ubuntu 20.04.1.

The Apr 30 message says stale. yet the issue has not been fixed. I also says it added the wontfix label to this issue. Is there a discussion as to why it won't be fixed? Just curious. I am relatively new to using vagrant and I am just trying to figure out how this all works.

small-pants commented 1 year ago

I have Guest Additions 6.1.40 installed for an Ubuntu 18.04 guest and removing the vagrant-vbguest plugin solved the issue for me.

paulmueller commented 1 year ago

For me, installing sudo apt install virtualbox-guest-utils on the guest (Ubuntu 20.04) solved the issue.