It occurred to me the other day that despite the fact that I talk up CentOS as a great Linux distribution multiple times on this blog, I’ve never really ever bothered to show people how to install it. That’s why today things are going to change.
Today I am going to walk you through how to setup CentOS in VirtualBox so you can create your own virtual machine of this great operating system as opposed to having to run it on a standalone Linux laptop. My hope is that this guide will help you take those first steps toward learning a version of CentOS that may not be quite as user friendly as some of the others out there, but it is definitely one of the most powerful.
A Little About CentOS
CentOS stands for Community Enterprise Operating System. It is a Linux distribution that tries to provide a completely free, enterprise-class, operating system that is open source and supported by the community. This operating system is downstream in the flow from Red Hat Enterprise Linux, and shares many of same features and specs as its upstream OS.
In many ways, this distribution is targeted at business and enterprise users. However, that doesn’t mean you can’t use it, as well. At the end of the day, CentOS is free and available for anyone to install and run on almost any system out there. So don’t think you can’t do it just because you want to play with it at home.
Setup CentOS in VirtualBox
Now that you know a little more about it, it’s time to get to work. By learning how to setup CentOS in VirtualBox you will not only gain access to a great operating system, but you will also learn a little something along the way. Increasing knowledge is always a good thing. Wouldn’t you say? So let’s get started.
Step 1: Install VirtualBox
Many of you may already have VirtualBox, but if you don’t, click here to download the software. Once the download completes, install the software and run it.
Step 2: Download CentOS
Once you have VirtualBox installed and ready to go, you will need to download the ISO for CentOS. All you have to do is visit their website and click the Get CentOS Now button to download the most recent stable version of the operating system.
Step 3: Create Your Virtual Machine
Create a new virtual machine with the following settings:
- Name: CentoOS 7
- Type: Linux
- Version: Red Hat (64-bit)
- Memory Size: Minimum 1024MB, I chose 2048MB
- Hard Disk: VDI, Dynamically Allocated, Size – 20GB
Step 4: Add the ISO Image to Your New Virtual Machine
Click on your new virtual machine, then click on Settings > Storage > Empty.
Next click the icon that looks like a DVD on the right and select the ISO that you downloaded. Once selected, click OK.
Step 5: Start Your Virtual Machine and Install CentOS
Now you are ready to begin installing CentOS. Select your CentOS virtual machine from your list and click Start. Select the option Install CentOS Linux 7 and hit enter.
Enter the basic information that you will need for your installation, including:
- Date & Time
- Language Support
- Installation Source
Step 6: Software Selection
While you will find this information among the essentials, I felt it necessary to talk about it for a minute. From these selection, you can choose what software will come with your version of CentOS. For example, you can install the components for a LAMP server, print and file servers, and you can even specify the desktop type you will be using.
Now, I want this to be a jack of all trades setup. So for my installation, I’m choosing software from the following categories:
- File and Print Server
- Basic Web Server
- Server with GUI
- GNOME Desktop
- Development and Creative Workstation
These should give me all the features that I like to use right out of the box. Feel free to customize these settings to your needs. Don’t worry, if you forget something, you can always add it manually after the installation is complete. Remember, the more features you add, the more hard drive space you need. It will also increase the time it takes for the setup of the virtual machine.
Step 7 – Installation Destination
Finally, select the Installation Destination choice. Now, we are going to allow CentOS to handle the partitioning for us and it can use the entire virtual disk we created. So all we have to do here is go to the Installation Destination and then click Done. If you want to customize your partitions, now is the time to do so.
Step 8 – Begin Installation
After you have made all your choices, it is time to get the install underway. To do so, click Begin Installation.
Step 9 – Setup Root Password and User Account
While the install does its job, go ahead and click on the root password to setup the master password for your system. You will need this password anytime you make any changes to CentOS such as installing software.
Once that is complete, go ahead and create the main username and password that you would like to use on your system. Once complete, simply wait until the installation has finished. When finished, you may be prompted to reboot your system.
After the first reboot, you will be prompted to accept the License Agreement and then connect your Ethernet network (if it didn’t do it already). Accept the agreement and then click on the Network & Host Name section and turn your Ethernet switch to On. Once you do that click on Finish Configuration. Your new virtual machine will then reboot again and bring you to the login window.
Step 10 – Update Your System
Once you reach the login screen, click on the Not listed choice below your login name and enter root for the username and then the root password you setup in the previous step. We will be doing some updates and installs at this point and I don’t want to keep entering the root user and password every time we do it.
Now we need to update all the software on your new CentOS Linux virtual machine. To do that, go to Applications > System Tools > Software Update. Be patient, this may take a little time. On my virtual machine, 200 updates were found. When the updates are complete, you may be prompted to reboot your machine. Whether you are or not, I recommend giving your system a reboot after so many updates. Reboot and then log in again as the Root user.
Step 11 – Install Guest Additions
Don’t worry, we are almost done. All that’s left now is installing the VirtualBox Guest Additions. If you haven’t noticed, the window for your new OS is pretty small. Installing Guest Additions will give you the ability to resize your desktop and even run it in full screen. It also brings with it other handy features that improve performance as well as file sharing and other features between your host operating system and your guest virtual machine.
Go to Applications > Utilities > Terminal to open a new terminal window. This is where we will live for the next few minutes. Run the following commands:
Update the virtual machine kernel and reboot:
yum update kernel*
Add Repos and Install Packages:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Install the following Packages:
yum install gcc kernel-devel kernel-headers dkms make bzip2 perl
Add KERN_DIR Environment Variable
Click on Devices > Install Guest Additions
A Window will appear asking if you want to Run the Guest Additions installer. Click Run. When the installation is complete, reboot your virtual machine.
Enjoy Your CentOS Installation
Once your guest additions are complete, you can reboot your machine and login as the user you created. That’s all there is to it. You are ready to enjoy all the Linux goodness that CentOS has to offer. This setup is a great way to run your own web server, file server or even to play around on and even use as your main operating system. Remember, CentOS is closely related to Red Hat Linux, so you should have no problem finding the help you need to customize, configure, and even troubleshoot your CentOS installation.
In my opinion, CentOS is a great way to really learn Linux. While it isn’t quite as user friendly as some of the other distributions, in my opinion it is one of the most well done and powerful distros out there. If you truly want to learn Linux, then installing and using CentOS is one of the best ways to do it.
I hope this guide will help any of you out there install and run CentOS. I love this distribution, even though I tend to be a huge Ubuntu supporter. If I want to create a server, I almost always choose CentOS. But really you can use it for so much more, and I hope this guide demonstrates how easy it is to configure this operating system for many different types of tasks so you can create the ultimate Linux VM on your system.
Do you have any questions about this guide or are you stuck on any part of it? If so, please feel free to comment below and I will walk you through it as best I can. Hopefully you won’t have any problems. But if you do, I’m here to help.
Do you like CentOS? Have you ever run it as a virtual machine on your computer? If so, tell us what your experience was like with this distribution of Linux.
About the author
Matt is an IT professional with over fifteen years experience supporting network infrastructure and computers. An avid gamer, Matt enjoys his time playing and writing about his experiences both in the IT world and in the gaming communities. You can find more of his writing for LaptopNinja where he enjoys talking about everything tech.