LoginSignup
30
31

More than 5 years have passed since last update.

vagrant up 時に shared folder の mount でエラーが発生する

Last updated at Posted at 2015-02-07

/sbin/mount.vboxsf: mounting failed with the error: No such device といった表示がされたので調査しました。

状況

今回のケースでは、こんな表示となっています。

==> default: Mounting shared folders...                                        
    default: /vagrant => /Users/****/projects/foo/middleman/VM
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

バージョンは以下の通り。

% VBoxManage --version
4.3.20r96996
% vagrant --version
Vagrant 1.7.1
% vagrant plugin list
vagrant-vbguest (0.10.0)

対応

vbox を破壊する

まず、以下の2つを行いました。

  1. chef/centos-6.5chef/centos-6.5-i386 へ変更。
  2. vagrant destroy で作り直す。

vbox を壊します。

% vagrant destroy

chef/centos-6.5chef/centos-6.5-i386 へ変更します。
これは、以前に chef/centos-6.5-i386 でないと、つまづくという別件を見かけたので試してみました。

Vagrantfile
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "chef/centos-6.5-i386"

その後、vagrant up でプロビジョニング終了。
エラーが出なくなりました。

もろもろ確認した感じでは、vagrant destroy したことが効いているようです。
(vbox の変更はおそらく関係が無い)

が、GuestAdditions のバージョンは未だずれているので、引き続き確認してみます。

% vagrant vbguest --status
GuestAdditions versions on your host (4.3.20) and guest (4.3.8) do not match.

vbox をリビルドする

エラーが表示される状態まで戻って、再開します。
vbox をリビルドするコマンドがあるので実行します。

% vagrant ssh
[vagrant@localhost ~]$ sudo /etc/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.8.1.el6.i686

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 ~]$ sudo yum install -y kernel-devel-2.6.32-504.8.1.el6.i686

gcc もないのでインストールします。

[vagrant@localhost ~]$ gcc --version
-bash: gcc: コマンドが見つかりません
[vagrant@localhost ~]$ sudo yum install -y gcc
Loaded plugins: fastestmirror
    :

以上で完了です。

vbox をリビルドすると all ok となりました。

[vagrant@localhost ~]$ sudo /etc/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 ~]$ exit
logout
Connection to 127.0.0.1 closed.

Host に戻って、GuestAdditions のバージョンを上げます。

% vagrant vbguest
GuestAdditions versions on your host (4.3.20) and guest (4.3.8) do not match.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
    :
% vagrant vbguest --status
GuestAdditions 4.3.20 running --- OK.

また vagrant reload でエラーが出ないことが確認できました。

まとめ

以下でひとまずの対応ができることが分かりました。

  • 必要なパッケージをインストールする
  • vbox をリビルドする

根本的な解決は、vbguest の対応待ちという感じなのですかね。

参考ソース

こちらを参考にさせて頂きました。

30
31
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
31