• RHEL – Working with LVM

    by  • February 17, 2012 • Linux • 0 Comments

    LVM is a logical volume manager for the Linux kernel; it manages disk drives and similar mass-storage devices, in particular large ones. The term “volume” refers to a disk drive or partition thereof. It was originally written in 1998 by Heinz Mauelshagen, who based its design on that of the LVM in HP-UX.

    The LVM can:

    • Resize Volumes online
    • Create Snapshots
    • Mirror Volumes

    …and more.

    First , we need some partitions. We make them using fdisk tool or any other tool of your choice. The only thing you need to remember is to set the partition type to 8e. That will make it LVM Ready.

    Once the partitions are ready, we can make them Physical Volumes (PV) using the pvcreate command. Remember , data is stored by LVM in blocks of space called Physical Extents (PE). This can be set by pvcreate command and vary. Default is 4MB.  Number of PEs and their size plays an important role according to the type of data you are going to store in there.

    When we have our Physical Volumes ready, we will then proceed to create our Volume Group (VG). Think about volume groups as a collection of PVs. You can add PVs to a VG to add more space whenever you need.

    Once a Volume Group is available, we can then define Logical Volumes (LV) using the space from VG. Think about LVs as partitions in VG. LVs are available to us for formatting with any file system and mount. LVs can be resized easily according to data requirement and space availability in the containing VG.

    How to create a LV in LVM

    Here, I am having 2 disks /dev/sdb and /dev/sdc each 1 GB in size. I am going to create one partition in each and mark them as type 8e (LVM).  Then I would create a VG (newvg) with both the partitions (/dev/sdb1 & /dev/sdc1 ) as members. So the VG  will be 2GB and I will create a LV (logvol01) of 500 MB from the VG. We will format the LV with ext3 filesystem and mount it under /mnt/logvol01 . Terminal output is given below.

    If you are a GUI lover, you could do this using System->Administration->Logical Volume Management. We will look at resizing Logical Volumes, Snapshots and more in future.

    Hope you have enjoyed this article. As usual, feel free to try, share and discuss. :)

    Related posts:

    1. Working with SWAP in Linux

    About

    Could be found playing with his son Aryan when not working as a sysadmin. Likes to watch movies, play football, listen to music and chat with friends.

    http://www.undan.co.in

    Leave a Reply

    Your email address will not be published. Required fields are marked *