19
18

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 で Guest Additions インストールに失敗し、/vagrant のマウントができなくなったので対処

Posted at

Ansible 環境を求めて試行錯誤中
http://qiita.com/progre/items/ccc2d8c2ec7ae8a4ed61
初見でうまくいかなかった所のメモ

調査不足というか Vagrant まわりの知識不足で、自分の環境固有かもしれないので
プルリクとかは保留…

原因(多分)と結論

既に古い(適切な?)バージョンの Guest Additions が入っている場合は、
vagrant-vbguest をオフにしておかないと Guest Additions 最新版に更新されて環境がおかしくなるもよう

Vagrantfile に 1 行記述するだけでよい。

問題発生と調査の簡単な流れ

  1. vagrant up すると、/vagrant のマウントができてない
    1. ログを調べると「Guest Additions インストールに失敗してる」と言われる
    2. しかし、vbguest による Guest Additions は成功し、最新版が入ってる
    3. ログをもっと読むと、なんだか Guest 過去バージョンがどうのと書いてある
  2. エラーメッセージでググって出てきた対処法 「ゲスト環境から、Guest Additions のリビルド」
    • 今回は無関係だった
    • 逆に、バージョン不一致で Guest Additions を新しくする必要があればこちらの方法で合致するかも?
  3. vbguest plugin を一時的にオフにして vagrant up
    1. どうやら成功。

ログなど

マウント失敗した時の vagrant up ログ

mount: warning: /mnt seems to be mounted read-only.
Installing Virtualbox Guest Additions 4.3.10 - guest version is 4.2.0
...
An error occurred during installation of VirtualBox Guest Additions 4.3.10. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
...
==> default: Mounting shared folders...
default: /vagrant => C:/Users/heignamerican/vagrant/template-vagrant
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`,dmode=775,fmode=664 vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant`,dmode=775,fmode=664 vagrant /vagrant

マウント失敗した時でも、VirtualBox Guest Additions の最新は入っている

$ vagrant ssh

vagrant@precise64:~$ sudo VBoxControl version
Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 4.3.10
(C) 2008-2014 Oracle Corporation
All rights reserved.

4.3.10r93012

vbguest plugin をオフ

config.vbguest.auto_update = false を追加

Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
  
  config.vbguest.auto_update = false
  
  config.vm.network :public_network
  config.vm.provision "shell", :path => "provision.sh"
  config.vm.synced_folder ".", "/vagrant", :mount_options => ['dmode=775', 'fmode=664']
end

成功時のログ

==> default: Mounting shared folders...
default: /vagrant => C:/Users/heignamerican/vagrant/template-vagrant
...
==> default: PLAY [127.0.0.1] **************************************************************
==> default:
==> default: GATHERING FACTS ***************************************************************
==> default: ok: [127.0.0.1]
==> default:
==> default: PLAY RECAP ********************************************************************
==> default: 127.0.0.1 : ok=1 changed=0 unreachable=0
failed=0

成功時の VirtualBox Guest Additions

$ vagrant ssh

vagrant@precise64:~$ sudo VBoxControl version
Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 4.2.0
(C) 2008-2012 Oracle Corporation
All rights reserved.

4.2.0r80737

マウント

vagrant@precise64:~$ ls /vagrant
ansible provision.sh Vagrantfile

19
18
6

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?