【解決方法】Vagrantを起動した際に発生するmodprobe vboxguest failedエラーの対処

VirtualBoxVagrantCentOS
【解決方法】Vagrantを起動した際に発生するmodprobe vboxguest failedエラーの対処
Memo
この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

以前に作成したVagrantのboxから新しくVagrantのインスタンスを起動した際に
modprobe vboxguest failedエラーが発生したため解決手順をメモしました。

環境

  • Vagrant 2.2.10
  • virtualbox 6.1.16 r140961

発生したエラー

modprobe vboxguest failedのエラーが発生しています。

ホストOS(Mac)
$ vagrant up // 中略 The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! /usr/sbin/rcvboxadd setup Stdout from the command: VirtualBox Guest Additions: Starting. VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: To build modules for other installed kernels, run VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version> VirtualBox Guest Additions: or VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Kernel headers not found for target kernel 3.10.0-693.21.1.el7.x86_64. Please install them and execute /sbin/rcvboxadd setup Stderr from the command: modprobe vboxguest failed The log file /var/log/vboxadd-setup.log may contain further information.

ゲストOS(Vagrant)に入って確認

vagrantへログインします。

ホストOS(Mac)
$ vagrant ssh

直接コマンドを打って確認します。

ゲストOS(Vagrant)
$ modprobe vboxguest FATAL: Module vboxguest not found.

モジュールが見つからないエラーが出ました。

依存パッケージのインストールして解決

依存パッケージのインストールで治りました。

カーネルのアップデートを実施

yum updateでカーネルのアップデートをします。

ゲストOS(Vagrant)
$ sudo yum -y update kernel

必要パッケージのインストール

yum installで必要パッケージのインストール

ゲストOS(Vagrant)
$ sudo yum -y install kernel-devel kernel-headers dkms gcc gcc-c++

Vagrantの再リロード実施で解決

ゲストOSからログアウト

exitコマンドでゲストOSからログアウトします。

ゲストOS(Vagrant)
$ exit;

Vagrantを再リロード

vagrant reloadコマンドでvagrantをリロードします。

ホストOS(Mac)
$ vagrant reload ==> default: Attempting graceful shutdown of VM... ==> 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: Adapter 2: hostonly ==> default: You are trying to forward to privileged ports (ports <= 1024). Most ==> default: operating systems restrict this to only privileged process (typically ==> default: processes running as an administrative user). This is a warning in case ==> default: the port forwarding doesn't work. If any problems occur, please try a ==> default: port higher than 1024. ==> default: Forwarding ports... default: 80 (guest) => 80 (host) (adapter 1) default: 443 (guest) => 443 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> 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: Machine booted and ready! [default] GuestAdditions seems to be installed (6.1.16) correctly, but not running. Redirecting to /bin/systemctl start vboxadd.service Redirecting to /bin/systemctl start vboxadd-service.service VirtualBox Guest Additions: Starting. VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: To build modules for other installed kernels, run VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version> VirtualBox Guest Additions: or VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Building the modules for kernel 3.10.0-1160.25.1.el7.x86_64. VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted Restarting VM to apply changes... ==> default: Attempting graceful shutdown of VM... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... default: The guest additions on this VM do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared folders from working properly. If you see default: shared folder errors, please make sure the guest additions within the default: virtual machine match the version of VirtualBox you have installed on default: your host and reload your VM. default: default: Guest Additions Version: 4.3.20 default: VirtualBox Version: 6.1 ==> default: Configuring and enabling network interfaces... ==> default: Exporting NFS shared folders... ==> default: Preparing to edit /etc/exports. Administrator privileges will be required... ==> default: Mounting NFS shared folders... ==> default: Mounting shared folders... default: /vagrant => /Users/XXXXX/workspace/vagrant

無事起動することができました。

終わりに

最後までご覧いただきありがとうございます。
この記事では【解決方法】Vagrantを起動した際に発生するmodprobe vboxguest failedエラーの対処について紹介させていただきました。

これからも皆様の開発に役立つ情報を提供していきたいと考えています。
今後ともよろしくお願いいたします。