After running many errands on google, wikipedia and suchthings in search of a good Virtualization solution for my Windows-7 HP machine, I’ve discovered a sleek new solution for many virtualization tasks like trying out new Linux distros, testing my C# applications on a fresh Operating System, creating a virtual “Network of computers” on my machine, etc. This solution came in the form of Oracle VirtualBox. I had short-listed three virtualization candidates for this – VirtualBox, VMWare Player and Microsoft VirtualPC in that order. However, VirtualBox paid off so well that I had no need to look anywhere else. If you haven’t set up VirtualBox already, here is how you do it:
Step1: Download VirtualBox and a guest OS image
Download and install the latest package for your host OS from https://www.virtualbox.org/wiki/Downloads. In order to achieve virtualization, you will obviously need a guest OS either in the form of an installable CD/DVD or an .ISO image. Luckily, VirtualBox doesn’t insist on an actual CD/DVD disk. You may choose to install either from a disk, or directly from the .ISO image of the guest OS itself! Here are some places to get the latest versions of some of the popular OS images:
Linux Mint: http://www.linuxmint.com/download.php
VirtualBox provides many out of the box features including a versatile GUI to make the job of creating a virtual machine as easy as possible. Once you have installed VirtualBox, the next step is to create a virtual-machine for your new OS. This is like a shell that provides all basic features such as BIOS settings to control how the new OS starts, its hardware and graphics profile, and also its network setup. To create a new VM, start the VirtualBox program and click the new icon on the top:
VirtualBox will now ask you several questions such as the type of operating-system and how much disk-space to allocate to your virtual hard-drive.
How to allocate space to your virtual hard-drive?
The default setting of a dynamically growing disk suffices most purposes. The advantage of this is that you can play with several VMs with each getting a good hard-disk allocation like 100 or 200 Gigabytes. Mind you, this space is not actually allocated on your host-OS in case of dynamic memory, but the space will grow as and when used.
However, if you have plenty of space on your host-drive with memory running in several gigs or terabytes, or you want to allocate a fixed size on your host in advance, then you should go for fixed-size drive which performs better compared to dynamically allocated one.
The entire VM creation process is quite intuitive with a wizard-like interface. If you don’t understand anything, just go with the default settings. You can change later anything you want. Once you create your new VM, you can start it using the start icon on top, then proceed with the installation of your particular OS.
VirtualBox provides several ways to control and interact with the new machine. For instance, by default, the right control key (or right command-key in Mac Osx) is used to leave control to the host-OS. You can toggle between full-screen and normal mode by pressing Right-Ctrl+F key.
Once your installation is complete, you may have to install some guest addition packages on your guest OS. These are software that enable VirtualBox to better the user experience for that OS by providing features like 3D-graphics, USB support, native resolution/modes, etc.
Step 3: Establish a network between the guest and host machines
Here comes an important reason why most people (myself included) want to implement virtualization in the first place. To create and experiment with all kinds of networks without the risk (or taking the trouble) of creating an actual one. And here is where VirtualBox excels by providing several options for networking out of the box. VirtualBox installs an additional NIC (Network Interface Card) on your host computer to identify itself while communicating with the guest. By default the host gets an IP address of 192.168.56.1. You can change the network modes, IP and other network settings by right-clicking your virtual machine on the left and clicking Settings. These are the networking modes that work with VirtualBox guest computers:
- NAT (Default)
- Host-only Network (Most secure)
- Bridged Network (Least secure)
- Internal-Network (Betweeen guests only)
- Not Attached (No connectivity, guest isolated)
NAT: By default, the networking mode for your virtual machine is NAT (Network Address Translation) mode. This works something like this:
Assume that on your laptop, you are accessing internet through a router (typical in most home or wifi network scenarios). NAT works in the same way. This is a very secure way to access a network. In this case, your Guest computer sits behind the VirtualBox router. It can even access internet from through the host computer’s modem or LAN. However it is completely hidden from the rest of your network and the host computer thanks to the VirtualBox router-cum-firewall. Any traffic coming
from the guest computer will be seen as originating from your host computer.
Host-only Network: This is the second mode allowed by VirtualBox. Obviously, this is the most secure method among the three as there the “virtual-cable” is just laid between the guest and host computers, no other computer on the network will be visible to the guest. Think of this as a peer-to-peer computers between any two computers on a LAN:
In this case, the guest is actually (or rather “virtually”) cut off from the rest of the world, except the host computer. In this case, if you want to provide internet connectivity to the guest, you will have to turn your host into a proxy server. Then the guest can indirectly access the internet through your guest’s proxy server. This scenario is very useful when say, you are developing a proxy server and you want to test it. Other scenario is when you don’t need network in the guest at all. Of course, VirtualBox also provides an additional “Not Attached” mode if you want to totally isolate your guest from even the host computer too.
Bridged-Network: This is the preferred mode to establish full-fledged networking on your guest. In this case, your guest actually becomes a peer on your network. All other computers can “see” the guest as a different peer from the host. In other words, it is as good as setting up another peer with network and cabling on your LAN. VirtualBox achieves this by “sniffing” the incoming network packets on all your NICs directed at the guest, and in-turn “injecting” packets that are send by the guest to other peers:
Be warned however, that this mode is the least secure way to connect the guest, and use it only when you know what you are doing, and you really need to. Use the NAT mode as far as possible. I’ve myself never yet found a use for this mode. Especially, when you are connecting to the Internet without a proxy, remember that you are connecting directly without a router in between. In this case, you need a firewall which is quite strong. The Windows built-in firewall is preferred for windows guests which is on by default. On RHEL-like system such as Fedora or CentOS, there is a built-in firewall that you have to initially configure. Similarly on debian based systems like Ubuntu and MintOS, there is the ufw package which stands for “Uncomplicated firewall”.
Internal-Network: If, for some reason, you want all or some guests to internally communicate, while still keeping them isolated from host and the rest of your network, VirtualBox provides this mode out of the box:
Just set this mode for those guests you want to keep internally connected. By default all guests are assigned a dynamic IP address in the range of 10.0.2.0 (in all modes) by the built-in DNS servers in the VirtualBox. You will not want to change this to a static IP-address unless you have a specific reason to do so. Also, remember to keep all guests that you want internally connected in the same domain (for linux or Win-Server hosts), or the same workgroup (Windows hosts).
Not Attached: Finally, there is the mode for complete isolation, wherein the “virtual-cable” is as good as non-existent between the guest and host. In this mode, there is zero connectivity between your guest and host:
However, do remember that the guest can still access your CD-drive or an ISO depending on your setup. There is also a feature for “Shared Folders” which you can set in the virtual machine’s “Shared Folders” settings. When you map a folder on your guest, you have the option to “auto-mount” it when your gust starts. For example, you have shared your host machine’s C:\library folder as and mapped as library folder in guest. When your linux guest starts, it will be automatically mounted as “/media/sf_library” by default.
Hopefully, the above instructions should suffice. However, with the complexity involved in Virtualization, there is a big chance that anything has gone wrong or some components did not work as expected. In that case these are the holy sites to visit: