Virtualizer toolbox – install Unix distros side by side

Virtualizer toolbox - install Unix distros side by side

CentOS, Windows, Ubuntu,
Catch a tiger by the toe.
If he hollers, let him go,
CentOS, Windows, Ubuntu.

Eeny, meeny, miny, moe

Today, we publish a simple guide on how to install multiple Unix distributions on your Windows computer. Why you may ask, when there are so many possibilities to put them as virtual machines. Just in case, when for some reason you need to install on the bare hardware, the described approach to install will be useful. For example, I needed a system for working with Xen on CentOS 5.8 for creating a virtual machine with Windows 7 (the topic of our next post) for Nerrvana. As you know Xen is not supported by RedHat since version 6, and since we are trying to work in a stable environment, we chose Xen in 2008, and now are looking at KVM. That is to work with KVM I installed CentOS 6.2 and Ubuntu 12.04.1. Because the process of understanding how to install multiple operating systems took some time and following our tradition, we will share our experiences with you. Understanding in this case is scalable, and you can use this knowledge to set hundreds of distros this way – you only need time, desire and … free disk space.

Let’s begin. I have a Dell laptop running Windows 7. I will not dwell on how to shrink a Windows partition. There are lots of tools that can help you with this, including the standard Windows tools.
In my case, I freed about 270GB on a 500GB drive to put three more operating systems. To proceed I loaded the following files that I recorded on CDs.

CentOS-5.8-x86_64-netinstall.iso – 14MB
CentOS-6.2-x86_64-netinstall.iso – 243 MB (at time of writing this post 6.3 is already available)
ubuntu-12.04.1-server-i386.iso – 660Mb

I apologize in advance for the quality of photos; I don’t have the skill set of a photographer. Today we can’t make it easy to understand the process without having lots of them.

CentOS 5.8

Starting off, a reminder to myself; I network install many times and I always forget that the CentOS 5.8 URL must be entered without http://, and even a folder can be entered without the leading slash (no clues are given on the screen but it works!).

Once we are at the disk partitioning screen, select the option ‘Create custom layout’.

On my convex monitor :) , we see two Windows partitions and free space to work with.

Push the button ‘New’ and create a /boot partition as shown. In this case, I did not mark to create it as primary, but partitioner creates it as primary. My discussion with Vadim (our sysadmin) concluded that this happens because we create the third partition and the disk partitioner understands it and makes it a primary. It turns out that in here we could actually tick “Force to be a primary partition” with the same result.

Again, press the button ‘New’ and create a Physical Volume (LVM) as shown below. This will create an extended partition /dev/sda4 and /dev/sda5 type PV (LVM) partition inside it. I admit, I needed Vadim’s help, to understand how to create an extended partition. It turned out that it is created and allocated the remaining space on the drive (what we need), apparently because we already have three partitions (two Windows and /boot, which we created earlier). Partitioner sees that we want to make the last (fourth) partition and that we have set the size – 70GB. On the other hand, partitioner sees that the disc has much more space than 70GB and therefore creates an extended partition /dev/sda4 first, and then inside the actual partition /dev/sda5, with size we specified, thus giving us the opportunity to use the remaining space in the extended section in the future. If we would use the option “Force to be a primary partition”, then most likely we would get 70GB primary partition on /dev/sda4 and … a lot of free space, which cannot be used as the disc will already have four partitions. In here, it was just not clear that creating a 70GB partition on the remaining free space will create both an extended partition and PV LVM partition in one go, if we don’t select the option “Force to be a primary partition” and the partition we create is the fourth one (and last available).

A hard disk may contain only one extended partition; the extended partition can be subdivided into multiple logical partitions.
The total data storage space of a PC hard disk can be divided into at most four primary partitions, or alternatively three primary partitions and an extended partition. These partitions are described by 16-byte entries that constitute the Partition Table, located in the master boot record.

From Wikipedia Disk partitioning

While at this point in the installation, you can perform the following experiment – remove /boot on /dev/sda3 and the extended partition /dev/sda4 we created and try to create 70GB partition first. Will this create it as extended if you specify its size as 70GB or, conversely, if you check “Fill to all allowable size”? Share the results, if you try.

In any case, we needed a primary partition, so we can boot from it and select one of installed operating systems in a boot loader (GRUB) we will install. We also needed an extended partition within which there may be infinitely many other partitions and we did and achieved it.

Now select /dev/sda5 and click “LVM”, to create file systems (/root, swap, /var and /tmp) for CentOS 5.8.

In the window that appears, use the ‘Add’ button to create logical volumes on vg0 we in turn created on /dev/sda5.

At the end this is how our vg0 looks like (scroll at the top of the main partitioner window).

Next step will be the boot loader setup. Change nothing here. The only thing I recommend is to select ‘Other’ and rename it to Win 7. We do not want to remember that ‘Other’ is in fact Windows 7.
On this step completion we will replace pointer to Windows 7 (/dev/sda0) in MBR to GRUB pointing to our /dev/sda3 as we install GRUB on /dev/sda (top line on picture below) which means MBR (no number after sda).

Since CentOS is set to load by default, we will see the CentOS boot screen and when we press space we end up in a GRUB menu where we can choose from a list. We have only two options in the menu and now we get to add a third one by setting CentOS 6.3.

This is how our hard drive looks after CentOS 5.8 setup from ‘fdisk-l’ point of view:

CentOS 6.3

Boot the CentOS 6.x netinstall disk (I used disk from 6.2 I already had). We select install from URL (net install) and enter the URL of the server address. Here, unlike CentOS 5.8, is a one lined with a default value ‘http://’ which leaves us with no doubts what to type.

When we reach the partitioning step, we select the option “Create Custom Layout”.

Note that our hard drive is now shown as /dev/sdb, but it’s the only thing that makes it different from what we saw when we finished installing CentOS 5.8.

Select our extended partition /dev/sdb4 and create /boot partition for CentOS 6. We will need it to put a boot loader for CentOS 6.

By analogy with the previous installation:

Select partition /dev/sdb4 again and create PV (LVM), by allocating 70GB.

We are going down a beaten path and creating, on the newly created PV (LVM) – /dev/sdb7, a logical volume group by selecting the appropriate option (see below).

Create vg1 and click ‘Add’ to create /root, swap, /tmp and /var.

Our result looks like:

Do not pay attention to this warning (click ‘Yes’):

It is important to dwell on this point and tell install to use /dev/sdb6 (/boot), as the place for a boot loader.

Next, you install CentOS by selecting packages. I always start with the minimum option, adding necessary ones later on. In CentOS 6, as opposed to CentOS 5.8, there is an option – Minimal.

After the reboot, we naturally cannot get to CentOS 6. You may ask – why after installing 5.8 we booted into its GRUB, but not here? This was because we wrote GRUB for CentOS 6 not to the MBR but /dev/sda5. If we would do it we would have access to 6, but lost access to 5.8. Also CentOS 5.8 GRUB does not know anything about installed CentOS 6. When installing CentOS 5.8, we modified the MBR and indicated that the active partition is /dev/sda3, but since there is GRUB over there, we can use it and boot from /dev/sda1 (Win 7).

We will boot to CentOS 5.8 and look at our hard drive again …

… and add the following section to /boot/grub/grub.conf:

Thus CentOS 5.8 GRUB contains, in essence, a reference to the CentOS 6 GRUB, which exclusively belongs to CentOS 6. Now we can reboot and select CentOS 6.3 from CentOS 5.8 GRUB menu.

Not tired? Well if not – we will install Ubuntu.

Ubuntu 12.04.1

I confess to you in confidence – I was installing Ubuntu for the first time and used all defaults, but then decided not to look for the easy way and at the same time to learn and as a result I installed it in the same way with logical volumes. We can boot from Ubuntu installation disk (server version).

This is how Ubuntu partitioner looks like:

Select free space line, press Enter and select ‘Create a new partition’.

Set size to 0.1GB for /boot.

Highlight lines – ‘Use as’, ‘Mount point’ and ‘Bootable flag’ and change values as shown below. Without setting a bootable flag I was unable to write GRUB to this partition (don’t fall into this trap and do it now!). Hopefully the boot loader page allows me to get back to partitioner, figure it out and proceed without aborting install and starting over (very nice).

Select free space line in the main window, press Enter and create a 70GB partition. In this case, for ‘Use as’ option choose ‘physical volume for LVM’ value.

After completion with this screen you are back to the main screen. Scroll up, select ‘Configure the Logical Volume Manager’ line and press Enter.

For some reason, Ubuntu wants to write the /boot partition to the hard drive now. We have no option to opt out and agree.

Create vg2 on /dev/sda9.

After creating the volume group, we stay in the same pop-up window and use a different menu item to add logical volumes for root, swap, tmp and var.

To actually create file systems on logical volumes, we need to press Enter on lines starting with #1, as shown in the first picture below. So we select lines starting with ‘#1′ for root, create the file system and exit and so on for each volume. What can I say – in CentOS it is much more convenient. Is the desktop version of installer better?

We can move on. When you save changes a warning pops up. Check LV’s and FS types and press ‘Yes’ to proceed.

Do not allow a boot loader to write to MBR and …

… write it to the /dev/sda8.

Now we are warned that we have a bootable flag on our logical partition. Well, I have checked – without a bootable flag Ubuntu will not be able to write GRUB to it. Set it to /dev/sda8. CentOS 5.8 GRUB will be able to boot from it by chain loading. This is different from both CentOS versions where we were able to write GRUB on /dev/sda3 and /dev/sda5 (partition inside extended partition) without setting a bootable flag.

That’s all. After installing Ubuntu again we will boot to CentOS5.8 and look at ‘fdisk-l’ output – Ubuntu is on /dev/sda8 and /dev/sda9. The second column is a bootable flag to confirm my words above – only Ubuntu wanted this flag to set a GRUB on partition.

Edit grub.conf file and remember that /dev/sda8 will be (hd0, 7) as (8-1).

Reboot now and select Ubuntu …

… and finally we see Ubuntu GRUB where we can actually go back to CentOS 5.8 (/dev/mapper/vg0-root) or CentOS 6 (/dev/mapper/vg1-root) or even Windows – see below.

All three OS’s are installed – that’s it.

Igor

Print this post | Home

Comments are closed.