LVM Configuration | Part -1 | Linux Disk Management

                                            LOGICAL VOLUME MANAGEMENT               
     
          LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.
     
         With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks.
     
         The physical volumes are combined into logical volumes, with the exception of the /boot/ partition. The /boot/ partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/) partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.

        Since a physical volume cannot span over multiple drives, to span over more than one drive, create one or more physical volumes per drive.

Components in LVM:

PV – Physical Volume: It is the standard partition that you add to the LVM. Normally, a physical volume is a standard primary or logical partition with the hexa code 8e.

VG – Volume Group: It is composed of a group of PV’s and LV’s. It is the organizational group for LVM.

LV – Logical Volume: It is composed of a group of LEs. You can format and mount any file system on an LV. The size of these LV’s can easily be increased or decreased as per the requirement.

Steps Involved in LVM:

pvcreate     – create a physical volume with hexa code 8e.
vgcreate     – create a virtual group to compose physical volumes.
lvcreate      – create a logical volume from physical volume in volume group.
vgextend    – to extend a volume group with new physical volume.
lvresize       – modify the size of logical volume.
vgremove   – reduce the volume by removing physical volume.
pvremove   – remove/delete the physical volume.
lvremove    – remove/delete the logical volume.

Commands, Syntax and Functions:

PV Creation:
#pvcreate < Partition name >
Example: #pvcreate /dev/sda1

PV Display:
#pvs (or) pvdisplay < Partition name >

Note: pvs, will display all PVs. pvdisplay < Partition name >, will display the details of particular partition.
Example: # pvs (or) pvdisplay < /dev/sda1 >

VG Creation:
#vgcreate < VG name > < Partition name >
Example: #vgcreate vg1 /dev/sda1

VG Display:
#vgs (or) vgdisplay < VG name >
Example: #vgs (or) vgdisplay vg1

LV Creation:
#lvcreate –L < size of LV >  -n < Name of LV > < VG name >
Example: lvcreate –L 300M lv1 vg1

Display LV:
#lvs (or) lvdisplay < VG name >
Example: lvdisplay vg1 (or) lvs.

Adding file system to LV:
We have created Logical volume. But, we can’t use without assign file systems to disk and mount.

Add File System:
# mkfs.ext4 </dev/vgname/lvname>
Example: mkfs.ext4 /dev/vg1/lv1

Mount the partition:
#mount </dev/vgname/lvname> /directory name
Example: mount /dev/vg1/lv1 /lvm1

Make permanent mounting by adding entry in /etc/fstab.
#vim /etc/fstab
Example:
/dev/vg1/lv1 /lvm1 ext4 defaults 0 0

Note: LVM Configuration is completed in part -1. LVM administration will post soon in part-2.

Comments

Popular Posts