Tuesday, February 17, 2009

Installing Ubuntu 8.10 (Intrepid Ibex) with LVM

Some really good information on what LVM is all about is given in these few links:
Learning Linux LVM, Part 1
Learning Linux LVM, Part 2
TLDP LVM docs
RHEL DOCS for LVM


This was something I always wanted to try, so here are the steps:

Firstly, put in your liveCD for Intrepid. The problem is that by default the liveCD has no support for LVM. We need to install it and load the kernel module.

$ sudo apt-get install lvm2

$ sudo modprobe dm-mod


Now open up gparted:
$ gksudo gparted


Here you should create an ext3 partition with size ranging from 100MB to 300MB depending on how many kernels you wish to keep once you have installed your OS.
This ext3 partition is needed for /boot which cannot be within a LVM.
In my case this unformatted partition was /dev/sda13


After this create a partition with whatever size you require but do not format the partition to any filesystem type.
In my case this unformatted partition was /dev/sda14

The following steps are used to create the LVM scheme via the command-line:

1. Create an Physical Volume on /dev/sda14
$ sudo pvcreate /dev/sda14


2. Create an VolumeGroup named "ubuntuLVM" on /dev/sda14
$ sudo vgcreate ubuntuLVM /dev/sda14


3. Create a LogicalVolume named "intrepidROOT" within the VolumeGroup "ubuntuLVM" for the " / " partition
$ sudo lvcreate -n intrepidROOT -L 13.6G ubuntuLVM


4. Create a LogicalVolume named "intrepidSWAP" within the VolumeGroup "ubuntuLVM" for the swap partition
$ sudo lvcreate -n intrepidSWAP -L 3G ubuntuLVM


5. Format "intrepidROOT" as ext3 and label it "intrepidROOT"
$ sudo mkfs -j /dev/ubuntuLVM/intrepidROOT -L intrepidROOT


6. Format "intrepidSWAP" as a swap partition and label it "intrepidSWAP"
$ sudo mkswap -L intrepidSWAP /dev/ubuntuLVM/intrepidSWAP



Now after this is done we are ready to start the installer.
Choose "Manual Partitioning" as always :)

Select the ext3 logical volume named /dev/mapper/ubuntuLVM-intrepidROOT to be your " / " partition
AND
logical volume named /dev/mapper/ubuntuLVM-intrepidSWAP to be your swap partition

Do not forget to choose the partition you initially chose to be a /boot partition and format it as ext3 and mount it on /boot
(I almost forgot this !!!)

After the installation is complete, DO NOT RESTART
We need to run a few steps before restarting so that your LVM scheme can be recognised by your installed system !

Now we need to mount your installed filesystem and chroot into it so that lvm2 can be installed on it.
You will have a directory called /target within the liveCD filesystem which is used when installing the OS. We can use this same directory.

$ sudo mkdir /target/root
$ sudo mount /dev/ubuntuLVM/intrepidROOT /target/root
$ sudo mount -t proc none /target/root/proc
$ sudo mount -o bind /dev /target/root/dev


Now if you have additional partitions which need to be mounted as below, you need to mount those as well
$ sudo mount /dev/sda13 /target/root/boot


.......... and so on depending on how many separate partitions you have made.
In my case its just one for /boot.

Now we need to chroot into /target/root
$ sudo chroot /target/root/


This takes you to the / directory of your installation as the root user
# apt-get update
# apt-get install lvm2
# exit
Now you can add the dm-mod to the end of /etc/moudules files in your installed system.

$ sudo gedit /target/root/etc/modules

Paste dm-mod at the end of the file. Thats it !


If you are paranoid you can unmount the partitions you just mounted
$ sudo umount /target/root/boot
$ sudo umount /target/root/


Now you can restart your system and boot into Ubuntu 8.10 (Intrepid Ibex).

Thanks to the guys who wrote these howtos:-

debuntu.org
menelkir.wordpress.com
www.sysadminsjourney.com
beginlinux.com

EDIT:
Credits:
ubuntuforums.com , terryburton.co.uk,
linuxquestions & linux-sxs.org
roderick greening's blog

How do we mount LVM on another ubuntu system:

  1. Boot Ubuntu.
  2. Install lvm2:
    $ sudo apt-get install lvm2
  3. Load the necessary module(s): (Alternatively you can add dm-mod to the end of /etc/modules file)
    $ sudo modprobe dm-mod
  4. Scan your system for LVM volumes and identify in the output the volume group name that has your Fedora volume (mine proved to be ubuntuLVM):
    $ sudo vgscan
  5. Activate the volume:
    $ sudo vgchange -ay ubuntuLVM
  6. Find the logical volume that has your Fedora root filesystem (mine proved to be intrepidROOT):
    $ sudo lvs
  7. Create a mount point for that volume:
    $ sudo mkdir /media/intrepidROOT/
  8. Mount it:
    $ sudo mount /dev/ubuntuLVM/intrepidROOT /media/intrepidROOT/
  9. Mount other partitions (in my case only /boot on /dev/sda13)
$ sudo mount /dev/sda13 /media/intrepidROOT/boot/


Ran into this problem after I was using my Ubuntu Hardy Heron today !!!
Added it to this post :)

Short URL to this page:
http://tinyurl.com/ubuntuLiveLVM

2 comments:

  1. hi

    Installed lvm2
    and fatel error on sudo modprobe dm-mod

    what I do

    thx

    ReplyDelete
  2. Thanks lol...
    Below mentioned link is very easy to understand,
    http://www.redhatlinux.info/2010/11/lvm-logical-volume-manager.html

    ReplyDelete

Follow this blog !!!