Virtualbox - Walk-Through (CentOS 9 Stream)

 In this post, we will walk through installing the community edition of the very popular RedHat Linux. The community edition is called CentOS. I call it the community edition because there are immaterial differences between the two minus the great support that comes with a purchase of RedHat. 

Before we go any further you will have to get familiar with the following websites:

  •  Virtualbox (https://www.virtualbox.org/) - This will be your hosted hypervisor. If you are not familiar with a hosted hypervisor please read my absolutely wonderfully stupendous post called "Virtualization -What is it and Why do we use it
  • Distrowatch (https://distrowatch.com/) - a virtual playground of Linux distros (a.k.a flavors) that you have never heard of. 
  • The Centos Project (https://www.centos.org/) - where we will download our ISO image file for creating a CentOS virtual machine on your host machine.

The first step lets install Virtualbox. If any of you are familiar with host virtualization, you may be into VMware Player (the free version of VMware Workstation). You may also know about the software Boxes. In this and every one of my posts, I will always prioritize the open-source and free software first. I do this because of the love and attention developers put into them. Most open-source projects are passion projects trying to bring something better to the computer communities around the world. These developers deserve their credit. 

Installing Virtualbox

Visit the link above, and click on the Downloads link to the left of the web page
From here, we will download the extension pack first. The extension pack is the same no matter which platform (Operating system) you are using. After this, select the platform package suited for whichever Operating System / Distro you are running. I will be installed on a Windows platform. 


the installation package will download immediately. From here we just follow the prompts and accept the license agreements as they appear. 



Before going any further, I would recommend setting 2 preferences:

  1. If you have multiple partitions or separate drives, consider changing the default location of where virtual machines will be stored
    • Select "File" -> "Preferences"
    • Select "Other..." from the box labeled "Default Machine folder:" 
  2. Setup a Nat network just in case you are interested in building a virtual lab.
    • While in "Preferences" click on "Network"
    • Click on the NIc card image to the right with a "+" over it
    • You do not have to, but you can edit the default configurations for the new NatNetwork by double-clicking on it or selecting the NIC card image with the "*" over it
Next, we download our ISO image from the CentOS website. Now this will get a little complicated because the download that is promoted on the normal site is almost 8gigs of data. Not everyone wants to wait for that kind of download. We will download the ISO image that is only ~750Mb in size. It is a much faster download and has everything that you will need to get started. We can also download any features that we may need in the future. 

Visit the CentOS link above, and click on the "Download" tab at the top of your screen. From here select the option CentOS Stream, not CentOS Linux. Take to read about the differences, but in short, the Linux version of CentOS will no longer be supported. Meaning, if bad guys find a way to hack it, the community will not provide any patches. Worst than this, fun applications for the distro may start to break as they progress their builds. I have been in this position with Mint Linux, and it broke my heart to wipe everything and start over. 

For the majority of you reading this walk-through, there is only one package needed. If you are using any other architectures like ARM and realize that you are, I will presume that you know what you need. For this walk-through, we will select the "RPMs" link beside "x86_64". 

From here we follow this rabbit hole: "BaseOS/" -> "x86_64" -> "iso" . Now we see a listing of ISO images and their accompanying hashes for integrity checking. Select the option "CentOS-Stream-9-20220117.1-x86_64-boot.iso" 

While the file downloads, locate the extension pack that you downloaded earlier, and double-click on it to start its installation.

By now, your ISO image file for CentOS should have completed its download. Let's create a new virtual machine. While in Virtualbox, click on the "*" labeled "New". 

Create a name for your new virtual machine. Tip: Using the name of the distro itself will register with the VirtualBox manager and pre-populate the "Type" and "version" fields.



Note: If the version field returns as a 32-bit option. The downloaded ISO image will not work, and you have one of three problems. 
  1. Your CPU and Motherboard both support virtualization, but it is not turned on in your BIOS. You will have to google how to change this setting for your individual computer. 
  2. Your CPU and/or Motherboard do not support virtualization. You will have to find a 32-bit version of CentOS 7 or stop here (sorry ;-( )
  3. You are installing this within a virtual machine itself. You will have to locate the steps for activating the nested virtualization feature. For VirtualBox, you can follow the steps in this article (https://stackoverflow.com/questions/54251855/virtualbox-enable-nested-vtx-amd-v-greyed-out)
Click the "Next" button. We now have to select the RAM. Most Linux distros only require 512Mb to 1Gb, but if you plan to follow the future posts I recommend 2Gb now. You can always adjust your RAM count while the virtual machine is stopped. 

Again click "Next", and now we create the virtual hard disk. ensure that the radio button of "Create a virtual hard disk now" is selected, then click "Create"


You will be given 3 options for hard disk types. Leave the default option of VDI unless you plan to re-use the virtual hard disk on a VMware product. If you would like the virtual hard disk to be compatible with VMware products use the option of VMDK.
 

the next option to popup is whether or not the virtual hard disk will be fixed or grow with usage (dynamic). The default option is dynamic, but fixed will provide better performance due to less processing done when writing. Since I am treating this as a home lab setup, and want to keep in mind that not everyone has an extra 100+gigs of space. I recommend going for the dynamic option so that the hard disk space is only used on the host machine when needed. 


Setup your maximum hard disk size to at least 20Gb. I will set mine to 32Gb.



We are almost done. Next, we will update a few settings in the virtual machine before installing the CentOS distro. Select your virtual machine name to the left, and then click on the sprocket labeled "Settings"

From the General section, select the advanced tab and change the field labeled "Shared Clipboard" to the option of "Bidirectional" so that you can copy from your host machine clipboard to the virtual machine or vice versa. 

Next, select the "Network" section. There will be 4 adapters. Each adapter is its own NIC card meaning that this virtual machine can be on 4 separate networks with 4 different IP addresses at the same time. We will activate one other adapter, and add it to the NatNetwork that we created earlier. 

The last stop in these settings will be adding the ISO image file to the optical disk drive of the virtual machine. Select the "Storage" section. Under "Controller: IDE" select the CD/DVD image labeled "Empty". To the right will appear a field labeled "Optical Drive:", select the drop-down to the right of that field. and click "Choose a disk file..."

Navigate to where you downloaded your CentOS ISO image to. Mine is in the "Downloads" folder. select the image and click "Open".


Click "Ok" at the bottom of the settings box. Now we are ready to run our virtual machine by clicking the "Start" button at the top of the manager window.


Select "Install CentOS Stream 9" by pressing enter on your keyboard. 
Note: that there may be a pop-up explaining how your mouse movement must be captured in the virtual machine. Accept the dialog box by clicking on "Capture". Your mouse movements will now be restricted to the virtual machine. When you want your mouse to track outside of the virtual machine, simply press your "CTRL" key on the right side of your keyboard. This is assuming that you are using a USA keyboard layout. 

There will be a systems check, and then you will be greeted by a GUI (graphical user interface) asking you to select your preferred language for CentOS. If you just click on "Continue" then it will default to English (United States). Next, you must set up your specific preferences. Let's start with "installing Destination" because it has a warning sign over it. 



When the next screen comes up, there is nothing out of place. The proper hard disk is selected, and we know this because there is only one and it is the size of 32Gb. This matches what I selected during the original setup that we went through earlier.  


Click the button labeled "Done". The warning sign over "installing Destination" is now gone. The option for "Software Selection" is next. In this settings window, we are only looking to ensure the following options for additional software for Selected Environment are selected in addition to "Server with GUI" being selected under the base environment section.
  • System Tools
  • Security Tools
  • Performance Tools
  • Network Servers
  • DNS Server

Click "Done" to return to the previous settings menu. Next, we will set up passwords for the Root account, and create the account that you will be using to log in. when configuring the Root account only set a password, do not lock the Root account at this time. Locking the Root account requires sizable efforts to get into the virtual machine,  and we have not gone over the inner working of Linux yet. 


Click on "Done", and then set up your user. Be sure to make your user an administrator, or you will not be able to run administrative tasks such as updating the system. 




Click "Done" and then "Begin Installation" and watch the magic happen.
Ok so most people that we are done at this point,  but we have one more step to go. We install the guest additions for this virtual machine, or features such as using the bidirectional clipboard or even maximizing the virtual machine window to max your monitor will not work. Let's start by logging in. 

Next, either take the tour of CentOS or skip it and escape the capture mode by pressing your right "CTRL" button keyboard button. In the menu bar at the top of your virtual machine window, select "devices"

this will load the Guest Additions into the virtual optical drive of your virtual machine. You will then notice a popup asking if you would like to run the software, select "Run". enter your password to run the software with elevated rights. 
Notice that I have maximized the window, but the virtual machine view did not change. 


During the installation, you may encounter an error with kernel headers. If so, visit the webpage: https://www.dev2qa.com/how-to-resolve-virtualbox-guest-additions-kernel-headers-not-found-for-target-kernel-error/

Well, that is all he wrote for this one. You now have a fully functional virtual machine running on your host machine. 


The Corporate Spin

At the end of each post, I like to leave you with questions and answers I have found to be most important 

How can we reduce errors during installations?

Create it one time, and then take a snapshot of the fully configured virtual machine. This will now be your gold image. Alternative to this, examine if it needs to be a virtual machine. Maybe, a container could accomplish the goal. A container would be more constant across multiple types of hardware. 

How can we make the repeatable?

After creating the gold image, leverage an automation tool like Ansible to fine-tune each deployment of the virtual machine. Then deploy through the use of a CI/CD tool like Ansible Tower or Jenkins. 

Comments

Popular posts from this blog

PowerShell Starter

Working with Windows Passwords

Writing a Powershell Script