Vagrantのguest additionのエラーをvagrant-vbquestプラグインで解消する

以前、vagrant boxを自前で作成するときに、以下のエラーが出ていた。

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:

stdin: is not a tty
mount: unknown filesystem type 'vboxsf'

これは、guest addtionがインストールされていないときなどが原因で、ホストOSとゲストOSのフォルダ共有ができないときに出力されるエラーだ。

ゲストにguest addtionを入れ直せば解決するのだが、入れ直すときには、他のパッケージが必要な場合や再コンパイルが必要になり、なかなか大変だ。そこで、vagrant-vbquestプラグインを使用したい。

dotless-de/vagrant-vbguest · GitHub

vagrant-vbguestはquest addtionsをインストールに必要なパッケージと共に、自動的にインストールしてくれるとても便利なプラグインだ。実際に使わない手はない。


$ vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.10.0)'!

そして、このままvagrant upしてみます。ログが長いの一部省略しています。

==> default: Machine booted and ready!
No installation found.
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  cpp-4.6 gcc-4.6 gcc-4.6-base linux-headers-3.2.0-4-common linux-kbuild-3.2
Suggested packages:
  gcc-4.6-locales gcc-4.6-multilib libmudflap0-4.6-dev gcc-4.6-doc libgcc1-dbg
  libgomp1-dbg libquadmath0-dbg libmudflap0-dbg binutils-gold
Recommended packages:
  linux-headers-686-pae linux-headers-amd64 linux-headers-generic
The following NEW packages will be installed:
  cpp-4.6 dkms gcc-4.6 gcc-4.6-base linux-headers-3.2.0-4-amd64
  linux-headers-3.2.0-4-common linux-kbuild-3.2


Processing triggers for man-db ...
Setting up gcc-4.6-base:amd64 (4.6.3-14) ...
Setting up cpp-4.6 (4.6.3-14) ...
Setting up dkms ( ...
Setting up gcc-4.6 (4.6.3-14) ...
Setting up linux-headers-3.2.0-4-common (3.2.68-1+deb7u2) ...
Setting up linux-kbuild-3.2 (3.2.17-1) ...
Setting up linux-headers-3.2.0-4-amd64 (3.2.68-1+deb7u2) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 3.2.0-4-amd64
Copy iso file /Applications/ 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.20 - guest version is 
stdin: is not a tty
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.20 Guest Additions for Linux............
VirtualBox Guest Additions installer
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.
Starting the VirtualBox Guest Additions ...done.
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.20. 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: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/xxx/deb


Chef活用ガイド コードではじめる構成管理 (アスキー書籍)

Chef活用ガイド コードではじめる構成管理 (アスキー書籍)