4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VirtualBox 4.3.12 の CentOS7 に Guest Additions をインストール

Posted at

謝辞

ありがたき先人たちに御礼が言いたいです。感謝。

参考サイト
http://punio.org/blog/201408041942VVAW.html
https://blog.kuma-chang.com/archives/337#i-3

いきさつ

Linux のカーネル系を一気に update しまくったら、VirtualBox の共有フォルダがマウントできなくなった。
どうもカーネルモジュールを更新した場合、Guest Additions を再度インストールする必要があるみたい。

なので、Guest Additions をインストール。

[root@centos ~]# mount -r /dev/cdrom /mnt/cdrom
[root@centos ~]# /mnt/cdrom/VBoxLinuxAdditions.run 
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.12 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.12 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                   [失敗]
(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.

あれ?

エラーが発生してる??
前はちゃんとインストールできてたのに?

ログを調べてみると

/var/log/vboxadd-install.log
/tmp/vbox.0/r0drv/linux/memobj-r0drv-linux.c:1542:26: error: 'struct mm_struct' has no member named 'numa_next_reset'
pTask->mm->numa_next_reset = jiffies + 0x7fffffffffffffffUL;

なんじゃこりゃ。。。

VirtualBox 4.3.12 のバグっぽいらしく、問題報告はあがっているとのこと。
けど、インストールできないと仕事に影響でてしまう。

対策

パッチを適用して流してやるしかないっぽい。
参考サイトを見ながらシェルを作成。

vboxbuild
set -e
mount -r /dev/cdrom /mnt/cdrom
sh /mnt/cdrom/VBoxLinuxAdditions.run --noexec --keep
umount /mnt/cdrom

# Apply patch
cur_dir=$(pwd)
tmp_dir=$(mktemp -d)
patch=VBox-numa_no_reset.diff

cat > ${patch} << _EOF_
--- src/vboxguest-4.3.12/vboxguest/r0drv/linux/memobj-r0drv-linux.c.orig    2014-05-16 21:16:12.000000000 +0900
+++ src/vboxguest-4.3.12/vboxguest/r0drv/linux/memobj-r0drv-linux.c 2014-08-04 18:55:12.346790321 +0900
@@ -65,6 +65,17 @@
 # define VBOX_USE_PAE_HACK
 #endif

+/*
+ * Distribution kernels like to backport things so that we can't always rely
+ * on Linux kernel version numbers to detect kernel features.
+ */
+#ifdef CONFIG_SUSE_KERNEL
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
+# define NUMA_NO_RESET
+# endif
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
+# define NUMA_NO_RESET
+#endif

 /*******************************************************************************
 *   Structures and Typedefs                                                    *
@@ -1533,12 +1544,12 @@
                 /** @todo Ugly hack! But right now we have no other means to disable
                  *        automatic NUMA page balancing. */
 # ifdef RT_OS_X86
-#  if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
+#  ifndef NUMA_NO_RESET
                 pTask->mm->numa_next_reset = jiffies + 0x7fffffffUL;
 #  endif
                 pTask->mm->numa_next_scan  = jiffies + 0x7fffffffUL;
 # else
-#  if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
+#  ifndef NUMA_NO_RESET
                 pTask->mm->numa_next_reset = jiffies + 0x7fffffffffffffffUL;
 #  endif
                 pTask->mm->numa_next_scan  = jiffies + 0x7fffffffffffffffUL;
_EOF_

tarball=${cur_dir}/install/VBoxGuestAdditions-amd64.tar.bz2

cd ${tmp_dir}
tar xjf ${tarball}
patch --ignore-whitespace -p0 < ${cur_dir}/${patch}
tar cjf ${tarball} *

# Run installer
cd ${cur_dir}/install
./install.sh

# Clean up
cd ..
rm -rf ${tmp_dir}
rm -rf ${cur_dir}/install
rm -f ${cur_dir}/${patch}

あとは、Guest Additions CD Image をセットしておき、

[root@centos mnt]# sh /mnt/vboxbuild

で実行してやれば、

Creating directory install
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.12 Guest Additions for Linux............
patching file src/vboxguest-4.3.12/vboxguest/r0drv/linux/memobj-r0drv-linux.c
VirtualBox Guest Additions installer
Removing installed version 4.3.12 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                         [失敗]
(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.

見事にインストール成功しました。
※CUIで運用しているので OpenGL はエラー出てます。

助かりました。
感謝!

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?