How to Install VirtualBox Guest Additions on CentOS

VirtualBox Guest Additions are a set of drivers and utilities that enhance the interaction and integration between the host and guest operating systems. For instance, if you are using CentOS (an open-source Linux distribution built from the same sources as Red Hat Enterprise Linux (RHEL)) as a guest OS on VirtualBox, installing Guest Additions within it will enhance its overall performance. Though installing VirtualBox Guest Additions is optional, improving the virtual machine’s performance and enhancing the user experience within VirtualBox, is recommended.

In particular, while using CentOS on VirtualBox you will notice some issues there. The most common ones are mouse and keyboard integration between the host and the virtual system, fixed virtual machine display resolution, 2-way share of clipboard and shared folders between the host and guest system, etc. In the following image, you can see that the guest CentOS VM is not opening in full screen. Installing VirtualBox guest addition will solve these problems. This guide will dive into the process of installing VirtualBox guest additions on CentOS using the graphical user interface (GUI) and command line interface (CLI).

centos vm not opening in full screen

Note: If you want to know how to install CentOS on VirtualBox follow “How to Install CentOS 7 on VirtualBox

Method 01: Install VirtualBox Guest Additions Using GUI

To install VirtualBox Guest Additions using the graphical user interface (GUI), follow the below processes:

  1. First, Start your CentOS virtual machine.start centos virtual machine on virtualbox
  2. After that, click on Devices. Then from that menu click on Insert Guest Additions CD image.insert guest additions cd image on virtualbox centos vm
  3. Now, click on Run.run virtualbox guest additions cd installer
  4. Provide your sudo user password and click on Authenticate.provide sudo user password and authenticate the installation
  5. Subsequently, VirtualBox guest additions installation will start. After VirtualBox Guest Additions Installation is Complete, press ENTER.After VirtualBox Guest Additions Installation is Complete, press ENTER.
  6. You are good to go. Now, you will be able to use VirtualBox guest additions features. For starters, you can resize your VM.centos vm is now opening in fullscreen
  7. After installation is complete you can safely remove the VirtualBox guest additions image from your VM. To do that right-click on the VBox_GAs image and click on Eject.eject virtualbox guest additions cd from centos vm

Method 02: Install VirtualBox Guest Additions Using CLI

To install VirtualBox Guest Additions using the command line interface (CLI) follow these step-by-step instructions:

Step 1: Launch CentOS VM

Select your CentOS VM and click on Start.

start centos vm

Step 2: Add “epel-release” Repository

Add EPEL (Extra Packages for Enterprise Linux) repository in CentOS as it provides additional packages not included in the default CentOS repositories.

For CentOS 7 and above:

sudo yum -y install epel-release

For CentOS 6 and earlier:

sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

add epel-release repository

Step 3: Update System App Packages

Update system applications by running sudo yum update -y command. This may take some time.

update centos installed app packages

app packages update complete

Step 4: Install Essential App Packages

  1. After the update is complete install all necessary packages to build kernel modules. To do that run:
    sudo yum install -y dkms gcc kernel-devel-$(uname -r)  kernel-headers-$(uname -r) make bzip2 elfutils-libelf-devel perl

    install all essential app packagesinstallation complete

  2. Now, set the KERN_DIR as an environment variable, as some applications may check this to reference the kernel source.
    export KERN_DIR=/usr/src/kernels/$(uname -r)

    set the KERN_DIR as an environment variable

Step 5: Mount the Guest Additions CD

  1. First, click on Devices > Insert Guest Additions CD Image.insert virtualbox guest additions cd image
  2. Then, create a new directory and mount the CD image there.
    sudo mkdir -p /mnt/cdrom
    sudo mount /dev/cdrom /mnt/cdrom

Step 6: Install VirtualBox Guest Additions Package

Now run the shell script to install the VirtualBox Guest Additions software package.

sudo sh /mnt/cdrom/VBoxLinuxAdditions.run

create new directory and mount the guest additions cd image

Step 7: Restart the CentOS Machine

  1. After installation is complete VirtualBox guest additions package should take effect. To ensure that restart your system with sudo shutdown -r nowshutdown your system
  2. Log in with your credentials.log in with your user credentials on centos
  3. VirtualBox guest additions package is active now.virtualbox guest additions is working properly, centos is in full screen

Step 8: Verify Guest Addition Installation

To check if the VirtualBox guest additions package is installed properly run lsmod | grep vboxguest

verifying guest additions installation

If you do not get any output then the VirtualBox kernel is not installed properly.

Step 9: Eject Guest Addition Installation Image

Finally, right-click on the VBox_GAs image and click on Eject to remove the VirtualBox guest additions image from your VM.

eject virtualbox guest additions image from centos virtual machine

Conclusion

VirtualBox guest additions enhance the functionality and performance of the virtual machine. This comprehensive guide has walked you through the steps of installing VirtualBox guest additions in the CentOS system to ensure a smooth integration of essential drivers and features. I hope this will help you to get a better CentOS experience in the VirtualBox environment.

People Also Ask

What are the requirements for installing VirtualBox Guest Additions on CentOS?

Requirements to Install VirtualBox Guest Additions on CentOS are:

  • VirtualBox extension pack should be preinstalled on VirtualBox.
  • CentOS virtual machine with CentOS installed in it.

What are the features of VirtualBox Guest Additions?

The main features of VirtualBox guest additions are:

  1. Enhanced graphics support.
  2. Mouse and keyboard integration.
  3. Shared folders for file transfer.
  4. Clipboard sharing between host and guest system.
  5. Seamless window integration.
  6. Automatic time synchronization between host and guest system.
  7. Auto resize of guest machine display.
  8. Improved audio support.

What is CentOS?

CentOS is a robust Linux distribution and is renowned for its stability and performance. It is an open-source distribution derived from Red Hat Enterprise Linux and offers a free platform. It is suitable for a wide range of applications and is a preferred choice among users due to its ability to provide a secure and comprehensive environment for various computing requirements.

Can I Install CentOS 7 on VirtualBox on Windows or MacOS?

Yes, VirtualBox is a cross-platform virtualization tool. You can install and run CentOS 7 on VirtualBox on Windows, macOS, or Linux.

How to full-screen CentOS 7 in VirtualBox?

To open CentOS 7 in full-screen mode on VirtualBox you need to have the VirtualBox guest additions installed. Then you can freely resize your guest system display. To install the guest addition CD on your CentOS VM, start the VM > devices > Insert Guest Additions CD image > Run > authenticate with sudo user password > Reboot. This will install VirtualBox guest addition packages on your CentOS VM.

How to install the VirtualBox Extension Pack?

To install the VirtualBox extension pack first download the extension pack from the official VirtualBox download page. Then click on Tools > Install > select the downloaded extension file > Install. The VirtualBox will automatically install the extension pack. If you are prompted to agree with their terms and conditions read that and click on agree.

Related Articles


<< Go Back to Virtual Machine Installation Guide | Linux OS Installation Guide | Learn Linux Basics

5/5 - (3 votes)
Ridoy Chandra Shil

Hello everyone. I am Ridoy Chandra Shil, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Biomedical Engineering graduate from Bangladesh University of Engineering and Technology. I am a science and tech enthusiast. In my free time, I read articles about new tech and watch documentaries on science-related topics. I am also a big fan of “The Big Bang Theory”. Read Full Bio

2 thoughts on “How to Install VirtualBox Guest Additions on CentOS”

  1. Great Article! thank you very much. it is very helpful and makes world better!

    However, there is a small mistake in the “Step 5”:

    “`
    sudo mkdir -p /mnt/cdromsudo mount /dev/cdrom /mnt/cdrom
    “`

    should be:

    “`
    sudo mkdir -p /mnt/cdrom; sudo mount /dev/cdrom /mnt/cdrom
    “`

    Reply
    • Hello zxnzysj. Thank you so much for your kind words! I’m really glad you found the article helpful, and I appreciate you taking the time to point out the error in Step 5. You’re absolutely right, the command should be:
      sudo mkdir -p /mnt/cdrom
      sudo mount /dev/cdrom /mnt/cdrom
      I’ve updated the article to reflect this correction. Thanks again for your feedback!

      Reply

Leave a Comment