Thursday, December 5, 2013

RHCSA Logical Volume Manager


The benefits of using LVM


  1. Create Extremely large logical volumes
  2. Add logical volumes in a running system
  3. Add hard disks to volume group in running system
  4. The snapshot feature allows consistent backups in a running system


Create a physical volume

The first step in LVM is to start with a physical partition. Create a partition using fdisk or parted. Assume that partition is /dev/sda1. To set up a new PV on a properly configured partition, apply pvcreate command:

#pvcreate /dev/sda1

If more than one partition configured as a PV:

#pvcreate /dev/sda1 /dev/sda2 /dev/sdb1

Create a volume group:

#vgcreate MyVol0 /dev/sda1  /dev/sda2

To include additional PV or to extend a VG:

#vgextend MyVol0 /dev/sdb1

Create a logical volume:

#lvcreate  -L 3G MyVol0  -n home

Use of Logical Volume:

Create a mount point and mount LV home to mount point.

#mkdir /Test
#mount /dev/MyVol0/home /Test

Remove a LV:

#umount /dev/MyVol0/home
#lvremove /dev/ MyVol0/home

Resize Logical Volumes:

Backup existing data on LV mounted directory for example /home and unmount it.
First extend the VG, if it doesn’t have more space.

#vgextend MyVol0 /dev/sdc1
#vgdisplay MyVol0          - to view total of VG

Then extend LV
#lvextend  -L 200M /dev/MyVol0/home
Then resize the LV with resize2fs
#resize2fs /dev/MyVol0/home
Or to use just a part of LV,





No comments:

Post a Comment