vagrant upすると、以下のように共有フォルダがマウントできなくてエラーになりました。

==> default: Mounting shared folders...
    default: /vagrant => .../vagrant-centos7-php
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

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

ターミナルの出力を遡ると、Guest Additions moduleのビルドに失敗してました。

Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 4.3.28 - guest version is 5.0.6
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.28 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.28 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
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  ]
Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 4.3.28. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.


[vagrant@localhost ~]$ cat /var/log/vboxadd-install.log
/tmp/vbox.0/Makefile.include.header:115: *** Error: unable to find the include directory for your current Linux kernel. Specify KERN_INCL=<directory> and run Make again.  Stop.
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.



[vagrant@localhost ~]$ sudo yum -y update kernel
[vagrant@localhost ~]$ sudo yum -y install kernel-devel kernel-headers dkms gcc gcc-c++

そして、仮想マシンを停止してvagrant up。これで後はvbguestプラグインが面倒を見てくれて、正常に動作できるようになりました。


$ vagrant plugin install vagrant-vbguest



Date: 2016/03/11

Tags: linux, vagrant, virtualbox