めもめも のーと

ハマったこととか、覚えたこととか

vagrant起動で"Failed to mount folders in Linux guest"のエラーが出た件

Windows7vagrant環境を作ってあったので久々に起動したら以下のエラーが出たので、その時の対処法をメモしておきます。

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

環境

Windows7(ホストOS)
CentOS6.6(ゲストOS)
VirtualBox

対応

コマンドプロンプトを開き、Vagrantfileがあるディレクトリまで移動して、下記のコマンドを実行。

(この時一番上のエラーが出てたけどVM自体は起動していたかもしれません。)

>vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.10.0)'!

vagrantを停止→起動

>vagrant halt
==> default: Attempting graceful shutdown of VM...

>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chef/centos-6.5' 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: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> 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: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions versions on your host (4.3.20) and guest (4.3.8) do not match.

・・・(何やらインストール)

Copy iso file C:\Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 4.3.20 - guest version is 4.3.8
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.20 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.8 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[  OK  ]
Building the shared folder support module[  OK  ]
Building the OpenGL support module[  OK  ]
Doing non-kernel setup of the Guest Additions[  OK  ]
Starting the VirtualBox 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.20. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/myhome/MyVagrant/centos
==> default: Machine already provisioned. Run `vagrant provision` or use the `--
provision`
==> default: to force provisioning. Provisioners marked to run always will still
 run.

うまく起動できました!

補足

同じエラーの解消方法を紹介しているサイト記事で /etc/init.d/vboxadd setup でvboxをリビルドする、というものがいくつかありましたが、自分の環境ではこれでは直りませんでした。。

ちなみにGuest Additionとは、ホストOSとゲストOS間でマウスカーソルのシームレスに移動させたり、ホストOSとの時刻同期、ホストとゲストの共有フォルダ作成、などをサポートしてくれるモジュールのようです。