酒と開発の日々

飲酒大好き駆け出しエンジニアのブログ

CentOS8のVagrantイメージではすんなり共有ディレクトリが使えなかったという話

みなさんおはこんばんにちは。ぐーどらです。昨日突然の腹痛と頭痛と熱により、本日突然な休みをゲットしてしまい、せっかくだからReactでHello Worldしてやろう!と思い立ったぐーどらです。休め

modprobe vboxguest failed

さて、CentOS8がリリースされてから随分日が経ちましたが、しっかり情報はゲットしていました。折角なんで気分新しく、新品の仮想マシン上でコーディングしたいなあという欲望に駆られ、CentOS8のイメージを使ったVagrantマシンの作成を始めました。そこで出てくる下記のエラー。

VirtualBox Guest Additions: Look at /var/log/vboxadd-setup.log to find out what
went wrong
modprobe vboxguest failed
The log file /var/log/vboxadd-setup.log may contain further information.
An error occurred during installation of VirtualBox Guest Additions 6.0.12. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
Redirecting to /bin/systemctl start vboxadd.service
Job for vboxadd.service failed because the control process exited with error code.
See "systemctl status vboxadd.service" and "journalctl -xe" for details.

ほう…どうやらGuest Additionsが機能していない模様…仮想マシンで共有ディレクトリが使えなくなるのは痛すぎるので、早速エラーに書かれているvboxadd-setup.logを確認します。

$ cat /var/log/vboxadd-setup.log
Building the main Guest Additions 6.0.12 module for kernel 4.18.0-80.el8.x86_64.
Error building the module.  Build output follows.
make V=1 CONFIG_MODULE_SIG= -C /lib/modules/4.18.0-80.el8.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j1 modules
Makefile:958: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel".  Stop.
make: *** [/tmp/vbox.0/Makefile-footer.gmk:111: vboxguest] Error 2
Could not find the X.Org or XFree86 Window System, skipping.
modprobe vboxguest failed

ふむふむ。どうやら前提ライブラリがなにか足りていないようですね。というわけで、please install 以下にかかれているライブラリのインストールを試みます。結局CentOS8ではelfutils-libelf-develのみインストールが可能でした。

インストール後にvagrant reloadをすると、[default] No Virtualbox Guest Additions installation found.が出ましたが、正常に起動します。それ以降は正常に起動がおこなえるようになります。

まとめ

CentOS8のVagrantイメージでvbguestを使いたいときはdnf install elfutils-libelf-devel