/ vgrant

Vagrant Guest Additions 安装或更新失败的处理方法

如果你使用Vagrant的时候provider用的是virtual box 可能你会遇到下面两个比较头疼的问题。

安装时示错误

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 workspace /workspace

The error output from the command was:

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

处理方法

vagrant ssh
yum -y update kernel
yum -y install kernel-devel kernel-headers dkms gcc gcc-c++

重启vagrant

vagrant reload

更新vbguest时提示错误:do not match

$ vagrant vbguest --status
GuestAdditions versions on your host (5.0.26) and guest (5.0.12) do not match.
$ vagrant plugin install vagrant-vbguest
Installed the plugin 'vagrant-vbguest (0.12.0)'!
$ vagrant vbguest
[default] GuestAdditions versions on your host (5.0.26) and guest (5.0.12) do not match.
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
No package kernel-devel-2.6.32-573.el6.x86_64 available.
Package gcc-4.4.7-17.el6.x86_64 already installed and latest version
Package binutils-2.20.51.0.2-5.44.el6.x86_64 already installed and latest version
Package 1:make-3.81-23.el6.x86_64 already installed and latest version
Package 4:perl-5.10.1-141.el6_7.1.x86_64 already installed and latest version
Package bzip2-1.0.5-7.el6_0.x86_64 already installed and latest version
Nothing to do
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 5.0.26 - guest version is 5.0.12
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.26 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.26 of VirtualBox Guest Additions...
Stopping VirtualBox Additions [  OK  ]
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-2.6.32-573.el6.x86_64

Building the main Guest Additions module[FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions[  OK  ]
$ vagrant vbguest --status
[default] GuestAdditions versions on your host (5.0.26) and guest (5.0.12) do not match.

解决方法

手动安装错误日志里提示的kernel

The missing package can be probably installed with
yum install kernel-devel-2.6.32-573.el6.x86_64

yum install ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.6/x86_64/updates/security/kernel-devel-2.6.32-573.el6.x86_64.rpm

参考资料