LoginSignup
7
7

More than 5 years have passed since last update.

vagrant up した時に共有フォルダのマウントでエラーが出る問題

Posted at

問題

大分前から vagrant up した時に共有フォルダのマウントに時間がかかり下記のエラーが出ていた。

$ vagrant up
(中略)
==> web: Mounting shared folders...
    web: /vagrant => /Users/hoge/path/to/dir/project
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したら接続はできるのでずっと放置していた。
が、ようやく色々と調べて解決した。

自分の環境

  • MacOS X 10.10.5 Yosemite
  • VirtualBox 5.0.2
  • Vagrant 1.7.4
  • Vagrant Box chef/centos-6.6

解決方法

まずはvagrantに接続しvboxのリビルドを試す。
以下はvagrant内でのコマンド操作。

$ sudo /etc/init.d/vboxadd setup
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-504.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  ]

Guest Additions の構築に失敗する。
メッセージ通り、 kernel-devel-2.6.32-504.el6.x86_64yum install してみる。

$ sudo yum install kernel-devel-2.6.32-504.el6.x86_64
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * epel: ftp.kddilabs.jp
 * extras: www.ftp.ne.jp
 * remi-safe: remi.kazukioishi.net
 * updates: www.ftp.ne.jp
パッケージ kernel-devel.2.6 は利用できません。
エラー: 何もしません

そんなものは存在しない!
仕方がないので、 kernel-devel-2.6.32-504.el6.x86_64 をキーワードにググり、web上のrpmパッケージを拾ってきてインストールする。

ググったら、ヒットした RPM Scientific Linux 6 kernel-devel 2.6.32 x86_64 rpm の中から適当なリンクのrpmパッケージをインストールする。

$ sudo yum install ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.6/x86_64/os/Packages/kernel-devel-2.6.32-504.el6.x86_64.rpm

インストール後にもう一度vboxのリビルドを行う。

$ 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 halt & vagrant up してもエラーが出ずにすぐに環境構築できるようになって解決した。

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