Updated: 2015-03-26 12:16 EDT
This document was originally written by CST student Joshua Caseley.
This document outlines how to install CentOS into the free VirtualBox virtualization software.
Students should normally be installing CentOS into VMware using the CentOS Install and Configure document.
This VirtualBox document is only for students who are having problems using VMware. Your instructors are not familiar with VirtualBox; use VMware if at all possible.
Linux/OS X/Windows
and x32/x64
Name: Choose a name for your new Virtual Machine: If your course and term is CST1234
and 15W
, then use the name CST1234-15W-CentOS-6
(no spaces). You can invent your own virtual machine name, if you prefer.
Type: Linux
Version: Choose either Red Hat (32-bit)
or Other Linux (32-bit)
Do not choose 64 bit!
Double check your settings and click Next.
The installation software requires more memory than the running CentOS server. If you are installing or re-installing your system, set your VM Memory to at least 1024MB (1 GB) before you continue. You can reduce the memory later.
Click Next
Another window will open.
Leave the default file name in the name box.
For the size of the virtual hard drive enter 2GB
(actually type the number 2
and the letters GB
into the box) and then Create.
The PAE/NX feature must be enabled or VirtualBox will not install CentOS.
Click on the Settings icon in the toolbar or go to the menu, Machine, Settings
In the left hand navigation pane, go to System
Go to the tab that says Processor
Where it says “Extended Features: Enable PAE/NX”, make sure this feature is enabled. Turn it on.
Click OK.
Open the Settings window.
In the left hand navigation pane, go to Audio.
Un-check Enable Audio. Turn this off.
In the left hand navigation pane, go to USB.
Un-check Enable USB Controller. Turn this off.
Click OK.
If either of these things re-enables itself, don’t fight it. Just move on.
Open the Settings window.
In the left hand navigation pane, go to Network.
Select the tab for Adapter 1.
Make sure that Enable Network Adapter is checked.
Make sure that Attached to: is set to just NAT (not NAT Network, just simple NAT).
When using NAT with VirtualBox, by default the IP address will always be
10.0.2.15
for every new virtual machine. (This is not how VMware does their NAT virtual machines.) To use SSH to connect from your host O/S to the VirtualBox VM behind NAT, you must setup and use Port Forwarding on each virtual machine.
In the Network settings, click the drop-down arrow next to Advanced to show the advanced settings that includes the Port Forwarding button.
Toward the bottom of network Adapter 1, select the link button called Port Forwarding. A new window will open named Port Forwarding Rules.
In the Port Forwarding Rules window, locate the tiny add new rule icon at the far right of the dialog box. It is the top icon of the two and looks like a green “plus” sign. Select it.
Change the Name of the new rule rule from Rule 1 to SSH.
Leave the Protocol as TCP.
Leave the Host IP field blank (empty).
Set the Host Port to some unused port on your Host O/S, e.g. try 2222
as a likely free port. Make sure you choose a port that will be unique for this virtual machine. If you have multiple Virtual Box virtual machines, each will need a different Host Port number.
Leave the Guest IP field blank (empty).
Set the Guest Port to 22. (The SSH service on your Guest VM uses port 22.)
Select OK to close this window and return to the Network window.
Refer back to this section once you have installed CentOS and enabled networking.
You cannot connect from your Host O/S to the Virtual Box private address 10.0.2.15
of a virtual machine using NAT networking. You must use Port Forwarding with NAT networking under Virtual Box.
When using Putty or any other client SSH program on your Host O/S to connect to this Virtual Box virtual machine, set up Port Forwarding in your VM and then use the following settings in your SSH client program to connect to the VM:
Host: 127.0.0.1
Port: 2222
(or whatever port forwarding port number you chose, above)For this client connection to work:
2222
port on your local Host O/S machine to port 22
at the private IP address of the running Virtual Box VM.sshd
service must be available in your CentOS virtual machine.If you have multiple Virtual Box virtual machines using NAT networking, you must give each one a different local Host Port number. (Choose host port numbers above 1024 if running Virtual Box unprivileged under Linux or MacOSX.)
To install CentOS, we need to download and connect the CentOS ISO image file to the virtual CD/DVD drive of the VirtualBox Virtual Machine and make sure that the system chooses that CD/DVD drive at boot time.
Open the Settings window.
In the left hand navigation pane, go to System
Go to the tab that says Motherboard
In the box labelled Boot Order: Uncheck the Floppy and use the right hand arrow buttons to move Floppy to the third spot, under Hard Disk. Make the CD/DVD (checked) first, the Hard Disk (checked) second, the Floppy (not checked) third, and the Network (not checked) last.
Make sure only the CD/DVD and Hard Disk are enabled.
Click OK.
Open the Settings window.
In the left hand navigation pane, go to Storage
Under Storage, you will see Storage Tree with a Controller:IDE, and inside the Controller is your VM name and under that is a poorly shown visual CD drive icon with Empty beside it.
In the right hand pane, under Attributes, beside CD/DVD Drive, you will see a box containing IDE Secondary Master. There is a tiny CD icon on the right of this box. Click on the CD icon to open a menu that lets you set the path to your downloaded CentOS CD ISO image file.
Use the menu to navigate to your previously downloaded CentOS ISO image file and select it. The window will close and you will return to the Storage settings window.
Verify that in the Storage settings window, on the right under Information, you see Size: 339.00 MB (the size of the CentOS Installation CD) and the Location: is the location of your CentOS install CD ISO image file.
Click OK.
Click in the window and use the arrow keys to stop the Automatic boot.
After you have finished installing CentOS, you should shut down your CentOS machine safely and return to VirtualBox Settings, System, Motherboard, and change the Base Memory back down to to 256MB. This will make snapshots you take much smaller in size.
VirtualBox Guest Additions are equivalent to VMware Tools You must have a working CentOS virtual machine to install them.
Once you have CentOS running, you can install the VirtualBox Guest Additions that improve virtual machine performance. Here’s how:
You may need to download and install the VBoxGuestAdditions.iso
file separately from VirtualBox. Do this, if necessary.
Start (boot) your CentOS VM.
Use the Menu bar on your CentOS VM console to go to Devices and select Insert Guest Additions CD Image at the bottom of the menu. This action should connect the Guest Additions CD ISO file to your virtual CD/DVD drive.
Open the Settings window, select Storage, and in the Storage Tree box verify that instead of Empty it says VBoxGuestAdditions.iso
beside the CD/DVD icon.
In the CentOS console window, log in as root
and run the command file -s /dev/sr0
and make sure the output starts with: /dev/sr0: ISO 9660 CD-ROM filesystem data 'VBOXADDITIONS_
…
Create a mount point for the CD/DVD: mkdir –p /mnt/cdrom
mount /dev/sr0 /mnt/cdrom
To install the Guest Additions, some software must be compiled and installed in the current Linux kernel. We need to install some packages to make this possible.
gcc
compiler package: yum install gcc
gcc
.Find out the version (release) of the kernel that you are running: uname -r
yum install kernel-devel-XXX
yum install kernel-devel-$( uname -r )
/mnt/cdrom/VBoxLinuxAdditions.run
that should install the VirtualBox Guest Additions.
You can ignore the warning about not finding the Window System, since your CentOS machine does not run a window system.
Snapshots can be made by going to the Menu, Machine, Take snapshot, or use the Snapshots button near the top right of the main VirtualBox Manager window.
VirtualBox uses private IP address 10.0.2.15
as the IP for every VM using NAT networking, and that private IP address is not visible to the Host O/S, which is not the way VMware does it. You can read about why here: https://blogs.oracle.com/fatbloke/entry/networking_in_virtualbox1
VirtualBox has a FAQ section that may be of use to you: https://www.virtualbox.org/manual/ch12.html
10.
addresses in /etc/resolv.conf
, instead of only one single 172.
address, you may have problems.© 2014, Joshua Caseley. Licensed under the Creative Commons Attribution 3.0 license, http://creativecommons.org/licenses/by/3.0/
Rewritten by Ian!, using Joshua’s base document. Thanks, Joshua!