VirtualBoxの/vagrantがマウントに失敗

VagrantでVM起動時に/vagrantがマウントできないというメッセージが出るようになってしまった。

■ 環境

  • Mac OSX (10.9.5)
  • Vagrant 1.7.2

■ 現状

vagrantでの起動時のログは下記の通り。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chef/centos-6.6' is up to date...
==> default: Clearing any previously set forwarded ports...
==> 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: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2200 (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:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Checking for host entries
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/withsin/tmp/docker
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

$
$ vagrant ssh
[vagrant@localhost ~]$ sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
/sbin/mount.vboxsf: mounting failed with the error: No such device
$

VM自体にログインは可能であるし、ファイルの共有にも使用していないので即問題になるわけではないのだが、ちゃんと対処しておく。

■ VirtualBox Guest Additions

Kernelのアップデートをした場合にVagrantのGuestAdditionsを入れ直す必要がある?との情報もある。確かに下記コマンドを実行したのでアップデートされたような気もする。

[vagrant@guest ~]$ sudo yum update

Guest Additionsを入れ直すにはvagrant-vbguestプラグインが便利だという事なのでインストールした。

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

現状を確認する。以降は全てVagrantfileがあるディレクトリにて実施。

$ vagrant vbguest --status
GuestAdditions seems to be installed (4.3.20) correctly, but not running.
$

実行してみる。

$ vagrant vbguest
GuestAdditions seems to be installed (4.3.20) correctly, but not running.
Starting the VirtualBox Guest Additions [FAILED]
(modprobe vboxguest failed)
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
The gcc utility was not found. If the following module compilation fails then
this could be the reason and you should try installing it.

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-504.23.4.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  ]
Guest Additions got installed. However, they seem not be loaded correctly. Please restart the box running `vagrant reload default`
$

なんか失敗しているようなだ。。メッセージの通り下記コマンドも実行してみた。

$ vagrant reload default

VMを再起動したタイミングでやはり/vagrantはマウントされなかった。違う問題のようである。

■ /sbin/mount.vboxsf symlink

VirtualBoxの共有フォルダのマウントに失敗する – Qiita
http://qiita.com/amagitakayosi/items/07ff50afac1cd6f62c1f

どうやらこちらの記事にあるsymlinkの方なのかも?試してみる。

$ vagrant ssh
Last login: Fri Jul  10 19:08:15 2015 from 10.0.2.2
[vagrant@localhost ~]$ ls -l /sbin/mount.vboxsf
lrwxrwxrwx. 1 root root 42  7月  7 02:22 2015 /sbin/mount.vboxsf -> /usr/lib64/VBoxGuestAdditions/mount.vboxsf
[vagrant@localhost ~]$
[vagrant@localhost ~]$ ls -l /usr/lib/VBoxGuestAdditions/mount.vboxsf
-rwxr-xr-x. 1 root root 15544 11月 21 13:56 2014 /usr/lib/VBoxGuestAdditions/mount.vboxsf
[vagrant@localhost ~]$ sudo rm /sbin/mount.vboxsf
[vagrant@localhost ~]$ sudo ln -s /usr/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
[vagrant@localhost ~]$

VMを再起動する。

$ vagrant reload

しかし、マウントは正常にされない。

■ vboxadd setup

続いて参照させてもらったのはこっち。

vagrantでmountエラーの解決方法 – Qiita
http://qiita.com/osamu1203/items/10e19c74c912d303ca0b

実際に試してみる。

[vagrant@localhost ~]$ sudo /etc/rc.d/init.d/vboxadd setup
Removing existing VirtualBox non-DKMS kernel modules     [  OK  ]
Building the VirtualBox Guest Additions kernel modules
The gcc utility was not found. If the following module compilation fails then
this could be the reason and you should try installing it.

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-504.23.4.el6.x86_64

Building the main Guest Additions module                 [失敗]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions            [  OK  ]
[vagrant@localhost ~]$

先程も出ていたのだがkernel-develもインストールしなければダメなようだ。また/var/log/vboxadd-install.logを確認したところ、gccコマンドも入っていなかった。確かに開発ツールを入れてはいなかった。

$ sudo yum install kernel-devel gcc

これで再度実行する。

[vagrant@localhost ~]$ sudo /etc/rc.d/init.d/vboxadd setup
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  ]
[vagrant@localhost ~]$

vboxのリビルドが正常にできたようなので再起動。

$ vagrant reload

マウントは正常にされたようだ。

今回行ったのは下記。

  1. vagrant-vbguestプラグインでGuestAdditionsを再インストール
  2. /sbin/mount.vboxsfのsymlink再作成
  3. vboxadd setupでリビルド

一番の原因はkernelをupdateした際に、同versionのkernel-develを入れる事であったような気もする。1点目でちゃんと対処して確認していれば以降の2つは実施しなくても解決できたかもしれない。次回発生した際には1点目でkernel-develをアップデートして確認してみる事にする。

以上。

■ 関連

コメントを残す

メールアドレスが公開されることはありません。

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください