Here are the steps to run a virtual instance of Linux CentOS on your Windows laptop using Oracle VirtualBox –
Downloading the essentials
- Get Oracle VirtualBox from https://www.virtualbox.org/wiki/Downloads
- Get CentOS 6.3 ~ 64bit from AOL India servers -> http://centos.aol.in/6.3/isos/x86_64/ (assuming you’re in India, else get your CentOS from another mirror). I had downloaded CentOS minimal which is about 300+ MB.
- Go ahead and install Oracle VirtualBox. This should be an easy step.
- Now it’s time to setup your Linux instance….
- Click “New” and go ahead and give the new instance a name.
- Select Type:”Linux” and Version:”2.6″ (64 bit). Hit Next.
- Change recommended memory size to 512 MB.
- Select “Create a Virtual Hard Drive now” > Next > Keep VDI selected. Hit Next.
- Select “Fixed size” > 2.0 GB. Hit Next.
- The wizard should now close.
- The instance you just created should show up on the Left hand bar in the “powered off” state.
- Now right click on the instance you just created. Hit Start.
- When prompted to provide a start disk, select the CentOS 6.3 ISO that you had previously downloaded. Hit Start.
- Now follow the instructions to install Linux just like you would on a bare metal box.
- If you plan to run web-server or an app-server on this CentOS VM then you’ll have to change the networking mode for this VM from NAT to Bridged. This ensures that your VM will get an IP address from the same DHCP source as your Windows Laptop.
Making CentOS ready
- Now log into your CentOS instance via the console
- Once you’re logged in as “root”, run ->
ifup eth0. This will bring up your ethernet interface.
- Now your instance will have a “real” IP address. To check, run ->
- Now open up “
/etc/sysconfig/network-scripts/ifcfg-eth0” and change
yes“. This will ensure that you don’t have to perform step #2 above whenever you bring up your VM instance.
- From now on you can SSH into your instance (via putty, if you prefer) via the IP address of the machine – as found out in step #3.
- Now let’s change an ipfilter rule to allow HTTP traffic to the VM instance.
- Open up the
/etc/sysconfig/iptablesfile and add the following rule
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
- The above should be added just below the this line “
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT” in the file
- You’re all set. Now go ahead and run ->
init 6for a VM reboot.
- Now go ahead and install Apache or any other web server and it shall be ready to serve on port 80 since we’ve opened up the port via step #7.
Hope the above steps will help you take the first few steps towards understanding virtualization and running your own virtual linux instance under Windows.