2014-12-21

Christmas is almost upon us. Black Friday has been followed by Small Business Saturday and Cyber Monday.

The rest of the month obviously started on Skint Tuesday.

Fortunately for all us geeks, Santa Claus is real. He’s currently posing as Richard Stallman.

I mean, look at the facts. He’s got the beard, he likes to give stuff away for free, and he most definitely has a “naughty” list.

Thanks to Santa Stallman and others like him, I can amuse myself in the Holidays without putting any more strain on my Credit Card.

My main machine is currently running Mint 17 with the Cinnamon desktop. Whilst I’m very happy with this arrangement, I would like to play with other Operating Systems, but without all the hassle of installing/uninstalling etc.

Now, I do have Virtualbox on a Windows partition, but I would rather indulge my OS promiscuity from the comfort of Linux… sorry Santa – GNU/Linux.

So what I’m going to cover here is :

Installing VirtualBox on a Debian-based distro

Installing CentOS as a Guest Operating System

Installing VirtualBox Guest Additions Drivers on CentOS

I’ve tried to stick to the command-line for the installation steps for VirtaulBox so they should be generic to any Debian based host.

Terminology

Throughout this post I’ll be referring to the Host OS and the Guest OS, as well as Guest Additions. These terms can be defined as :

Host OS – the Operating System of the physical machine that Virtualbox is running on ( Mint in my case)

Guest OS – the Operating System of the virtual machine that is running in VirtualBox (CentOS here)

Guest Additions – drivers that are installed on the Guest OS to enable file sharing, viewport resizing etc

Options for getting VirtualBox

Before I get into the installation steps it’s probably worth explaining why I chose the method I did for getting VirtualBox in the first place.

You can get VirtualBox from a repository, instructions for which are on the VirtualBox site itself. However, the version currently available ( 4.3.12 at the time of writing) does not play nicely with Red Hat based guests when it comes to Guest Additions. This issue is fixed in the latest version of Virtualbox (4.3.20) which can be downloaded directly from the site. Therefore, this is the approach I ended up taking.

Right, now that’s out of the way…

Installing VirtualBox

Step 1 – Prepare the Host

Before we download VirtualBox, we need to ensure that the dkms package is installed and up to date. So, fire up good old terminal and type :

Running this, I got :

One further step is to make sure that your system is up-to-date. For Debian based distros, this should do the job :

Step 2 – Get the software

Now, head over to the VirtualBox Downloads Page and select the appropriate file.

NOTE – you will have the choice of downloading either the i386 or the AMD64 versions.

The difference is simply that i386 is 32-bit and AMD64 is 64-bit.

In my case, I’m running a 64-bit version of Mint (which is based on Ubuntu), so I selected :

Ubuntu 13.04( “Raring Ringtail”)/ 13.10(“Saucy Salamander”)/14.04(“Trusty Tahr”)/14.10(“Utopic Unicorn”) – the AMD64 version.

NOTE – if you’re not sure whether you’re running on 32 or 64-bit, simply type the following in a terminal session :

If this comment returns x86_64 then you’re running a 64-bit version of your OS. If it returns i686, then you’re running a 32-bit version.

A short time later, you’ll find that Santa has descended the chimney that is your browser and in the Downloads folder that is your living room you have present. Run…

… and you’ll find the shiny new :

Step 3 – Installation

To virtually unwrap this virtual present….

On running this the output should be similar to :

Note As this was not my first attempt at installing VirtualBox, there are some feedback lines here that you probably won’t get.

Anyway, once completed, you should have a new VirtualBox icon somewhere in your menu.

In my case (Cinnamon desktop on Mint 17, remember), it’s appeared in the Administration Menu :



As part of the installation, a group called vboxusers has now been created.

You’ll want to add yourself to this group so that you can access the shared folders, which is something I’ll come onto in a bit. For now though…

… where username is your user.

Now, finally, we’ve set it up and can start playing. Click on the menu icon. Alternatively, if you can’t find the icon, or if you just prefer the terminal, the following command should have the same effect :

Either way, you should now see this :



One present unwrapped, assembled and ready to play with…and you don’t even need to worry about cleaning up the discarded wrapping paper.

Installing the CentOS Guest

I fancy having a play with a Red Hat-based distro for a change. CentOS fits the bill perfectly.

Additionally, I happen to have an iso lying around on a cover disk.

If you’re not so lucky, you can get the latest version of CentOS (currently 7) from the website here.

I’ve created a directory called isos and put the CentOS iso there :

Once again, I’ve downloaded the 64-bit version, as can be seen from the x86-64 in the filename.

Now for the installation.

Open VirtualBox and click New :

In the Name and operating system window enter :

Name : CentOS7

Type : Linux

Version Red Hat(64 bit)



In the Memory Size Window :

Settings here depend on the resources available to the host machine and what you want to use the VM for.

In my case, my host machine has 8GB RAM.

Also, I want to install Oracle XE on this VM.

Given that, I’m going to allocate 2GB to this image :

In the Hard Drive Window :

I’ve got plenty of space available so I’ll just accept the default to Create a virtual hard drive of 8GB now.

Hard Drive File Type :

Accept the default ( VDI (VirtualBox Disk Image))

and hit Next…

Storage on physical hard drive :

I’ll leave this as the default – Dynamically allocated

Click Next…

File location and size :

I’ve left the size at the default…

I now have a new VirtualBox image :

The vdi file created to act as the VM’s hard drive is in my home directory under VirtualBox VMs/CentOS7

Now to point it at the iso file we want to use.

Hit Start and ….

You should now see the chosen .iso file identified as the startup disk :

Now hit start….

Don’t worry too much about the small viewport for now. Guest Additions should resolve that issue once we get it installed.

You probably do need to be aware of the fact that you can transfer the mouse pointer between the Guest and Host by holding down the right CTRL key on your keyboard and left-clicking the mouse.

This may well take a bit of getting used to at first.

Anyway, once you’re guest knows where your mouse is, the first thing is to actually install CentOS into the VDI. At the moment, remember, we’re just running a Live Image.

So, click the Install to Hard Drive icon on the CentOS desktop and follow the prompts as normal.

At the end of the installation, make sure that you’ve ejected your virtual CD from the drive.

To do this :

Get the Host to recapture the mouse (Right CTRL + left-click)

Go to the VirtualBox Menu on the VDI and select Devices/CD/DVD Devices/Remove disk from virtual drive

Now re-start CentOS.

Once it comes back, we’re ready to round things off by…

Installing Guest Additions

It’s worth noting that when CentOS starts, Networking is disconnected by default. To enable, simply Click the Network icon on the toolbar at the top of the screen and switch it on :

We need to make sure that the packages are up to date on CentOS in the same way as we did for the Host at the start of all this so…

Depending on how recent the iso file you used is, this could take a while !

We also need to install further packages for Guest Additions to work…

Note It’s also recommended that dkms is installed on “Fedora” (i.e. Red Hat) based Guests. However when I ran …

I got an error saying “No package dkms available”.

So, I’ve decided to press on regardless…

In the VirtualBox Devices Menu, select Insert Guest Additions CD Image

You should then see a CD icon on your desktop :

The CD should autorun on load.

You’ll see a Virtual Box Guest Additions Installation Terminal Window come up that looks something like this :

Eject the CD and re-start the Guest.

Now, you should see CentOS in it’s full-screen glory.

Tweaks after installing Guest Additions

First off, let’s make things run a bit more smoothly on the Guest :

On the Host OS in VirtualBox Manager, highlight the CentOS7 image and click on Settings.

Go to Display.

Here, we can increase the amount of Video Memory from the default 12MB to 64MB.

We can also check Enable 3D Acceleration :

Next, in the General Section, click on the Advanced Tab and set the following :

Shared Clipboard : Bidirectional

Drag’n’Drop : Bidirectional

You should now be able to cut-and-paste from Guest to host and vice-versa.

Shared Folders

At some point you’re likely to want to either put files onto or get files from your Guest OS.

To do this :

On the Host

I’ve created a folder to share on my Host system :

Now, in VirtualBox Manager, back in the Settings for CentOS, open the Shared Folders section.

Click the Add icon

Select the folder and make it Auto-mount

On the Guest

In earlier versions of VirtualBox, getting the shared folders to mount was, well, a bit of messing about.

Happily, things are now quite a bit easier.

As we’ve set the shared folder to Auto-mount, it’s mounted on the Guest on

…where sharename is the name of the share we assigned to it on the Host. So, the shared folder I created exists as :

In order to gain full access to this folder, we simply need to add our user to the vboxsf group that was created when Guest Additions was installed :

…where username is your user on the Guest OS.

Note – you’ll need to logout and login again for this change to take effect, but once you do, you should have access to the shared folder.

Right, that should keep me out of trouble (and debt) for a while, as well as offering a distraction from all the things I know I shouldn’t eat…but always do.

That reminds me, where did I leave my nutcracker ?

Filed under: Linux, VirtualBox Tagged: centos 7 guest, copy and paste from clipboard, guest additions, how to tell if your linux os is 32-bit or 64-bit, mint 17 host, shared folders, uname -i, VirtualBox

Show more