LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Blogs > iamswift
User Name
Password

Notices



Rate this Entry

RHEL Installing multiple OS versions using Logical Volume Manager

Posted 10-10-2012 at 08:56 AM by iamswift
Updated 10-11-2012 at 02:02 AM by iamswift

Introduction:
Logical Volume Manager is a very good tool available in Linux to play around with disks and its sizes. This tool is very powerful that it virtually eliminates the requirement for fdisk based partition after the initial setup. Nowadays only two main partitions are created. One for “boot” and another for “LVM”. LVM internally has volume groups and logical volumes which act as independent partitions.

This article talks about how a free / available logical volume can be used to install a new version of OS unlike old ways where partition is necessary to accommodate multiple OS installation. For example, I might have RHEL 5.1 already installed and I want RHEL 5.8 to be installed in new logical volume instead of upgrading the RHEL5.1, I could do so with help of LVM.

In case the Volume group and logical volume is not properly planned and just has a single logical volume, we still can carve out a new logical volume from the root partition of the existing OS.
Refer link: http://www.linuxquestions.org/questi...-volume-35077/

Installing additional OS:
Assuming there is already a free logical volume available for new OS installation, the below steps are to be followed to install additional OS in a logical volume.

The “lvs” command gives us the list of logical volumes.

Code:
# lvs
  LV           VG                 Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  Lv_root    VolGroup01  -wi-ao  64G
  Lv_root2  VolGroup01  -wi-ao  64G					
  Lv_swap  VolGroup01  -wi-ao  17.62G

Here we have Lv_root and Lv_root2 logical volumes available. Lets say, we already have RHEL 5.1 installed in Lv_root and we are about to install RHEL 5.8 in Lv_root2.

First step is to check whether Lv_root2 logical volume is formatted in correct format (ext2 or ext3). Otherwise, we have to format the file system.


Code:
# mkfs –t ext3 /dev/VolGroup01/Lv_root2

Next is to mount the logical volume in a temporary dir so that new OS can be installed.

Code:
# mkdir –p /tmp/root2
# mount  /dev/VolGroup01/Lv_root2  /tmp/root2/
Installing additional OS in the Lv_root2 logical volume can be done in several ways. A yum local repository can be setup where the additional OS rpms can be placed. Another method is to use the “rpm” command and install additional OS in Lv_root2. The advantage of “yum” is that the package dependency is resolved internally and the order of installing the package is taken care by “yum”.

To set local yum repository:
For the baseurl attribute, provide the path where the RPMs are available.

Code:
# cd /etc/yum.repos.d/
# echo “[rhel5_8]” > rhel5_8.repo 
# echo “name=RHEL 5.8” >> rhel5_8.repo
# echo “baseurl=file:///path/to/rpm/” >> rhel5_8.repo
# echo “enabled=0” >> rhel5_8.repo
Once yum local repository is set, install temporary OS in the swap partition which is now mounted in /tmp/tmproot/ dir.
Note that we are just installing Base and Core packages. If additional packages are required those packages too to be added in the “groupinstall” option of below command.

Code:
# yum ––installroot=/tmp/tmproot ––enablerepo=tempos  groupinstall  Base Core –y ––nogpgcheck

Once the installation is done, it is necessary that few important files are copied to temporary OS installation so that when the temporary OS is booted, the parameters of original OS are available to new OS as well.


Code:
# cp –p /etc/fstab  /tmp/root2/etc/
# cp –p /etc/passwd  /tmp/root2/etc/
# cp –p /etc/shadow  /tmp/root2/etc/
# cp –p /etc/group  /tmp/root2/etc/
Edit the fstab to mount correct filesystems.
The copied fstab should look something as below:
Code:
# cat /tmp/root2/etc/fstab

/dev/VolGroup01/Lv_root 	/               	ext3    defaults        1 1
LABEL=/boot             		/boot                ext3    defaults        1 2
tmpfs                   		/dev/shm           tmpfs   defaults        0 0
devpts                  		/dev/pts             devpts  gid=5,mode=620  0 0
sysfs                   		/sys                   sysfs   defaults        0 0
proc                    		/proc                  proc    defaults        0 0
/dev/VolGroup01/Lv_swap 	swap                  swap    defaults        0 0
The fstab entries are to be edited so that /dev/VolGroup01/Lv_root2 logical volume is to be mounted as root (/) partition. Edit the /tmp/root2/etc/fstab as below (changes in red).

Code:
/dev/VolGroup01/Lv_root2 	/               	ext3    defaults        1 1			 Edited
LABEL=/boot             		/boot                ext3    defaults        1 2
tmpfs                   		/dev/shm           tmpfs   defaults        0 0
devpts                  		/dev/pts             devpts  gid=5,mode=620  0 0
sysfs                   		/sys                   sysfs   defaults        0 0
proc                    		/proc                  proc    defaults        0 0
/dev/VolGroup01/Lv_swap 	swap                  swap    defaults        0 0
Edit the /boot/grub/grub.conf to add additional boot option from Lv_root2 logical volume.
Typical grub.conf:

Code:
# cat /boot/grub/grub.conf

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-246.el5)
        root (hd0,0)
         kernel /vmlinuz-2.6.18-246.el5 ro root=/dev/VolGroup01/Lv_root  rhgb quiet
        initrd /initrd-2.6.18-246.el5.img

Modified grub.conf to add additional OS in boot menu (Those marked in red are to be replaced with the actual version of the additional OS that is being installed)

Code:
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-246.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-246.el5 ro root=/dev/VolGroup01/Lv_root rhgb quiet
        initrd /initrd-2.6.18-246.el5.img

title Red Hat Enterprise Linux Server 5.8 (2.6.18-274.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-274.el5 ro root=/dev/VolGroup01/Lv_root2 rhgb quiet
        initrd /initrd-2.6.18-274.el5.img

If required the default value can be set to 1 to boot from new OS when boot menu timeout is hit. Otherwise user can press any key during boot menu and select any OS to boot from.
Depending on whether to enable or disable SELinux, the configuration has to be edited accordingly in the new OS.

Code:
# cd /tmp/root2/etc/selinux/
# vi config			;# Edit the config file and set SELINUX=disabled for disabling SELinux
Now additional OS is installed and sitting parallel to existing OS. Reboot the system to boot on OS of your choice.

- Lakshmivaragan
HCL Technologies Ltd,
Chennai, India
lakshmivaraganm at hcl dot com
Posted in Technical
Views 884 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 11:36 PM.

Main Menu
Advertisement

Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration