Setup Lab Environment using CentOS Linux and Oracle VirtualBox

Last week I started Red Hat Server Hardening (RH413) online training from Network Nuts so thought of setting up my lab environment to exercise the quiz at the end of each unit. I decided to use the open source CentOS Linux and Oracle VirtualBox on my Dell Latitude Windows 7 laptop so it won't hurt my pocket with extra cost. As this is going to be a lab environment and we experiment and break things up so it is a good practice to have a baseline image of the operating system which we can use to create multiple identical virtual machines within few minutes when needed using Clone feature. VirtualBox also has another great feature and that is point in time snapshot. Let's check out the step by step process to build the lab environment,

  1. Download the latest available VirtualBox binaries for our platform from, and go ahead with the installation. The installation is pretty straight forward, just double click the binary file and follow the wizard. At the time of writing this article the VirtualBox version was 4.3.6

  2. Download the "CentOS-6.5-x86_64-minimal.iso" from the CentOS website. We can download it from the nearest mirror to our location.


  3. Create virtual machine with type Linux and version Red Hat (64 bit). All the default installation parameters should be fine like memory 512M and hard disk 8G as we are going to do the minimal installation. Note: I am assuming we have x86_64 supported hardware and downloaded 64 bit ISO file.

  4. Once the virtual machine is created then configure the following,
    • Click on Storage and under IDE Controller select Empty CD/DVD Drive. On the right side under the Attributes browse the path and select the ISO file we downloaded in step #2.
    • Click on Network and change the Attached to to Bridge Adapter and Adapter Type to Paravirtualized Network (virtio-net).
    • Also, I prefer to disable any unwanted component like Audio, Serial Ports and USB.

  5. Start the virtual machine and follow the wizard to install the CentOS Linux.

  6. The default CentOS network configuration is set to not start at boot time but to change the configuration,

    # vi /etc/sysconfig/network-scripts/ifcfg-eth0

    Change the parameter ONBOOT=no to ONBOOT=yes and save the file wq! and now to restart the network service,

    # service network restart

  7. Go ahead and apply all the system patches,

    # yum -y upgrade

    And reboot the system,

    # reboot

  8. Before we proceed with the VirtualBox Guest Additions dependencies, we need to configure the Extra Packages for Enterprise Linux (EPEL) repository to install DKMS (Dynamic Kernel Module Support Framework) originally developed by Dell. If DKMS is not used then the VirtualBox Guest Additions will need to be re-installed after every kernel update. We can browse the latest available EPEL release at and at the time of writing this article the latest available package was epel-release-6-8.noarch. To install/configure the EPEL,

    # rpm -Uvh

  9. Due to security reasons we might want to disable the EPEL repository and enable explicitly only when required, to disable the EPEL repository,

    # vi /etc/yum.repos.d/epel.repo

    Under [epel] change the line enabled=1 to enabled=0 and save the file wq!

  10. Now install the VirtualBox Guest Additions dependencies,

    # yum -y install kernel-devel gcc make perl dkms --enablerepo epel

  11. On virtual machines window, click Devices and then Insert Guest Additions CD image..

  12. To mount the CD drive in CentOS,

    # mount /dev/cdrom /mnt

  13. To install the VirtualBox Guest Additions,

    # /mnt/

    The output will be,

    Verifying archive integrity... All good.
    Uncompressing VirtualBox 4.3.6 Guest Additions for Linux............
    VirtualBox Guest Additions installer
    Removing installed version 4.3.6 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                         [FAILED]
    (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                       [FAILED]
    (Could not find the X.Org or XFree86 Window System.)

    The output shows two failures, the second one is for Window System drivers which we don't care because this is CentOS system not Windows but first one failed to build the OpenGL support module.

    OpenGL (Open Graphics Library) is a cross-language, multi-platform application programming interface (API) for rendering 2D and 3D computer graphics. The API is typically used to interact with a Graphics processing unit (GPU), to achieve hardware-accelerated rendering. - Wikipedia

    If we do tail on the log file /var/log/vboxadd-install.log and look near the bottom then we will notice there are four files that VirtualBox Guest Additions couldn't find,

    include/drm/drmP.h:76:21: error: drm/drm.h: No such file or directory
    include/drm/drmP.h:77:27: error: drm/drm_sarea.h: No such file or directory
    include/drm/drm_crtc.h:35:26: error: drm/drm_mode.h: No such file or directory
    include/drm/drm_crtc.h:37:28: error: drm/drm_fourcc.h: No such file or directory

    But if we check what provide these files then the packages are already installed on the system,

    # yum whatprovides "*drm/drm.h"

    Now let's check if these files are present in kernel source,

    # ls /usr/src/kernels/$(uname -r)/include/drm | grep -E "^drm_fourcc.h$|^drm.h$|^drm_mode.h$|^drm_sarea.h$"

    If this does not return any output then it mean the files are not present in the kernel source and we need to create symbolic links manually,

    # cd /usr/src/kernels/$(uname -r)/include/drm
    # ln -s /usr/include/drm/drm.h drm.h
    # ln -s /usr/include/drm/drm_sarea.h drm_sarea.h
    # ln -s /usr/include/drm/drm_mode.h drm_mode.h
    # ln -s /usr/include/drm/drm_fourcc.h drm_fourcc.h

  14. Install the VirtualBox Guest Additions again,

    # /mnt/

    Hurry!! Happy days, everything is OK this time.

  15. When we reboot the system and check the activities happening in the background then we will notice following message in very first few lines,

    Starting udev: piix4_smbus 0000:00:07.0: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr

    This is an error caused by VM having no smbus but operating system always try to load the module. It doesn't affect anything and can be safely ignored but is a bit annoying so to fix this let's check if the module is being loaded,

    # lsmod | grep -i piix4

    If yes, then go ahead and blacklist the module,

    # echo "# Blacklist the smbus i2c_piix4 module" >> /etc/modprobe.d/blacklist.conf
    # echo "blacklist i2c_piix4" >> /etc/modprobe.d/blacklist.conf

  16. Finally reboot the system,

    # reboot

  17. Before we lock down this baseline image we can install three more packages used frequently,

    # yum -y install wget man vim-enhance
Now we are good to power off the machine, just right click and clone to spin up new virtual machine. If we clone the machine there are two recurring tasks that we need to perform every time. First, rename the network interface eth1 back to eth0 which I have already documented but those are manual steps. Stay tuned for my upcoming posts for scripted way to fix the issue. Second, update the host name in /etc/hosts and /etc/sysconfig/network files. I couldn't find a way to get the VM name from CentOS guest but I am checking at the VirtualBox forum if this is even possible, otherwise stay tuned for my next article on scripted (less manual) way to update the host name.

Any feedback will be highly appreciated.

Suggested Posts,

This post appeared on the by Sumit Goel. Copyright © 2012–2014 – and Sumit Goel. All rights reserved. Not to be reproduced for commercial purposes without written permission.


  1. I did that once, but i had another problem with networking.
    I had to edit this file /etc/udev/rules.d/70-persistent-net.rules
    and remove the entry for Ethernet device then run "start_udev" then restart the network service "service network restart"

  2. Thank you for this post! I ran into this exact bug on a new CentOS 6.5 VM and creating the four symlinks got everything working.


Be sure to check back again because I do make every effort to reply to your comments here.