How to Install CentOS 6.3 Linux in Oracle VirtualBox/SSH access/Port forwarding

Standard

For installing this flavor of Linux I am going to use Cent OS 6.3 x86_64 minimal version [Don’t be fooled by its name "minimal"] and Oracle Virtual box 4.2.6 x86. These are the current releases of both softwares.What do you need for this:

1. A computer which can run oracle virtual box [ can be Windows or Mac OS X ]

2. Cent OS 6.3 ISO – No need to burn a disk for this and you can download it here [Under CD and DVD Iso images click on x86_64 and then click on one of the mirrors to download it. Look for the file name CentOS-6.3-x86_64-minimal.iso to download, if this link becomes invalid, then browse for other mirrors]

3. Oracle Virtual box 4.2.6 and you can download it here

4. SSH Client for accessing your Cent OS Linux VM Server Secure Shell. I recommend KiTTY for SSH and you can download it here or you can download Putty here

Alright, now that you have downloaded both CentOS 6.3 and Oracle Virtual Box 4.2.6 you can start installing the Linux server.

1. Installing oracle virtual box on your computer – Step by step process with screen shots

Virtual Box Installer

change the installation location if you have disk space constraint on your primary hard disk. See the screen shot below and update the location by browsing to the location where you want to install.

2

3

In the next screen as shown below you will see a warning message about your network interfaces going away, yes as of this version of virtual box, it does disconnect you from your internet and so be prepared for a quick network interruption.

4

5

53

6 7

At this point you have a successfully installed virtual box on your computer. Go ahead and click finish to launch the program

8

2. Now that you have your virtualization software installed you are now ready to install CensOS 6.3 server in oracle virtual box – Step by step process with screen shots

Click on new to create a new virtual machine [Keyboard shortcut : CTRL+N to create a new VM]

9

10Name it appropriately and hit next. [If you want to install more virtual machines you want a follow good naming convention, avoid naming it too generic]. I named it as opensourcedbms_testbed. Dont worry about what version on Linux you are going to put over there as CentOS is not listed under there. We can mention it has RedHat 64bit or Fedora 64bit as these are close cousins of Cent OS.

11

Give appropriate memory size you want to allocate to your VM. depending on you main computer memory. I suggest for a basic Cent OS Linux server give at-least 1 GB and this can be modified at any time. If you give memory less than 1GB your CentOS Server will switch to text mode installation down the line rather than GUI. So stick with 1GB memory for now.

12

In the next screen its going to ask you to create a virtual hard drive and that’s what we want for a new server installation.

13

One nice thing in virtual box is that it can create virtual machines hard disk in multiple formats, I am not going to discuss which one is better over the other for now. I will choose the default one VDI (VirtualBox Disk Image).

14

In the next screen it will ask you how it wants to store this data on your main hard disk. Pick dynamically allocated to keep the size growing when needed. Fixed option will just use up all the space even if the CentOS VM does not physically use it.

15

In the next screen you can define the max hard disk size for this virtual machine. You can change the location of where you want to store this on your disk if want to place this virtual machine hard disk other than default. Hit create after you change the parameters as you desired.

16

Now you are done creating environment for your CentOS 6.3 Linux Server. Before you start the server installation we need to tweak certain things to mount the operating system ISO disk and some performance enhancements for the installation of operating system in this VM.

Select virtual machine and click settings.

17

Add some CPU cores to the VM if needed

18

Now mount the operating system disk image of Cent OS minimal that you have downloaded earlier. Browse to the download location for this image in your main computer to mount it.

19

Once you pick the operating system image it will indicate that as shown below and now click ok and come out from settings.20

Now you are ready to install Cent OS 6 Server in your VM. Go ahead and click start after selecting your VM in virtual box.

21

Once you click start you virtual machine starts up for the first time in a new window. Pay attention to the little red circle I drew to indicate how to release your mouse once you are inside the VM. You need to hit Right CTRL to release your mouse from your virtual machine. Hit enter inside this console window to begin installation.

Choose Install or upgrade an existing system and hit enter [its the default option]

23

In the next step it will request for a disk check. You can do it, I am skipping it as I am confident that my ISO image is good. Right arrow on you key board to move the highlighter onto skip option and hit enter to continue. At this point it will switch installation to Graphical user interface[GUI] mode.

24

click next 25

26

27

Select basic storage devices as we fall under that category

28

In the next screen it will ask to discard any data that exists in the hard disk that you created earlier for this VM. Go ahead and say yes to that. Note : This is not going to discard any of your main hard disk data. Only discard the VM HDD drive that you created along the way which should be empty any way.

29

Name your new CentOS VM Server. Name to what ever you want this server to be called as.

30

pick a time zone for the Cent OS VM server

31

Enter a password for root user. If you are a newbie to Linux, root user is like administrator.32

In this screen you can choose how to layout your partitioning schema. I am not covering how to change default partitioning schema[Custom partitioning] here. Pick the default option "replace existing systems". This will clean wipe the VM HDD one more time and layout partitioning schema to install CentOS Server.

33

Go ahead and write changes to disk and viola ! Cent OS will start installing in your Virtual Machine.

34

35 36

Congratulations ! you now have successfully installed Cent OS Linux Virtual Machine Server.

37

Restart and log into the console for enabling SSH access from out site virtual box into virtual machine. Use root as login and the password that you have setup for root user earlier in the Cent OS Server installation.

38 39

login into console

40

41

Now before you do anything we need to disable SELINUX. I am assuming you know a little bit of vi editor here, which is the default text editor in Cent OS Linux. If you do not know how to use vi editor please read about it a bit before you proceed further.

Edit the file /etc/sysconfig/selinux to disable it. Change the string from SELINUX=enforcing to SELINUX=disabled. Save it and exit.

42

43

Now SELINUX is disabled. We now need to fix our networking. To do that we need to edit our network file at this location : /etc/sysconfig/network-scripts/ifcfg-eth0

44

Remove HWADDR line and change ONBOOT="no" to ONBOOT="yes". Save the file and exit. Now the changes are made restart network for gaining network access to this server. To restart network simply run the command "service network restart"

45

Now we have network to our server.

46

Almost done and we are at our final stretch. We just need to open up port 22 from outside this server to make the SSH connection come into server. To do that open up VM settings one more time from main virtual box window [Leave the console window behind – no need to shutdown].

17

Click on Network navigation item and then click on port forwarding

47

Add port 22 to the list of ports that you want main computer forward into this guest Cent OS virtual machine. Save these settings and you are ready to access this Cent OS VM server secure shell from any where in your network. You can also forward other ports like 80/3306/5432 etc if you want to make this VM a web-server or database server in future. One modification that you might have to do it enable that new port in your iptables and restart iptables for server to start listening to that port.

48

Go ahead and allow its access from main host.54

3. Accessing CensOS 6.3 server secure shell from outside oracle virtual box – Step by step process with screen shots

Fire up the SSH client that you downloaded earlier

50Put localhost or your main computer name for host name and hit enter to connect to secure shell of you newly installed CentOS 6 Server.

51

Login with root / password [That you creating for root while installing Cent OS Operating system] and there you are in your Cent OS Server Console.

52

Facebooktwitterredditpinterestlinkedinmail

About Prashanth Goriparthi

Data Janitor

50 Comments

  1. Pingback: CENTOS install via .iso

  2. Pingback: Centos 6.4 in VirtualBox VM on Mac OS Lion + Windows + SSH | Think Beyond

  3. Awesome post Prashanth !! My Heartful Thanks to such a step-by-step post which can help Newbies like me……Much Appreciated!!

  4. Pingback: Configuring Oracle VMlocal | Resume JRC – Web Professional

  5. Thanks a lot mate. I was browsing lot of sites to get this information. Here is where I found straight forward steps.

  6. Your tutorial is awesome man! Thanks a lot.

    Can you tell me how to handle multiple VM instances from the putty session? I can’t use the same "localhost" as the hostname, right? How do I take care of this situation?

  7. Pingback: Linux Centos 6.3 | Kuplux's

  8. Hi, I have installed virtual box 5.0.10 on my Windows 8.1 64-bit Host and I want to install Linux on it. But when I am going to select Linux OS it is installing 32-bit OS. How I can 64-bit Linux OS on it.

  9. Really thank you a lot!
    I had problems with tutos on YouTube and I was disappointed and now I’m really happy to find this so explicitly explain!
    Thaaannnkkk yyyooouuu

Leave a Reply

* Captcha [Please fill/solve below] : * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.