14
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Vagrant]共有フォルダのマウントに失敗

Last updated at Posted at 2016-01-20

vagrant up時の共有フォルダマウントで以下のエラーが出てマウントに失敗する場合がありました

==> default: Mounting shared folders...
default: /vagrant => {ホストOSの共有フォルダ}
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

  • 仮想マシンは起動出来ている
  • ホスト側の共有フォルダにはファイル等は残っている状態

解決法

以下の2つの記事を参考にさせて頂きました

VirtualBoxの/vagrantがマウントに失敗
http://tech.withsin.net/2015/07/10/virtualbox-vagrant-mount-fail/

[Sy] 【解決した】Vagrantでvagrant-vbguestを使ってたら共有フォルダのマウントに失敗する
http://www.utano.jp/entry/2014/11/vagrant_guest_additions_update_error


Guest Additionsの再インストール

$ vagrant plugin install vagrant-vbguest

ゲストOSを再起動

$ vagrant reload
    失敗

シンボリックリンクを貼り直してみる

$ ls -l /sbin/mount.vboxsf
    /sbin/mount.vboxsf -> /usr/lib64/VBoxGuestAdditions/mount.vboxsf

$ ls -l /usr/lib/VBoxGuestAdditions/mount.vboxsf
    /usr/lib/VBoxGuestAdditions/mount.vboxsf

$ sudo rm /sbin/mount.vboxsf
$ sudo ln -s /usr/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf

ゲストOSを再起動

$ vagrant reload
    失敗

カーネルを再インストール

The missing package can be probably installed with
yum install kernel-devel-2.6.32-573.12.1.el6.x86_64

Building the main Guest Additions module[失敗]

kernel-devel-2.6.32-573.12.1.el6.x86_64をインストール出来ないと言われていたので
ネット上からダウンロード出来るURLを探して来ました。

ゲストOSで次のコマンドを実行

sudo yum install ftp://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/6.7/x86_64/updates/security/kernel-devel-2.6.32-573.12.1.el6.x86_64.rpm

インストールされたか確認

$ ls /usr/src/kernels/
    2.6.32-573.12.1.el6.x86_64

Guest Additionsを再ビルド

$ sudo /etc/init.d/vboxadd setup

ゲストOSを再起動

$ vagrant reload

default: /vagrant => {ホストOSの共有フォルダ}
==> default: Machine already provisioned. Run vagrant provision or use the --provision
==> default: flag to force provisioning. Provisioners marked to run always will >still run.

無事マウント出来ていることを確認

14
15
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?