前回Discover Vagrant Boxes | Atlas by HashiCorpはすごい簡単ですよー、みたいな記事あげてたけど、実際にはdebianのbox落として立ち上げるときだけとても困ったバグを踏んだ。
以下にログを書くと
$ vagrant up (いろいろ省略) ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => /Users/kimikimi714/Documents/vagrant/debian-7.4 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
というわけでまたしても共有フォルダがマウントできなかった。3月30日にあげた記事とはまた全然違う原因だった。
この問題を解決したのは以下のリンク。
- Vagrant can't mount shared folder in VirtualBox 4.3.10 · Issue #3341 · mitchellh/vagrant · GitHub
- #12879 (Can't mount shared folders with guest additions 4.3.10 => Fixed in SVN) – Oracle VM VirtualBox
初めのリンクのタイトルを読むとvagrantに問題があるように書いてあるが実際にはVirtual Box 4.3.10が提供するGuest Additionsに問題がある。また2つ目の記事にはubuntuの仮想マシンだと共有フォルダがマウントできないって書いてあるけど、ubuntuはdebian系unixなので実際にはdebianでも起こる問題。
簡単に解決方法を書いておくと
- バグが修正されたGuest Additionsを
wget https://www.virtualbox.org/download/testcase/VBoxGuestAdditions_4.3.11-93070.iso
でダウンロードする。 - ホストマシンのGuest Additionsにダウンロードしたものを上書き。macなら
sudo cp VBoxGuestAdditions_4.3.11-93070.iso /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
でいける。 vagrant-vbguest
が入っているなら普通にvagrant up
かvagrant reload
で共有フォルダがマウントされる。
そのうちVirtual Boxのupdateがくるだろうから、それに合わせてこのバグも修正されると思う。
続きにはどうやってこの問題を解決できるリンクを探し当てたかの経緯を書いておく。
$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Box 'chef/debian-7.4' could not be found. Attempting to find and install... default: Box Provider: virtualbox default: Box Version: >= 0 ==> default: Loading metadata for box 'chef/debian-7.4' default: URL: https://vagrantcloud.com/chef/debian-7.4 ==> default: Adding box 'chef/debian-7.4' (v1.0.0) for provider: virtualbox default: Downloading: https://vagrantcloud.com/chef/debian-7.4/version/1/provider/virtualbox.box ==> default: Successfully added box 'chef/debian-7.4' (v1.0.0) for 'virtualbox'! ==> default: Importing base box 'chef/debian-7.4'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'chef/debian-7.4' is up to date... ==> default: Setting the name of the VM: debian-74_default_1396689831407_95814 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Error: Connection timeout. Retrying... ==> default: Machine booted and ready! GuestAdditions versions on your host (4.3.10) and guest (4.3.8) do not match. stdin: is not a tty Reading package lists... Building dependency tree... Reading state information... dkms is already the newest version. linux-headers-3.2.0-4-amd64 is already the newest version. linux-headers-3.2.0-4-amd64 set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso stdin: is not a tty mount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting read-only Installing Virtualbox Guest Additions 4.3.10 - guest version is 4.3.8 stdin: is not a tty Verifying archive integrity... All good. Uncompressing VirtualBox 4.3.10 Guest Additions for Linux............ VirtualBox Guest Additions installer Removing installed version 4.3.8 of VirtualBox Guest Additions... Copying additional installer modules ... Installing additional modules ... Removing existing VirtualBox DKMS kernel modules ...done. Removing existing VirtualBox non-DKMS kernel modules ...done. Building the VirtualBox Guest Additions kernel modules ...done. Doing non-kernel setup of the Guest Additions ...done. You should restart your guest to make sure the new modules are actually used Installing the Window System drivers Could not find the X.Org or XFree86 Window System, skipping. 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. stdin: is not a tty ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => /Users/kimikimi714/Documents/vagrant/debian-7.4 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
またvboxsf
がマウントできてないのかよー。
でもCentOSじゃないからyumではパッケージ管理してないし、そもそもGuest Additionsをインストールするのに必要なカーネルはlinux-headers-3.2.0-4-amd64 is already the newest version.
を見る限り既に存在しているようだ。
試しにゲストマシンにログインして手動でマウントをさせてみよう。
$ vagrant ssh Linux packer-debian-7 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Sun Mar 30 20:25:56 2014 from 10.0.2.2 vagrant@packer-debian-7:~$ sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` /vagrant /vagrant mount: Protocol error
ん?Protocol error
?
初めはmount: Protocol error
で検索して、VirtualBox(Ubuntu)で共有フォルダするときの注意。 - Rubellum fly lightとか出てきたけど、
Virtual Boxの「自動マウント」のチェックボックスは初めから外れていたから、これでは解決できなかった。ただ、このリンクに「Ubuntu」という言葉が入っていたので、もしかしてと思いvirtualbox debian vagrant mount
でググったら上記2つのリンクが出てきた。
$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'chef/debian-7.4'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'chef/debian-7.4' is up to date... ==> default: Setting the name of the VM: debian-74_default_1396692797263_9005 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Error: Connection timeout. Retrying... ==> default: Machine booted and ready! GuestAdditions versions on your host (4.3.10) and guest (4.3.8) do not match. stdin: is not a tty Reading package lists... Building dependency tree... Reading state information... dkms is already the newest version. linux-headers-3.2.0-4-amd64 is already the newest version. linux-headers-3.2.0-4-amd64 set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso stdin: is not a tty mount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting read-only Installing Virtualbox Guest Additions 4.3.11 - guest version is 4.3.8 stdin: is not a tty Verifying archive integrity... All good. Uncompressing VirtualBox 4.3.11 Guest Additions for Linux............ VirtualBox Guest Additions installer Removing installed version 4.3.8 of VirtualBox Guest Additions... Copying additional installer modules ... Installing additional modules ... Removing existing VirtualBox DKMS kernel modules ...done. Removing existing VirtualBox non-DKMS kernel modules ...done. Building the VirtualBox Guest Additions kernel modules ...done. Doing non-kernel setup of the Guest Additions ...done. You should restart your guest to make sure the new modules are actually used Installing the Window System drivers Could not find the X.Org or XFree86 Window System, skipping. An error occurred during installation of VirtualBox Guest Additions 4.3.11. Some functionality may not work as intended. In most cases it is OK that the "Window System drivers" installation failed. stdin: is not a tty ==> default: Checking for guest additions in VM... ==> default: Mounting shared folders... default: /vagrant => /Users/kimikimi714/Documents/vagrant/debian-7.4 kimikimi714@Kimie-no-MacBook-Air:~/Documents/vagrant/debian-7.4$ vagrant ssh Linux packer-debian-7 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Sun Mar 30 20:25:56 2014 from 10.0.2.2 vagrant@packer-debian-7:~$ cd /vagrant/ vagrant@packer-debian-7:/vagrant$ ls -la total 12 drwxr-xr-x 1 vagrant vagrant 136 Apr 5 09:05 . drwxr-xr-x 24 root root 4096 Apr 5 10:14 .. drwxr-xr-x 1 vagrant vagrant 102 Apr 5 09:05 .vagrant -rw-r--r-- 1 vagrant vagrant 4635 Apr 5 09:05 Vagrantfile vagrant@packer-debian-7:/vagrant$ touch aaa vagrant@packer-debian-7:/vagrant$ exit logout Connection to 127.0.0.1 closed. $ ls -la total 16 drwxr-xr-x 5 kimikimi714 group 170 4 5 19:15 . drwxr-xr-x 4 kimikimi714 group 136 4 5 18:03 .. drwxr-xr-x 3 kimikimi714 group 102 4 5 18:05 .vagrant -rw-r--r-- 1 kimikimi714 group 4635 4 5 18:05 Vagrantfile -rw-r--r-- 1 kimikimi714 group 0 4 5 19:15 aaa
ググり力高まってる。