CentOS5へのVBoxLinuxAdditionsインストール

ちょっとCentOSも使ってみようとVirtualBoxにインストールして、
とりあえず解像度は何とかしたいな…と、
いつものようにGuest Additionsをインストールしようとしたらつまづいたのでメモ。

# sh VBoxLinuxAdditions-amd64.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 3.2.10 Guest Additions for Linux........
VirtualBox Guest Additions installer
Uninstalling old VirtualBox DKMS kernel modules [ OK ]
Building the VirtualBox Guest Additions kernel modules [失敗]
Your system does not seem to be set up to build kernel modules.
Look at /var/log/vboxadd-install.log to find out what went wrong.
Once you have corrected it, you can
run

/etc/init.d/vboxadd setup

to build them.
Doing non-kernel setup of the Guest Additions [ OK ]
Installing the Window System drivers
Installing X.Org 7.1 modules [ OK ]
Setting up the Window System to use the Guest Additions [ OK ]
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services componen[ OK ]

途中でビルドに失敗している模様。
/var/log/vboxadd-install.log を見ろと書いてあるのでチェック。

# cat /var/log/vboxadd-install.log
Makefile:23: *** 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.

どうやらkernelのソースが必要みたいなので、
インストールして環境変数KERN_DIR(ソースのパス)を設定。

# yum install kernel-devel -y
# export KERN_DIR=/usr/src/kernels/2.6.18-194.26.1.el5-x86_64

で、再度セットアップを実行

# /etc/init.d/vboxadd setup
Uninstalling old VirtualBox DKMS kernel modules [ OK ]
Building the VirtualBox Guest Additions kernel modules
Your guest system does not seem to have sufficient OpenGL support to enable
accelerated 3D effects (this requires Linux 2.6.27 or later in the guest
system). This Guest Additions feature will be disabled.


Building the main Guest Additions module [ OK ]
Building the shared folder support module [ OK ]
Doing non-kernel setup of the Guest Additions [ OK ]
Starting the VirtualBox Guest Additions [ OK ]

今度はOK。
再起動して、解像度が変更できるようになったことを確認。