vagrantで共有ディレクトリがマウントされなくなった

投稿者: | 2016年8月31日

vagrant起動時にエラーが発生し、共有ディレクトリがマウントされなくなりました。
発生したエラーは次のようなものになります。

C:\vagrant\centos7>vagrant halt
==> default: Attempting graceful shutdown of VM...
$ vagrant up
  Bringing machine 'default' up with 'virtualbox' provider...
  ==> default: Clearing any previously set forwarded ports...
  ==> 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: Warning: Connection timeout. Retrying...
      default: Warning: Remote connection disconnect. Retrying...
  ==> default: Machine booted and ready!
  ==> default: Checking for guest additions in VM...
  ==> default: Mounting shared folders...
      default: /vagrant => C:/vagrant/centos7
  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

メッセージはそのままデバイスのマウントに失敗しましたと出ています。
エラーメッセージを元に情報を集めてみたところ理由が判明しました。
どうやらカーネルモジュールをアップデートした場合、GuestAdditionsを入れなおす必要があるようです。
先日、vagrantのcentoOSにvagrantを入れる際に「yum update」を実行しました。
このときにカーネルモジュールがアップデートしてしまったようです。
カーネルモジュールの入れなおしはvagrantのプラグインを使用すれば簡単にできるようです。
大元のホストに戻り、次のvagrantコマンドを実行します。

vagrant plugin install vagrant-vbguest

この後にvagrantを起動します。
すると自動でGuestAdditionsを入れなおしてくれます。

$ vagrant up
  Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
  ==> 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: Warning: Connection timeout. Retrying...
      default: Warning: Remote connection disconnect. Retrying...
  ==> default: Machine booted and ready!
  [default] GuestAdditions versions on your host (4.3.22) and guest (4.3.30) do not match.
  Loaded plugins: fastestmirror
  Loading mirror speeds from cached hostfile
   * base: ftp.riken.jp
   * epel: ftp.riken.jp
   * extras: ftp.riken.jp
   * updates: ftp.jaist.ac.jp
  Package kernel-devel-3.10.0-327.22.2.el7.x86_64 already installed and latest version
  Package gcc-4.8.5-4.el7.x86_64 already installed and latest version
  Package binutils-2.23.52.0.1-55.el7.x86_64 already installed and latest version
  Package 1:make-3.82-21.el7.x86_64 already installed and latest version
  Package 4:perl-5.16.3-286.el7.x86_64 already installed and latest version
  Package bzip2-1.0.6-13.el7.x86_64 already installed and latest version
  Nothing to do
  Copy iso file C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
  mount: /dev/loop0 is write-protected, mounting read-only
  Installing Virtualbox Guest Additions 4.3.22 - guest version is 4.3.30
  Verifying archive integrity... All good.
  Uncompressing VirtualBox 4.3.22 Guest Additions for Linux............
  VirtualBox Guest Additions installer
  Removing installed version 4.3.30 of VirtualBox Guest Additions...
  Copying additional installer modules ...
  Installing additional modules ...
  Removing existing VirtualBox DKMS kernel modules[  OK  ]
  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[FAILED]
  (Look at /var/log/vboxadd-install.log to find out what went wrong)
  Doing non-kernel setup of the Guest Additions[  OK  ]
  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.22. Some functionality may not work as intended.
  In most cases it is OK that the "Window System drivers" installation failed.
  ==> default: Checking for guest additions in VM...
  ==> default: Mounting shared folders...
      default: /vagrant => C:/vagrant/centos7
  ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
  ==> default: to force provisioning. Provisioners marked to run always will still run.

この後にバーチャルホストにログインし、共有ディレクトリがマウントされていることが確認できました。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA