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 !!

Friday, 27 July 2012

Ubuntu Pre-Installation Tips

I will write a post here on What to remember before you install Ubuntu - a famous Linux flavor. Even though I am speaking about Ubuntu here, I will try make it a general post for all Linux flavors.

Let me drag your precious 5 minutes. World's 80% of PC is still running with Windows as major operating system. Google Trend ranks Linux at approximately 0.5 while Windows at 1.8 to 2. What's the reason behind people not opting for a better choice? Well there are few reasons, which may rid off soon (hopefully). First and foremost reason, Not knowing How user friendly, Hardware friendly, Installer friendly and Developer friendly the Linux is than any other OS. If you not aware Why You Need Linux in your machine, really it's time to know it for you.

Second reason might be, you dependent on proprietary software where you paid heavily for it's license and can't let it go. No matter, Linux has a solution for that, Dual boot. You can install Linux in parallel to your Windows and while booting you can choose which OS you prefer to boot. With 100% fail safe, Linux promises, your parallel Windows OS will  not be touched at all. That's the beauty of Linux, unlike monopoly strategy of Windows. Ubuntu - Linux for human beings - is one step ahead to it. Yes I forgot to tell, each and every software you install in Linux is totally Free of cost and you will never feel missing your own packages or software environment in Linux what you liked in Windows. It's sad to here if you been charged for softwares which are freely available in Linux.

Other reasons also like, monopoly nature of hardware vendors, there may be hardwares which only support Windows. Are you receiving your brand new lappy with Windows OS installed in it and is your vendor refusing to sell your device if you tell him that you don't want to invest on Windows?

Well, change your mind, we will install Ubuntu in your computer and let's discuss what things you need to take care before you start it.

What options available for me to install Ubuntu
Well, you can install it through CD-Rom or if your CD-Rom not working or you presently don't have it, you can install Ubuntu through your USB stick (is it not amazing to learn?).

How to prepare my CD-Rom for Ubuntu installation
Ubuntu home page itself is best guide to clearly explain it. Follow the link, in 2nd point, chose I would like to create : CD as option and To create it, I will use : Windows/Mac (chose which one you have running) operating system as options and click on Show me How.

How to prepare my USB stick for Ubuntu installation
Here also Ubuntu home page is best capable to explain you how. Follow the link, in 2nd point, chose I would like to create : USB stick as option and To create it, I will use : Windows/Mac (chose which one you have running) operating system as options and click on Show me How.

What about Installation
Well, I will not discuss all the steps here, it's all easy, even a level zero guy could do it. I will share a link, where it is beautifully explained Ubuntu installation with snapshots. Follow that >> HERE <<

Wait, what you should remember before installation
Believe me, most of the people will not go for installing OS because they afraid of data loss when doing partition. Well let me just say, Ubuntu installation is as easy as you install a software in your machine. If you are afraid too much, Ubuntu will install easily into your hard drive without asking for partition, without touching rest of the data. Let me clear some points about Linux - Ubuntu,

Everything is Files in Linux:
Yes, everything is file in Linux. The disk Partition in any OS is not physically dividing your hard disk into different parts, neither there exists a physical partition in your drive. Definitely, who ever used Windows, have been misguided about it. It is just a kind of record kept (in safe) as Boundary for different space in your disk. Once you keep storing data into the drive, OS takes care you just not cross that boundary.
So, today onwards, please think your Drive (Partition) as simple Directory (Folder: windows convention) with just a 'Storage Limit' as one extra property set to it. Any time you can Delete/Create/Format/Resize your drive as if you do it with Directory (Please take care your important data will not be lost before you do all above operations).
Keeping in mind, "partition is a directory", let's move on to Linux Partition (Linux Main Directories Structures). Here is the image for all major directories (partitions) in any Linux (including Ubuntu),
You can see, there is a "/" at the left hand side, which connects to many other directories on the right. That "/" is called ROOT of DIRECTORIES, where your directory structure just initiates. 
Don't get confused ROOT ("/") with another directory at the right side "/root/", both are different, I will tell you about that later. 
You might be surprised, how this directory structure relate to Partition of a disk? Simple, referring to image above,
ROOT ("/") is a big Directory (or Partition) and consider it occupies your full Hard Drive in size. 
Then, all other directories on right are also partitions inside your ROOT and total size they all occupy is what size of ROOT. Remember, you can manually define size for each partitions.
So if you have allotted complete Hard Drive for your ROOT, you can create all other directories (partitions) by giving them with each of them a better size limit. Else if you had plan to allot only some part of free space in your Hard Drive for Linux installation, ROOT will have a size of free space you allotted and inside ROOT all other partitions will occupy quite less space. I mean to say bigger the space you allocate for Linux installation, bigger will be your partition sizes; quite obvious, isn't it.
Now, let's look into child partitions on right hand side,
The /root/ directory you have seen at the right hand side is a 'User Specific' directory for Administrator. In Windows you might have seen there possible to create different users and one among them is Administrator also who is the master user in machine. The same Administrator is called "root" in Linux terminology. He will have all the access in his computer and what so ever you operate as 'root' will be reflected in /root/ directory. 
Then what about other users I create? Other users you create (like if I have created a user with name Kiran), they will allotted space at different Directory, that is under "/home/" directory (like /home/Kiran/). 
Well, now, /Kiran/ directory inside /home/ is not exactly a partition, it doesn't have size limit, but /home/ is a partition and it has size limit (So, obviously, if you have created only /Kiran/ directory under /home/ and if you keep storing data, you will be limited by /home/ partition size, since /Kiran/ can't carry data which exceeds it's parent size).
So, all are Directories in Linux, all have size limits and sub directories will carry only their parental size data.
You can specify Partition (Directory) Size while installing Linux:
Yes, you can manually specify what size your ROOT and other Directories (partitions) will follow. While installing, in "Allocate Drive Space" screen, choose "Specify Partitions Manually (Advanced)" option. 
I will explain here what method I follow normally, it is not mandatory you should follow same. And I will introduce one special partition called "Swap" in between my discussion, (which you have not seen in above directory structure image), for that you should have information about what is your computer RAM size in terms of GB?
Let me take an example and explain. Consider, you have 15GB free space, which you want to allocate it for Linux installation; or you can consider your Hard Drive size itself is 15GB, which you use for Linux installation. Let's jump to partition making process in Linux installation. 
While partitioning your 15GB, you can specify 
[*] "Partition Size" in terms of MB (1GB = 1024MB), 
[*] its "File System Type" (like ext2, ext3, ext4...) and 
[*] its "Mount Point".
where 'File System Type' is a partition type, just like what you choose FAT32 or NTFS in Windows, it's ext2 or ext3 or ext4 etc here in Linux; 
and Mount Point is exactly the Directory structure (ROOT or /home/ or /boot/ or /bin/ or /root/ etc) what you are specifying.
Now, let's divide out of 15GB,
[step A]. Create 2GB, ext2 partition type. However, "Ext2" is not mandatory. Mount it for /boot/ directory. So 15GB - 2GB = 13GB left.
[step B]. Create One and Half times or Two times your RAM size Swap partition. That is, if your RAM size is 512MB, then its two times, create 1GB Swap partition. Remember, there is No Mount point for Swap partitions, hence it's not shown under ROOT. Swap partitions helps to hold memory pages that are inactive in RAM (read more about Swap).  So now, 13GB - 1GB = 12GB left.
[step C]. Create 5GB, ext4 partition type. Mount it for /usr/. In general, this /usr/ directory is where Linux will install many of the softwares and packages. So you can choose, if you are not installing much of the softwares or games in your Linux, make partition size less. But I have taken it as 5GB in my example, so 12GB - 5GB = 7GB left.
[step D]. Create rest all 7GB space, ext4 type partition. Mount it for "/" (ROOT).
I know you are confused at this step, where all other partitions gone? Don't worry, Linux will automatically create them for you under ROOT. I know you have question, where did I specify other directory's size? Don't worry, Linux has calculated their size and allocated. 
What happened in overall is, ROOT ("/") is total 14GB (except Swap 1GB), under which lies /boot/ of 2GB, the /usr/ of 5GB and rest of 7GB will be shared by Linux to different directories according to their priority and usage. Remember, if you are still not satisfied, you want to manually allocate size for each and every directory under ROOT, you can go ahead and do it. Follow the "step C" and mention Partition Size and Mount Point for each directory you wish to create. Probably, you may wish to refer link, Linux Filesystem Structure or may be this or may be this.
Well that's all about pre installation tips you need to keep in mind. If you still facing difficulty in installation, don't worry, just start the installation and in Allocate drive space screen just choose "Install alongside other operating systems" and move further; Ubuntu will take care of it all and will get install successfully side by side to your Windows, without harming any stuffs in your machine.

Hope you enjoyed.