Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Installation/Update of Virtualbox Guest Additions fails #351

Closed
HubertSadecki opened this issue Sep 25, 2019 · 60 comments
Closed

Installation/Update of Virtualbox Guest Additions fails #351

HubertSadecki opened this issue Sep 25, 2019 · 60 comments

Comments

@HubertSadecki
Copy link

HubertSadecki commented Sep 25, 2019

Environment:

Windows: 10 ver. 1803
Virtualbox version: 6.0.12r133076 # The same error occured for Virtualbox 5.2.26
Vagrant version: Vagrant 2.2.4

Using latest debian stretch (9.9.1) vagrant box:

  config.vm.box = "debian/stretch64"

And latest vagrant-vbguest:

vagrant-vbguest (0.19.0, global)

When running vagrant up or vagrant vbguest I got following error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

apt-get install -y linux-headers-`uname -r` dkms

Stdout from the command:

Reading package lists...
Building dependency tree...
Reading state information...


Stderr from the command:

E: Unable to locate package linux-headers-4.9.0-9-amd64
E: Couldn't find any package by glob 'linux-headers-4.9.0-9-amd64'
E: Couldn't find any package by regex 'linux-headers-4.9.0-9-amd6
@ecom-db
Copy link

ecom-db commented Sep 25, 2019

We are having the same issue, similar setup as above but with box "debian/jessie64"

From vagrant up:

[default] No Virtualbox Guest Additions installation found.
...
0 upgraded, 32 newly installed, 0 to remove and 0 not upgraded.
...
Err http://security.debian.org/ jessie/updates/main linux-libc-dev amd64 3.16.68-1
  404  Not Found [IP: 151.101.36.204 80]
Err http://security.debian.org/ jessie/updates/main linux-compiler-gcc-4.9-x86 amd64 3.16.68-1
  404  Not Found [IP: 151.101.36.204 80]
Err http://security.debian.org/ jessie/updates/main linux-headers-3.16.0-9-common amd64 3.16.68-1
  404  Not Found [IP: 151.101.36.204 80]
Err http://security.debian.org/ jessie/updates/main linux-headers-3.16.0-9-amd64 amd64 3.16.68-1
  404  Not Found [IP: 151.101.36.204 80]
Err http://security.debian.org/ jessie/updates/main linux-headers-amd64 amd64 3.16+63+deb8u5
  404  Not Found [IP: 151.101.36.204 80]
Fetched 22.9 MB in 8s (2,756 kB/s)
E: Failed to fetch http://security.debian.org/pool/updates/main/l/linux/linux-libc-dev_3.16.68-1_amd64.deb  404  Not Found [IP: 151.101.36.204 80]
E: Failed to fetch http://security.debian.org/pool/updates/main/l/linux/linux-compiler-gcc-4.9-x86_3.16.68-1_amd64.deb  404  Not Found 
[IP: 151.101.36.204 80]
E: Failed to fetch http://security.debian.org/pool/updates/main/l/linux/linux-headers-3.16.0-9-common_3.16.68-1_amd64.deb  404  Not Found [IP: 151.101.36.204 80]
E: Failed to fetch http://security.debian.org/pool/updates/main/l/linux/linux-headers-3.16.0-9-amd64_3.16.68-1_amd64.deb  404  Not Found [IP: 151.101.36.204 80]
E: Failed to fetch http://security.debian.org/pool/updates/main/l/linux-latest/linux-headers-amd64_3.16+63+deb8u5_amd64.deb  404  Not Found [IP: 151.101.36.204 80]
...
E: Unable to locate package linux-headers-3.16.0-9-amd64
E: Couldn't find any package by regex 'linux-headers-3.16.0-9-amd64'
...

@checkphi
Copy link

Having the same issue.
I think vbguest should perform "apt-get update" before running install.

@checkphi
Copy link

I found it. I was using a debian base box (stretch64) which has linux kernel 4.9.0-9 installed. The vbguest plugin is using uname -r to define the version, so it tries to install linux-headers-4.9.0-9 which does not exist on the mirrors anymore (it's 4.9.0-11 now).

Not sure how to solve it. Of course it needs to get the headers of the current kernel, but it limits you to base boxes which are very up to date.

@ghost
Copy link

ghost commented Sep 27, 2019

For me a solution similar to the apt update (that can be turned off from config) would be just perfect.
At the moment we cannot automate our pipline due to this limitation.
Is there any "automatic" workaround? Ex perform some "provision" steps before executing the plugin or customizing and addng custom script to the plugin through the Vagrant config file ?

@Mephistokrates
Copy link

Mephistokrates commented Sep 27, 2019

As a workaround I created a provisioning step for a dist-upgrade on my debian pipeline while disabling the plugin in that step.
This at least keeps the chain working further up.

@HubertSadecki
Copy link
Author

HubertSadecki commented Sep 27, 2019

As a workaround you can disable auto update in Vagrantfile.

config.vbguest.auto_update = false

It won't raise error on provision and won't install Virtualbox Guest Additions as well.

@FunTimeCoding
Copy link

@Mephistokrates Would you mind sharing how you did that? I've fiddled with triggers for a bit now and couldn't get that to work.

@ghost
Copy link

ghost commented Sep 29, 2019

This is how far I got:

# -*- mode: ruby -*-
# vi: set ft=ruby :

unless Vagrant.has_plugin?("vagrant-vbguest")
  puts 'Installing vagrant-vbguest Plugin...'
  system('vagrant plugin install vagrant-vbguest')
end

Vagrant.configure("2") do |config|

  config.vm.box = "debian/buster64"
  
  class WorkaroundVbguest < VagrantVbguest::Installers::Linux
    def install(opts=nil, &block)
	  puts 'Executing update workaround...'
	  communicate.sudo('apt-get -y --force-yes update', (opts || {}).merge(:error_check => false), &block)
	  communicate.sudo('apt-get -y --force-yes upgrade', (opts || {}).merge(:error_check => false), &block)
          communicate.sudo('apt-get -y install build-essential', (opts || {}).merge(:error_check => false), &block)=> false), &block)
	  puts 'Continue vbguest installation...'
      super
         puts 'Perform vbguest post installation steps...'
	  communicate.sudo('usermod -a -G vboxsf vagrant', (opts || {}).merge(:error_check => false), &block)
    end
  end
  
  config.vbguest.installer = WorkaroundVbguest

  config.vm.synced_folder "../image", "/image"
end

But synced folder mount still fails fir the first vagrant up.
(But executing the command again mounts the folders and so it seems as a reboot is missing from somewhere)

default: /image => D:/work/tank/cross_compile/image
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 image /image

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

Also there is an interesting part during guest install that might be related:

Setting up build-essential (12.6) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10) ...
Continue vbguest installation...
Copy iso file C:\Program Files\Oracle\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.0.12 - guest version is 5.2.0
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.0.12 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: Kernel headers not found for target kernel
4.19.0-5-amd64. Please install them and execute
  /sbin/rcvboxadd setup
VirtualBox Guest Additions: Running kernel modules will not be replaced until
the system is restarted
An error occurred during installation of VirtualBox Guest Additions 6.0.12. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
Unmounting Virtualbox Guest Additions ISO from: /mnt

Any suggestion?

@Flo2345
Copy link

Flo2345 commented Sep 30, 2019

Experiencing the same issue.

In my opinion, doing an apt-get update is tolerable. However, an apt-get upgrade can only be a workaround at best. It makes the whole concept of version-controlling the configuration of a virtual machine pointless.

Example: Let's say one uses desktop VMs for development. Some day a bug occurs that is suspected to be related to machine configuration. One recreates a machine from a couple weeks ago to track down the bug. With upgrading being a part of machine creation this will lead nowhere.

@Flo2345
Copy link

Flo2345 commented Sep 30, 2019

I may have an alternative solution that doesn't require to upgrade the whole system.

It requires adding appropriate debian archive repositories (snapshots) to sources.list before running apt-get update and installing the guest additions.

Source:
Why do previous versions of debian packages vanish in the package repositories?
Failed to update linux headers on debian stretch

@wachjose88
Copy link

I can confirm this problem with a "debian/contrib-buster64" box in this environment:

Virtualbox 6.0.12,
Vagrant 2.2.5,
vagrant-vbguest 0.20.0,

I can also confirm that manually upgrading and rebooting the box is a workaround.

The error happens when it is tried to install the kernel headers with the command apt-get install -y linux-headers-`uname -r` dkms. This fails because the headers for the old running kernel are no longer in the repositories. Using apt-get install -y linux-headers-`dpkg --print-architecture` dkms is no solution because the kernel is not updated through this package.

@gzp79
Copy link

gzp79 commented Sep 30, 2019

Case solved for me:
As the virtual env is used for cross compile, and actually all major distros have the required toolset I could easily switch to ubuntu (where it is working for some reason).
Debian is only the target for the cross compile which is just fine. In other words the host and cross compile target don't have to be the same and it solve the issue for me.
(Though it'd be grate if vbguest can work out of the box for debian too)

@checkphi
Copy link

@gzp-crey The reason why Ubuntu is working is probably because the base box is more current. Some of them (for example xenial) have been released some days ago.

I still think the "right" solution would be to have a configuration parameter that allows the plugin to run apt-get update and a kernel-upgrade before actually installing the additions. If I was familiar with Ruby I would submit a PR by myself, but... I'm not. @fnordfish ? :)

@wachjose88
Copy link

@checkphi yes, your recommendation for a solution seems to be the most useful variant. The aproach, shown by @zpgaal seems to be a starting point. It only lacks the reboot after the upgrade.

@fnordfish
Copy link
Member

fnordfish commented Oct 1, 2019 via email

@checkphi
Copy link

checkphi commented Oct 1, 2019

@fnordfish But wouldn't you say that this should be a native feature of the plugin instead of fixing it with a custom method?

Although it's not affecting every user and depends on the version of the base box, it's a systematic problem which is very likely to happen in the future again.

@wachjose88
Copy link

@fnordfish When exactly will this reboot happen? After installing the guest additions is too late because the reboot has to happen before the installation but after the upgrade of the box.

@checkphi I am also the oppinion that this should be a native feature of the plugin because of the same reasons.

@shrimpwagon
Copy link

I've confirmed the error with debian/buster64 as well.

@moduspwnens
Copy link

We ran into this issue a few days ago.

I'm sure it doesn't apply to everyone's use case, but for ours, we are also the same people building the Vagrant box with packer, and we use the Debian 9.9.0 ISO to do it.

I worked around this by adding linux-headers-$(uname -r) to the debian preseed config file as a d-i pkgsel/include value. My understanding is this results in the appropriate Linux headers package being installed during that initial setup and pulled from the ISO media, so they're then already installed when vagrant-vbguest goes to install / upgrade the guest additions.

This avoids having to figure out how to fetch them later (e.g. from a snapshot repo), and also ensures this won't happen again when we start using a later ISO and its kernel headers get removed from public repos, too.

@shrimpwagon
Copy link

@moduspwnens That sounds awesome and thank you but how exactly do I fix the issue? What do I need to do or not do? Thank you!

@moduspwnens
Copy link

@shrimpwagon It only applies if you're building your own VirtualBox box files from one of the official Debian ISOs, which I don't think is the most common use case for Vagrant. From my research, it looks like it's far more common to use one of the ones Vagrant Cloud packages up and provides (e.g. config.vm.box = "debian/stretch64").

If you're building them from the ISOs, your work will look more like this example here:
https://github.com/geerlingguy/packer-debian-9

In that repo, you'll find a http/preseed.cfg file and a line starting with d-i pkgsel/include. You'd want to add linux-headers-$(uname -r) to that line.

But switching to building your own Debian vagrant boxes (if you're not already doing that) just to workaround this issue is likely overkill.

@djomlastic
Copy link

djomlastic commented Oct 3, 2019

I had some time to try a few things. As we know, the headers are no longer available from the repositories and we can get them from the snapshot archive repositories (snapshot.debian.org). Here is a custom installer that works for debian/stretch64 v9.9.1 box, and will work for debian/buster64 v9.99.2 if you uncomment the command. I tried it with debian/buster64 v10.0.0, the headers are there, but it doesn't mount shared folders: Vagrant was unable to mount VirtualBox shared folders (tested with virtualbox 5.2.32 and 5.2.18). I don't use a buster box, so it might be some problem on my side, if you had a working one you can give it a try.

FIle: ./utility/vbg-installer.rb

module Utility

    # Custom Debian installer for Vbguest
    class DebianCustom < VagrantVbguest::Installers::Debian
    
        # Adds snapshot archive repo to sources
        def install(opts=nil, &block)
            
            cmd = <<~SCRIPT
                cat <<EOF > /etc/apt/sources.list.d/snapshot_archive.list
                deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20190801T025637Z/ stretch main
                deb [check-valid-until=no] http://snapshot.debian.org/archive/debian-security/20190801T025637Z/ stretch/updates main
                EOF
            SCRIPT

            # Uncomment if running a Buster box
            # cmd = <<~SCRIPT
            #     cat <<EOF > /etc/apt/sources.list.d/snapshot_archive.list
            #     deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20190812T140702Z/ buster main
            #     deb [check-valid-until=no] http://snapshot.debian.org/archive/debian-security/20190812T140702Z/ buster/updates main
            #     EOF
            # SCRIPT

            communicate.sudo(cmd, opts, &block)

            super
        end

        def cleanup
            # Uncomment to remove the snapshot archive repo from sources
            # communicate.sudo('rm /etc/apt/sources.list.d/snapshot_archive.list')
            
            super
        end
    end
end

File: ./Vagrantfile

...
# Vagrant configuration
Vagrant.configure('2') do |config|

    # Load custom vbguest installer
    if defined?(VagrantVbguest::Installers::Debian)

        require_relative 'utility/vbg-installer'
        config.vbguest.installer = Utility::DebianCustom
    end
...

Hopefully they'll upgrade boxes to run a kernel which is available from the repository, and this can be useful when we need to run an older box.

@hsarbia
Copy link

hsarbia commented Oct 7, 2019

Thanks a lot @djomlastic, you probably just saved my week :-)

@checkphi
Copy link

checkphi commented Oct 7, 2019

@fnordfish can you comment if a native fix is planned?
I know I'm asking every week, but I love your plugin and want to continue using it...

@fnordfish
Copy link
Member

@checkphi sorry to say, but I totally really on pull requests for fixing OS support stuff.
I might plan to rebuild how the entire install/restart/rebuild step (aka run list) are build, giving more control to integrations. But I cannot give any time frame on this.

@ikari7789
Copy link

Problem seems to also affect CentOS 7 as well, just to chime in.

@carlosefr
Copy link
Contributor

carlosefr commented Oct 10, 2019

Which version of CentOS?

As for Debian, I've been trying something like this:

begin
    class FixGuestAdditions < VagrantVbguest::Installers::Debian
        def install(opts=nil, &block)
            # If the "linux-headers" package matching the running kernel can't be found in the default
            # repositories, then we will look for it in the archives at the time the kernel was current...
            communicate.sudo("SNAPSHOT=$(stat -c %Y /lib/modules/$(uname -r) | xargs -I{} date -d @{} -u +'%Y%m%dT%H%M%SZ') &&" \
                             "RELEASE=$(lsb_release -s -c) &&" \
                             "REPOSITORY=https://snapshot.debian.org/archive &&" \
                             "printf \"deb\t${REPOSITORY}/debian/${SNAPSHOT}/ ${RELEASE} main\n" \
                                      "deb\t${REPOSITORY}/debian-security/${SNAPSHOT}/ ${RELEASE}/updates main\n\"" \
                                      "> /etc/apt/sources.list.d/snapshot.list &&" \
                             "printf 'Package: linux-headers linux-headers-$(dpkg --print-architecture)\n" \
                                     "Pin: origin \"snapshot.debian.org\"\n" \
                                     "Pin-Priority: 1001\n'" \
                                     "> /etc/apt/preferences.d/snapshot")
            super
        end

        def cleanup
            communicate.sudo("rm -f /etc/apt/sources.list.d/snapshot.list /etc/apt/preferences.d/snapshot")
            super
        end
    end

    # Anything with priority over 5 overrides the default installer...
    VagrantVbguest::Installer.register(FixGuestAdditions, 100)
rescue NameError
    # The "VagrantVbguest" class won't be available during the first pass,
    # when vagrant is checking for required plugins and stuff like that...
end

On buster (Debian 10) the modules build sucessfully but don't load after reboot with errors like x86/modules: Skipping invalid relocation target (seems related to the kernel being signed or something).

On stretch (Debian 9) the process hangs while getting packages from the repo.

One thing that's bugging me is what changed? Is the removal of old packages from the repos a new thing?

Last time I've checked, I could vagrant up stretch and buster VMs just fine without these shenanigans and I'm using the same debian/buster64 from 3 months ago and debian/stretch64 is even older at 4 months.

I'm using VirtualBox 6.0.12, can't remember what version I was using the last time I launched VMs with these OSes.

@ikari7789
Copy link

@carlosefr bento/centos-7 v201907.24.0
It cannot find the kernel-devel package in the update and installs a newer version of the kernel-headers and then fails to install, but still reboots.

$ vagrant init bento/centos-7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

$ vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching: micromachine-3.0.0.gem (100%)
Fetching: vagrant-vbguest-0.20.0.gem (100%)
Installed the plugin 'vagrant-vbguest (0.20.0)'!

$ export VAGRANT_DEFAULT_PROVIDER=virtualbox

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-7' version '201907.24.0' is up to date...
==> default: Setting the name of the VM: 7_default_1570759763507_25565
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
[default] GuestAdditions versions on your host (6.0.12) and guest (6.0.10) do not match.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
No package kernel-devel-3.10.0-957.21.3.el7.x86_64 available.
Package 4:perl-5.16.3-294.el7_6.x86_64 already installed and latest version
Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package binutils.x86_64 0:2.27-34.base.el7 will be updated
---> Package binutils.x86_64 0:2.27-41.base.el7 will be an update
---> Package gcc.x86_64 0:4.8.5-39.el7 will be installed
--> Processing Dependency: libgomp = 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: cpp = 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-39.el7 for package: gcc-4.8.5-39.el7.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-39.el7.x86_64
---> Package kernel-devel.x86_64 0:3.10.0-1062.1.2.el7 will be installed
---> Package make.x86_64 1:3.82-23.el7 will be updated
---> Package make.x86_64 1:3.82-24.el7 will be an update
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-39.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-292.el7 will be installed
--> Processing Dependency: glibc-headers = 2.17-292.el7 for package: glibc-devel-2.17-292.el7.x86_64
--> Processing Dependency: glibc = 2.17-292.el7 for package: glibc-devel-2.17-292.el7.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-292.el7.x86_64
---> Package libgcc.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package libgcc.x86_64 0:4.8.5-39.el7 will be an update
---> Package libgomp.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package libgomp.x86_64 0:4.8.5-39.el7 will be an update
--> Running transaction check
---> Package glibc.x86_64 0:2.17-260.el7_6.6 will be updated
--> Processing Dependency: glibc = 2.17-260.el7_6.6 for package: glibc-common-2.17-260.el7_6.6.x86_64
---> Package glibc.x86_64 0:2.17-292.el7 will be an update
---> Package glibc-headers.x86_64 0:2.17-292.el7 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-292.el7.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-292.el7.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-260.el7_6.6 will be updated
---> Package glibc-common.x86_64 0:2.17-292.el7 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-1062.1.2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch        Version                     Repository    Size
================================================================================
Installing:
 gcc                 x86_64      4.8.5-39.el7                base          16 M
 kernel-devel        x86_64      3.10.0-1062.1.2.el7         updates       18 M
Updating:
 binutils            x86_64      2.27-41.base.el7            base         5.9 M
 make                x86_64      1:3.82-24.el7               base         421 k
Installing for dependencies:
 cpp                 x86_64      4.8.5-39.el7                base         5.9 M
 glibc-devel         x86_64      2.17-292.el7                base         1.1 M
 glibc-headers       x86_64      2.17-292.el7                base         687 k
 kernel-headers      x86_64      3.10.0-1062.1.2.el7         updates      8.7 M
Updating for dependencies:
 glibc               x86_64      2.17-292.el7                base         3.6 M
 glibc-common        x86_64      2.17-292.el7                base          11 M
 libgcc              x86_64      4.8.5-39.el7                base         102 k
 libgomp             x86_64      4.8.5-39.el7                base         158 k

Transaction Summary
================================================================================
Install  2 Packages (+4 Dependent packages)
Upgrade  2 Packages (+4 Dependent packages)

Total download size: 72 M
Downloading packages:
No Presto metadata available for base
No Presto metadata available for updates
--------------------------------------------------------------------------------
Total                                              6.2 MB/s |  72 MB  00:11
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libgcc-4.8.5-39.el7.x86_64                                  1/18
  Updating   : glibc-common-2.17-292.el7.x86_64                            2/18
  Updating   : glibc-2.17-292.el7.x86_64                                   3/18
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
  Installing : cpp-4.8.5-39.el7.x86_64                                     4/18
  Updating   : binutils-2.27-41.base.el7.x86_64                            5/18
  Updating   : libgomp-4.8.5-39.el7.x86_64                                 6/18
  Installing : kernel-headers-3.10.0-1062.1.2.el7.x86_64                   7/18
  Installing : glibc-headers-2.17-292.el7.x86_64                           8/18
  Installing : glibc-devel-2.17-292.el7.x86_64                             9/18
  Installing : gcc-4.8.5-39.el7.x86_64                                    10/18
  Updating   : 1:make-3.82-24.el7.x86_64                                  11/18
  Installing : kernel-devel-3.10.0-1062.1.2.el7.x86_64                    12/18
  Cleanup    : 1:make-3.82-23.el7.x86_64                                  13/18
  Cleanup    : libgomp-4.8.5-36.el7_6.2.x86_64                            14/18
  Cleanup    : binutils-2.27-34.base.el7.x86_64                           15/18
  Cleanup    : glibc-common-2.17-260.el7_6.6.x86_64                       16/18
  Cleanup    : glibc-2.17-260.el7_6.6.x86_64                              17/18
  Cleanup    : libgcc-4.8.5-36.el7_6.2.x86_64                             18/18
  Verifying  : glibc-devel-2.17-292.el7.x86_64                             1/18
  Verifying  : glibc-2.17-292.el7.x86_64                                   2/18
  Verifying  : kernel-headers-3.10.0-1062.1.2.el7.x86_64                   3/18
  Verifying  : cpp-4.8.5-39.el7.x86_64                                     4/18
  Verifying  : binutils-2.27-41.base.el7.x86_64                            5/18
  Verifying  : kernel-devel-3.10.0-1062.1.2.el7.x86_64                     6/18
  Verifying  : libgomp-4.8.5-39.el7.x86_64                                 7/18
  Verifying  : 1:make-3.82-24.el7.x86_64                                   8/18
  Verifying  : gcc-4.8.5-39.el7.x86_64                                     9/18
  Verifying  : glibc-common-2.17-292.el7.x86_64                           10/18
  Verifying  : libgcc-4.8.5-39.el7.x86_64                                 11/18
  Verifying  : glibc-headers-2.17-292.el7.x86_64                          12/18
  Verifying  : libgomp-4.8.5-36.el7_6.2.x86_64                            13/18
  Verifying  : libgcc-4.8.5-36.el7_6.2.x86_64                             14/18
  Verifying  : glibc-2.17-260.el7_6.6.x86_64                              15/18
  Verifying  : 1:make-3.82-23.el7.x86_64                                  16/18
  Verifying  : glibc-common-2.17-260.el7_6.6.x86_64                       17/18
  Verifying  : binutils-2.27-34.base.el7.x86_64                           18/18

Installed:
  gcc.x86_64 0:4.8.5-39.el7      kernel-devel.x86_64 0:3.10.0-1062.1.2.el7

Dependency Installed:
  cpp.x86_64 0:4.8.5-39.el7
  glibc-devel.x86_64 0:2.17-292.el7
  glibc-headers.x86_64 0:2.17-292.el7
  kernel-headers.x86_64 0:3.10.0-1062.1.2.el7

Updated:
  binutils.x86_64 0:2.27-41.base.el7          make.x86_64 1:3.82-24.el7

Dependency Updated:
  glibc.x86_64 0:2.17-292.el7         glibc-common.x86_64 0:2.17-292.el7
  libgcc.x86_64 0:4.8.5-39.el7        libgomp.x86_64 0:4.8.5-39.el7

Complete!
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 6.0.12 - guest version is 6.0.10
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.0.12 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 6.0.10 of VirtualBox Guest Additions...
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: Kernel headers not found for target kernel
3.10.0-957.21.3.el7.x86_64. Please install them and execute
  /sbin/rcvboxadd setup
VirtualBox Guest Additions: Running kernel modules will not be replaced until
the system is restarted
An error occurred during installation of VirtualBox Guest Additions 6.0.12. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
Redirecting to /bin/systemctl start vboxadd.service
Redirecting to /bin/systemctl start vboxadd-service.service
Unmounting Virtualbox Guest Additions ISO from: /mnt
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.10
VBoxService inside the vm claims: 6.0.12
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.10
VBoxService inside the vm claims: 6.0.12
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   6.0.10
VBoxService inside the vm claims: 6.0.12
Going on, assuming VBoxService is correct...
Restarting VM to apply changes...
==> default: Attempting graceful shutdown of VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Mounting shared folders...
    default: /vagrant => /Users/andrew.miller/Development/tests/centos/7
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

@eroux
Copy link

eroux commented Feb 27, 2020

my understanding is that the fact that it works is purely circumstantial and is due to the fact that there are no kernel updates necessary in the new box; and that the problem will reappear once kernel updates are available. Or am I mistaken?

@wachjose88
Copy link

@eroux This is my understanding too. The most useful workaround is the way of @shrimpwagon .

@alxbridge
Copy link

Drawing heavily from #351 (comment) and the follow-up comment from @fnordfish got me to this solution, which seems to do the job for my local boxes:

  # Workaround to prevent missing linux headers making new installs fail.
  # Put into Vagrantfile directly under your `config.vm.box` definition

  class WorkaroundVbguest < VagrantVbguest::Installers::Linux
    def install(opts=nil, &block)
          puts 'Ensuring we\'ve got the correct build environment for vbguest...'
          communicate.sudo('apt-get -y --force-yes update', (opts || {}).merge(:error_check => false), &block)
          communicate.sudo('apt-get -y --force-yes install -y build-essential linux-headers-amd64 linux-image-amd64', (opts || {}).merge(:error_check => false), &block)
          puts 'Continuing with vbguest installation...'
        super
          puts 'Performing vbguest post-installation steps...'
            communicate.sudo('usermod -a -G vboxsf vagrant', (opts || {}).merge(:error_check => false), &block)
    end
    def reboot_after_install?(opts=nil, &block)
      true
    end
  end

  config.vbguest.installer = WorkaroundVbguest
  # End workaround

@eroux
Copy link

eroux commented Mar 17, 2020

why closing the issue?

@hyamamoto
Copy link

Well, It's still happening to me for a debian/buster image with vagrant-vbguest 0.23.0

@glen-84
Copy link

glen-84 commented Mar 21, 2020

@HubertSadecki Please reopen the issue.

@fnordfish fnordfish reopened this Mar 21, 2020
@kergekacsa
Copy link

I have the same problem with debian/jessie64.
Thanks for the workaround thou, that helped me out. But it's still just a workaround :(

@Volker-Weissmann
Copy link

I had the same problem under Arch Linux.
It disappeared seemingly randomly and now I can't reproduce it. I think it got fixed by either rebooting, pacman -Syu or running vagrant init debian instead of vagrant init debian/jessie64.
My error output was:

[volker@battle ~]$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'debian/jessie64' version '8.11.1' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
/home/volker/.vagrant.d/gems/2.7.0/gems/vagrant-vbguest-0.23.0/lib/vagrant-vbguest/middleware.rb:24: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/opt/vagrant/embedded/gems/gems/i18n-1.8.2/lib/i18n.rb:195: warning: The called method `t' is defined here
[default] No Virtualbox Guest Additions installation found.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package linux-headers-3.16.0-9-amd64
E: Couldn't find any package by regex 'linux-headers-3.16.0-9-amd64'
Hit http://security.debian.org jessie/updates InRelease
Ign http://httpredir.debian.org jessie InRelease
Hit http://httpredir.debian.org jessie Release.gpg
Hit http://httpredir.debian.org jessie Release
Hit http://security.debian.org jessie/updates/main Sources
Hit http://httpredir.debian.org jessie/main Sources
Hit http://httpredir.debian.org jessie/main amd64 Packages
Hit http://security.debian.org jessie/updates/main amd64 Packages
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package linux-headers-3.16.0-9-amd64
E: Couldn't find any package by regex 'linux-headers-3.16.0-9-amd64'
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

apt-get install -y linux-headers-uname -r dkms

Stdout from the command:

Reading package lists...
Building dependency tree...
Reading state information...

Stderr from the command:

E: Unable to locate package linux-headers-3.16.0-9-amd64
E: Couldn't find any package by regex 'linux-headers-3.16.0-9-amd64'

@stale
Copy link

stale bot commented May 30, 2020

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.

@stale stale bot added the wontfix label May 30, 2020
@stale stale bot closed this as completed Jun 6, 2020
@glen-84
Copy link

glen-84 commented Jun 6, 2020

@fnordfish Can you please reopen this issue and label it so that it doesn't get automatically closed?

@DJviolin
Copy link

I tried this solution, but still not able to silence the linux-headers-4.9.0-3-amd64 kernel update... Trying out apt-mark hold linux-headers-4.9.0-3-amd64 also throws error, because this is a non-existing package, there's nothing to hold back... As I understand if I install the current kernel linux-headers-4.9.0-12-amd64 with the linux-headers-amd64 linux-image-amd64 packages, I need to restart the VM in order to take effect. Can this be the issue why the vbguest provision process still want to install the older linux-headers-4.9.0-3-amd64 kernel update?

$vbguest_install = <<~HEREDOC_VBGUEST
	apt-get -y --force-yes update
	DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential linux-headers-amd64 linux-image-amd64 dkms
HEREDOC_VBGUEST

if opts[:vbguest] == true
    # VAGRANT_EXPERIMENTAL="typed_triggers" env var should be present!
    node.trigger.before :"VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions", type: :action do |trigger|
        trigger.info = "Trigger run before vagrant-vbguest install!"
        trigger.run_remote = {inline: $vbguest_install}
        node.vm.provision :reload
    end
else
    node.vbguest.auto_update = false
end

I tried to use vagrant-reload plugin, but the provision reload didn't triggered after installing build-essential linux-headers-amd64 linux-image-amd64 dkms.

I also want to ask is there any action to target vagrant-vbguest? So far I tried the following ones without luck:

VagrantVbguest::Installers::Debian
VagrantVbguest::Installers::Linux
vbguest

Only targeting VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions works and runs before checking the guest addition's version. As I understand this is one step before vagrant-vbguest provision process?

If anyone have some tips how to solve this issue using Vagrant triggers without writing custom classes, I'm all open.

@fnordfish This issue needs to be reopen because this effecting current dev environments which targeting legacy OS (like Stretch) in production. The currently hardcoded uname -r solution needs an alternative kernel update method behind a boolean to install build-essential linux-headers-amd64 linux-image-amd64 packages.

@fnordfish fnordfish removed the wontfix label Jun 18, 2020
@fnordfish fnordfish reopened this Jun 18, 2020
@shrimpwagon
Copy link

Yall..... my solution up top works best so far: #issuecomment-545391139

@thenewguy
Copy link

Observing issue with Windows 10 1909 and config.vm.box = "hashicorp/bionic64"

@jamieburchell
Copy link

jamieburchell commented Oct 20, 2020

This also appears to be an issue with the CentOS 8 boxes I used from here:

http://cloud.centos.org/centos/8/x86_64/images/CentOS-8-Vagrant-8.2.2004-20200611.2.x86_64.vagrant-virtualbox.box
https://app.vagrantup.com/centos/boxes/8

Error: Unable to find a match: kernel-devel-4.18.0-193.6.3.el8_2.x86_64
and
Error: Unable to find a match: kernel-devel-4.18.0-147.3.1.el8_1.x86_64

I was able to resolve by:

$ vagrant ssh
$ sudo dnf upgrade
$ sudo shutdown now
$ vagrant halt
$ vagrant up

@riege-burghardt
Copy link

For CentOS 8, please see: https://github.com/dotless-de/vagrant-vbguest#installer-specific-options-installer_options

Especially:
c.vbguest.installer_options = { allow_kernel_upgrade: true }

That fixed my problem by installing the latest kernel and performing a reboot of the Vagrant VM before continuing the provisioning.

@jpsecher
Copy link

For Ubuntu, it is linux-headers-generic linux-image-generic instead of linux-headers-amd64 linux-image-amd64.

@ijdoc
Copy link

ijdoc commented Jan 7, 2022

For CentOS 8, please see: https://github.com/dotless-de/vagrant-vbguest#installer-specific-options-installer_options

Especially: c.vbguest.installer_options = { allow_kernel_upgrade: true }

That fixed my problem by installing the latest kernel and performing a reboot of the Vagrant VM before continuing the provisioning.

This works for Ubuntu Focal (20.04) as well

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests