Vagrant error "Failed to mount folders in Linux guest" after halt or reload
It turns out, upgrading the Linux kernel will cause the Virtual Box Guest Additions to stop working until they are rebuilt by running the following command in the VM
sudo /etc/init.d/vboxadd setup
I had upgraded the kernel without thinking about it when I ran yum update
(similar to apt-get upgrade
) to get updates to other software.
Alternatively, if you install the dkms
package as described here, then the kernel module should be automatically updated when the kernel is updated.
To fix this issue virtual box addition has to be installed. For example, I use Centos 7. Firstly download centos 7 minimal and then install guest addition, please see all steps below
Download centos 7
vagrant init centos/7
vagrant up
vagrant ssh
Install Guest addition for virtual box
yum update
reboot
vagrant ssh
yum update kernel
reboot
vagrant ssh
yum groupinstall "Development tools"
yum install kernel-devel
yum install wget
wget http://download.virtualbox.org/virtualbox/5.0.2/VBoxGuestAdditions_5.0.2.iso
sudo mkdir /media/VBoxGuestAdditions
sudo mount -o loop,ro VBoxGuestAdditions_5.0.2.iso /media/VBoxGuestAdditions
sudo sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.runrm VBoxGuestAdditions_5.0.2.iso
sudo umount /media/VBoxGuestAdditions
sudo rmdir /media/VBoxGuestAdditions
sudo /etc/init.d/vboxadd setup
sudo chkconfig --add vboxadd
sudo chkconfig vboxadd on
exit
Package new box
vagrant package --base my-virtual-machine
Right after I got the same error I did this:
$ vagrant ssh$ sudo apt-get update$ exit
then installed vagrant-vbguest
$ vagrant plugin install vagrant-vbguest
then
$ vagrant halt$ vagrant up
and it worked!
Looking at the logs it seems that vagrant-vbguest did some cleanup in terms of vbguest additions on the guest (the VM).
[default] GuestAdditions versions on your host (4.3.38) and guest (4.3.10) do not match. * Stopping VirtualBox Additions ...done.rmmod: ERROR: Module vboxsf is not currently loadedrmmod: ERROR: Module vboxguest is not currently loadedReading package lists...Building dependency tree...Reading state information...The following packages will be REMOVED: virtualbox-guest-dkms* virtualbox-guest-utils* virtualbox-guest-x11*0 upgraded, 0 newly installed, 3 to remove and 12 not upgraded.After this operation, 12.1 MB disk space will be freed.(Reading database ... 113238 files and directories currently installed.)Removing virtualbox-guest-dkms (4.3.10-dfsg-1ubuntu5) ...Error! Could not locate dkms.conf file.File: does not exist.Removing virtualbox-guest-x11 (4.3.10-dfsg-1ubuntu5) ...Purging configuration files for virtualbox-guest-x11 (4.3.10-dfsg-1ubuntu5) ...Removing virtualbox-guest-utils (4.3.10-dfsg-1ubuntu5) ...Purging configuration files for virtualbox-guest-utils (4.3.10-dfsg-1ubuntu5) ...Processing triggers for man-db (2.6.7.1-1ubuntu1) ...Processing triggers for libc-bin (2.19-0ubuntu6.9) ...Reading package lists...Building dependency tree...Reading state information...dkms is already the newest version.linux-headers-3.13.0-91-generic is already the newest version.0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.isomount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting read-onlyInstalling Virtualbox Guest Additions 4.3.38 - guest version is 4.3.10Verifying archive integrity... All good.Uncompressing VirtualBox 4.3.38 Guest Additions for Linux............VirtualBox Guest Additions installerCopying additional installer modules ...Installing additional modules ...Removing existing VirtualBox DKMS kernel modules ...done.Removing existing VirtualBox non-DKMS kernel modules ...done.Building the VirtualBox Guest Additions kernel modules ...done.Doing non-kernel setup of the Guest Additions ...done.Starting the VirtualBox Guest Additions ...done.
P.S. I'm on OS X using the following software versions:
$ vagrant plugin listsolve (0.8.2) - Version Constraint: 0.8.2vagrant-berkshelf (4.1.0)vagrant-hostmanager (1.5.0) - Version Constraint: 1.5.0vagrant-hostsupdater (1.0.2)vagrant-omnibus (1.3.1) - Version Constraint: 1.3.1vagrant-proxyconf (1.2.0) - Version Constraint: 1.2.0vagrant-share (1.1.5, system)vagrant-vbguest (0.12.0)$ VBoxManage --version4.3.38r106717$ vagrant --versionVagrant 1.8.4
Hope this helps.