VirtualBox guest additionsがインストールできない場合(CentOS, Fedora)

LINEで送る
Pocket

CentOS RHEL Fedora で Oracle VM VirtualBox Guest Additions tools をインストールする方法を紹介します。
Oracle VM VirtualBox を使用する上で、Guest Additions tools をインストールする
必用はありませんが、インストールすると、
・マウスカーソルのシームレスな移動
・高解像度のデスクトップ画面が使用可能
・クリップボードの共有
・ハードウェア3Dアクセラレーションのサポート
などの機能が追加できます。

しかし、インストールを試みようとしても、以下のようにエラーが出力されてインストール出来ない場合があります。
この問題には、主に2つの問題があります。
・Guest Additions をインストールする為のパッケージが不足している。
・起動中の kernel と kernel のヘッダー(kernel-headers)、ディベロッパー(kernel-devel)のバージョンが異なる
の2つが主な原因です。この2点を解消してあべれば Guest Additions をインストールする事が出来ます。

エラー例

# ./VBoxLinuxAdditions.run_
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.22 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Copying additional installer modules ...
./install.sh: 行 365: bzip2: コマンドが見つかりません
tar: これは tar アーカイブではないようです
tar: 前のエラーにより失敗ステータスで終了します
./install.sh: 行 378: bzip2: コマンドが見つかりません
tar: これは tar アーカイブではないようです
tar: 前のエラーにより失敗ステータスで終了します


# ./VBoxLinuxAdditions.run_
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.22 Guest Additions for Linux...........
VirtualBox Guest Additions installer
You appear to have a version of the VirtualBox Guest Additions
on your system which was installed from a different source or using a
different type of installer.  If you installed it from a package from your
Linux distribution or if it is a default part of the system then we strongly
recommend that you cancel this installation and remove it properly before
installing this version.  If this is simply an older or a damaged
installation you may safely proceed.

Do you wish to continue anyway? [yes or no]
yes
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Starting the VirtualBox Guest Additions.
Failed to set up service vboxadd, please check the log file
/var/log/VBoxGuestAdditions.log for details.

Redirecting to /bin/systemctl stop  vboxadd-x11.service
Failed to stop vboxadd-x11.service: Unit vboxadd-x11.service not loaded.
Redirecting to /bin/systemctl stop  vboxvfs.service
Failed to stop vboxvfs.service: Unit vboxvfs.service not loaded.
Redirecting to /bin/systemctl stop  vboxadd-timesync.service
Failed to stop vboxadd-timesync.service: Unit vboxadd-timesync.service not loaded.
Redirecting to /bin/systemctl stop  vboxadd-service.service
Failed to stop vboxadd-service.service: Unit vboxadd-service.service not loaded.
Redirecting to /bin/systemctl stop  vboxadd.service
Failed to stop vboxadd.service: Unit vboxadd.service not loaded.
vboxadd.sh: failed: Configuration file /var/lib/VBoxGuestAdditions/config not found.
vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: modprobe vboxguest failed.

目次

パッケージのアップデート

起動中の kernel と kernel のヘッダーのバージョンを合わせる為に、パッケージのアップデートを行います。

// Fedora 27/26/25/24/23/22 の場合
# dnf -y update
// CentOS/RHEL 7/6/5 Fedora 21/20/19/18/17/16/15/14/13/12 の場合
# yum -y update
// kernel パッケージだけアップデートしたい場合
// Fedora 27/26/25/24/23/22 の場合
# dnf -y update kernel*
// CentOS/RHEL 7/6/5 Fedora 21/20/19/18/17/16/15/14/13/12 の場合
# yum -y update kernel*
//アップデートしても、再起動しないと最新のkernelで起動している事にならないので必ず再起動します。
# reboot
// 再起動しないと以下のようなエラーがメッセージが表示されます。これは、起動中のカーネルとVirtualBox のカーネルモジュールをコンパイルする為に必要な kernel の開発パッケージのバージョンが異なるために発生します。
# cat /var/log/VBoxGuestAdditions.log 
Created symlink /etc/systemd/system/multi-user.target.wants/vboxadd-x11.service → /usr/lib/systemd/system/vboxadd-x11.service.
Created symlink /etc/systemd/system/multi-user.target.wants/vboxadd.service → /usr/lib/systemd/system/vboxadd.service.
vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: modprobe vboxguest failed.
Created symlink /etc/systemd/system/multi-user.target.wants/vboxadd-service.service → /usr/lib/systemd/system/vboxadd-service.service.
# cat /var/log/vboxadd-install.log 
/tmp/vbox.0/Makefile.include.header:112: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  中止.
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

不足しているパッケージのインストール

不足しているパッケージをインストールします。

// Fedora 27/26/25/24/23/22 の場合
# dnf install gcc kernel-devel kernel-headers dkms make bzip2 perl

// CentOS/RHEL 7/6/5 Fedora 21/20/19/18/17/16/15/14/13/12 の場合
# yum install gcc kernel-devel kernel-headers dkms make bzip2 perl

guest additions CDイメージの挿入

[デバイス]メニュより ->[guest additions CDイメージの挿入]を選択します。
これで システム上に /dev/cdrom にCDがセットされます。

インストールスクリプト実行

インストールスクリプトを実行します。

// /media/GuestAdditions ディレクトリを作成
# mkdir /media/GuestAdditions
// マウントします。
# mount -r /dev/cdrom /media/GuestAdditions
# cd /media/GuestAdditions
// スクリプトを実行します。
# ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.22 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Removing installed version 5.1.22 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Starting the VirtualBox Guest Additions.
// インストール成功!
# reboot
LINEで送る
Pocket

  • このエントリーをはてなブックマークに追加

アマゾン

LINEで送る
Pocket

記事が面白かった。為になったと思ったら。下記リンクより商品を購入頂くと筆者は喜び記事を更新致します。


LINEで送る
Pocket

コメントを残す

*

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください