Monday, 30 July 2012

Ubuntu in Virtual Machine

Many of my friends are really interested in installing and using an open source in their work machine, but for one or other reason they are not granted permission in their office. So what I thought, let's check for an alternate solution, people can install and use Ubuntu, without touching the OS running in their machine. 
So I have thought of writing a post on How to Install and use Ubuntu in Virtual Machine environment, I will chose Windows platform to install Virtual Machine. Reason I have chosen Windows is many people complained for installing Ubuntu over or beside running Windows, saying, who have patience to do all this stuffs? and also, I have many important softwares running in Windows, which I don't want to lose. So for them, this post may be a direct answer.

Virtual Machine (VM) environment is completely isolated operating system installation within your normal operating system, which is now achieved by Software Emulation. Or in easy words I can say, VM is a software implementation of a machine (or a complete computer) that executes programs and applications like a physical machine. Now a days many VM softwares are getting popular. VM Ware is the most popular virtual machine in market. However, there are may others too.
For my installation process I am taking one of the free Open Source Virtual Machine software called Oracle Virtual Box. It is free to download from Oracle webpage and yet powerful too. 
Download and install Oracle Virtual Box from >>here<<.
Next item is, Ubuntu ISO image, downloaded into your hard drive. If you don't have a latest copy download Ubuntu ISO image from >>here<<.

Minimum Requirements to Install Ubuntu in Virtual Box:
1) At least 2GB of RAM recommended. (Because 512 MB of RAM will be taken by VM Virtual Box for Ubuntu, other wise there is chance of crashing Ubuntu while running).
2) Minimum 8GB free space in your Hard Disk.

Let's start Virtual Box:
> Start Oracle VirtualBox.
> Click on the New button. In the New Virtual Machine wizard, click Next.
> In the Name field, enter UbuntuLinux, select Operating System as Linux and Version as Ubuntu. Click Next.
> In the Memory section, set the Base Memory Size to a minimum of 512 MB (default). Just make sure, the memory you allocate is less than half the physical RAM capacity. For example, if your computer has 2 GB RAM and you allocate 1 GB RAM for your Ubuntu Virtual Machine, there is a chance you will get an out-of-memory warning when you run the Virtual Box.
> In the Virtual Hard disk section, check Boot Hard Disk and select Create new hard disk.
> Select Next till you come to the Hard Disk Storage Type. Select Dynamically expanding storage and click Next.
> Set Location as UbuntuLinux and Size as 8.00 GB. The Summary page should be shown at this point. > Click on Finish, Click on Finish againIt will take you to the main screen.
Next step is Configuring your Ubuntu Installation.

In the main screen, select UbuntuLinux and click on Settings.
Navigate to Network on the left panel and change Attached to: to Bridged Adapter.
Navigate to Storage on the left panel and select IDE Controller and click Add CD/DVD devices > and click choose device button and select your Ubuntu ISO file.
Once it is all done, click on OK and in the main screen select UbuntuLinux and click on Start.
Do you get another screen now for Ubuntu installation? Just follow the instructions and install Ubuntu.

Installing Ubuntu:
Have a look into my first post Ubuntu Pre-Installation Tips and follow the same instructions here.
Select Install Ubuntu and do the install.
In "Allocate drive Space" screen, chose Erase and use Entire disk. Ubuntu will do all partition needed for you. Don't be afraid, the term entire disk here is your 8GB virtual partition you have created in previous steps. Your 8GB partition serves as entire hard disk, virtually for Ubuntu.  That's why it is Virtual Environment execution!!
After installation is complete, allow it to reboot. It will reboot and take you to the login page.
As it reboots you should hear the Ubuntu audio theme. If you can't, check the audio settings under SettingsEnable Audio should be checked.

Now, Open a terminal and type,
$ sudo su
enter password for Super User. Next type,
# sudo shutdown -h now
The Ubuntu Virtual Machine will shutdown now.

Now we have to remove the link to the Ubuntu iso file, or else it will start all over installation again. This step is similar to removing the Ubuntu CD from your CD Drive after the installation is complete.
Select UbuntuLinux and click on Settings; Go to Storage; Right-click on Ubuntu ISO link you have added and select Remove Attachment.

Now, you should be able to run your Ubuntu in Virtual Box.

How to share Windows folder in Virtual Box:
Believe me this situation will definitely occur, when you start using Ubuntu in your Virtual Box. Since, both the environments are different, you cannot access Windows files and folders in Virtual Box Ubuntu, [vice versa is also true].
There is a process how you can access Windows shared folder in Virtual Box Ubuntu. I found this method great helpful, with respect to Virtual Environment Execution.
Once you start UbuntuLinux, login with proper password.
Chose Device menu and click on Install Guest Additions. Install Virtual Box Guest application. It's an image file located in Virtual Box installation file. You may get more information about Guest Addition, hereRestart your Virtual Machine when completed. Now you should see a CD icon of "VBOX_ADDITIONS" on your Desktop.
Next step is, in your Windows drive, create a folder and name it properly. For example, i have created a folder named "ubuntu_share" in my C:\ drive. Next, share the drive for every one, with both Read, Write permission. To do so, right click on 'ubuntu_share' folder, chose properties, in sharing section, select share this folder.

Next, in Ubuntu Virtual Box machine, open Terminal and type,
$ sudo su
enter proper password.

Next part, Check what are all mounted in your system, to do that, type,
# mount
and hit enter.

You should see, what are all drives mounted in your system. There will be a line among list of all,
/dev/sr0 on /media/VBOXADDITIONS... type iso9660...

Next step is create a directory in /media/ drive. To do so, in Terminal type,
# mkdir /media/share/

Next, you have to mount your 'ubuntu_share' folder into /media/share/ directory. 
To do so, in terminal type,
# mount.vboxsf  ubuntu_share  /media/share/
and hit enter. 
If no warning is generated, then your ubuntu_share folder is successfully mounted on /media/share/ directory. Now, any file/folder you have kept in "ubuntu_share" in Windows you can access in Ubuntu Virtual Box. 
Try it out, keep any file in 'ubuntu_share' folder in Windows. In Ubuntu Virtual Box, in Terminal type,
# ls /media/share/
hit enter. You should see your file listed in here. 

Hope you Enjoyed !!

No comments:

Post a Comment