Install Guest Additions in CentOS through VirtualBox

centos.png

VirtualBox has special software that can be installed inside Windows and Linux virtual machines to improve performance and make integration much more seamless. Among the features provided by these Guest Additions are mouse pointer integration and arbitrary screen solutions (e.g. by resizing the guest window).

For some reason, I have never installed them on my CentOS 5.2 image… and I suddenly feel compelled to

So, let’s open VirtualBox, start the CentOS image and log in.
Now, on the host system, you need to locate the ISO image which contains the guest additions software : on my Ubuntu box, it was installed as /usr/share/virtualbox/VBoxGuestAdditions.iso.

Now, in the VirtualBox menu bar, go to Devices, Mount CD/DVD-ROM image, CD/DVD-ROM image… Add VBoxGuestAdditions.iso to the list and select it.

If your guest image is running X, the image should be mounted automatically in /media and appear on your desktop.

If X isn’t running (that’s my case), you need to mount the image. So, on the guest system (not on the host!):

[julien@centos ~]$ sudo mount -o ro -t iso9660 /dev/cdrom /mnt/cdrom

OK, now let’s run the installation script:

[julien@centos ~]$ sudo sh /mnt/cdrom/VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 1.6.6 Guest Additions for Linux installation.............................................................................................................................................................................
VirtualBox 1.6.6 Guest Additions installation
Please install the build and header files for your current Linux kernel.
The current kernel version is 2.6.18-92.1.18.el5
Please install the GNU compiler.
Problems were found which would prevent the Guest Additions from installing.
Please correct these problems and try again.

Oops. Installing guest additions requires a build phase and this box is missing the appropriate tools, i.e.the kernel development kit and the GNU compiler.

Let’s add them, but first let’s check the kernel version:

[julien@centos ~]$ uname -a
Linux centos 2.6.18-92.1.18.el5 #1 SMP Wed Nov 12 09:30:27 EST 2008 i686 i686 i386 GNU/Linux

[julien@centos ~]$ uname -r
2.6.18-92.1.18.el5

Now, let’s install the kernel development kit matching the kernel version:

[julien@centos ~]$ sudo yum install kernel-devel-`uname -r`
Password:
Loading "fastestmirror" plugin
Loading mirror speeds from cached hostfile
* base: centos.intergenia.de
* updates: ftp.free.fr
* addons: ftp.free.fr
* extras: centos.intergenia.de
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.i686 0:2.6.18-92.1.18.el5 set to be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
kernel-devel i686 2.6.18-92.1.18.el5 updates 4.8 M

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 4.8 M
Is this ok [y/N]:
Downloading Packages:
(1/1): kernel-devel-2.6.1 100% |=========================| 4.8 MB 00:15
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: kernel-devel ######################### [1/1]

Installed: kernel-devel.i686 0:2.6.18-92.1.18.el5
Complete!

Good. Now, the GNU compiler:

[julien@centos ~]$ sudo yum install gcc
Loading "fastestmirror" plugin
Loading mirror speeds from cached hostfile
* base: centos.intergenia.de
* updates: ftp.plusline.de
* addons: ftp.free.fr
* extras: centos.intergenia.de
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package gcc.i386 0:4.1.2-42.el5 set to be updated
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
--> Running transaction check
---> Package glibc-devel.i386 0:2.5-24.el5_2.2 set to be updated
--> Processing Dependency: glibc-headers = 2.5-24.el5_2.2 for package: glibc-devel
--> Processing Dependency: glibc-headers for package: glibc-devel
--> Running transaction check
---> Package glibc-headers.i386 0:2.5-24.el5_2.2 set to be updated
--> Processing Dependency: kernel-headers for package: glibc-headers
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
--> Running transaction check
---> Package kernel-headers.i386 0:2.6.18-92.1.22.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
gcc i386 4.1.2-42.el5 base 5.2 M
Installing for dependencies:
glibc-devel i386 2.5-24.el5_2.2 updates 2.0 M
glibc-headers i386 2.5-24.el5_2.2 updates 611 k
kernel-headers i386 2.6.18-92.1.22.el5 updates 854 k

Transaction Summary
=============================================================================
Install 4 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 8.7 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): glibc-devel-2.5-24 100% |=========================| 2.0 MB 00:03
(2/4): gcc-4.1.2-42.el5.i 100% |=========================| 5.2 MB 00:14
(3/4): kernel-headers-2.6 100% |=========================| 854 kB 00:02
(4/4): glibc-headers-2.5- 100% |=========================| 611 kB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: kernel-headers ######################### [1/4]
Installing: glibc-headers ######################### [2/4]
Installing: glibc-devel ######################### [3/4]
Installing: gcc ######################### [4/4]

Installed: gcc.i386 0:4.1.2-42.el5
Dependency Installed: glibc-devel.i386 0:2.5-24.el5_2.2 glibc-headers.i386 0:2.5-24.el5_2.2 kernel-headers.i386 0:2.6.18-92.1.22.el5
Complete!

Good to go. Let’s run that installation script again:

[julien@centos ~]$ sudo sh /mnt/cdrom/VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 1.6.6 Guest Additions for Linux installation.............................................................................................................................................................................
VirtualBox 1.6.6 Guest Additions installation
Building the VirtualBox Guest Additions kernel module...
Building the shared folder support kernel module...
Installing the VirtualBox Guest Additions...

Successfully installed the VirtualBox Guest Additions.
You must restart your guest system in order to complete the installation.

[julien@centos ~]$ reboot

Done! That wasn’t so bad, was it?

Related Posts

Comments are closed.