0% found this document useful (0 votes)
11 views18 pages

22 Logical Volume Manager - Creation, Resize, Snapshot, Deletion

Uploaded by

adeelpfizer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views18 pages

22 Logical Volume Manager - Creation, Resize, Snapshot, Deletion

Uploaded by

adeelpfizer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Logical volume manager

LVM
It is a device mapper target in linux

It is a software abstraction of hard disk and partition

Features

Resizing - extend and reduce

Snapshots

Migrate logical volumes


Logical volume LV Logical volume LV

Volume group - VG

PV PV PV PV
PV

/dev/sdb /dev/sdc /dev/sdd /dev/sde


Physical Volume

It is a label given to hard disk or partition

Volume Group

Multiple physical volume combined together to form a storage pool called volume group

Logical Volume

It is a resizable portion created from volume group


Demo layout

/dev/sdb
/dev/sdc
/dev/sdd

are the three blank hard disk of size 20G each


Create PV
#create pv

pvcreate /dev/sdb /dev/sdc

#verify

pvs
Create VG
#create vg

vgcreate testvg /dev/sdb /dev/sdc

#verify

vgs

pvs
Create LV
#create lv

lvcreate -n testlv -L 30G testvg

or

lvcreate -n testlv -l 7680 testvg

#verify

lvs

vgs

pvs
Give filesystem
Note:

● Once logical volume is created /dev/mapper/vgname-lvname and /dev/vgname/lvname


dev file will be created.

mkfs.xfs /dev/testvg/testlv

or

mkfs.xfs /dev/mapper/testvg-testlv
Mounting
#temporary mounting

mount /dev/mapper/testvg-testlv /mnt

#permanent mounting

vi /etc/fstab

/dev/mapper/testvg-testlv /mnt xfs defaults 0 0

:wq

mount -a
Extending LV
lvextend -r -L +5G /dev/mapper/testvg-testlv

Verify:

Device path, current size, and mount point - lsblk

Free space in volume group to extend logical volume - vgs


Physical extend(PE)
Physical extend (PE) is a chunks of data block in volume group and the same in logical
volume is called logical extend (LE)

1PE = 4MiB

#verify

pvdisplay

vgdisplay

lvdisplay
Extending volume group
vgextend testvg /dev/sdd

Note:

● Volume group can be extended by adding a hard disk or partition without file system
Reducing volume group
vgreduce testvg /dev/sdd

Note:

● Volume group can be reduced by removing a physical volume which is not in use
Removing the old or unused hard disk

#New disk should be added to same VG


Snapshot
lvcreate -s -n testsnap -L 1G /dev/testvg/testlv
Revert the snapshot
#unmount

umount /mnt

#merge the snapshot with original volume

lvconvert --merge /dev/testvg/testsnap

#remount

mount -a
Deleting the logical volume
#remove entry from /etc/fstab

#unmount

umount /mnt

#remove the logical volume (This will remove the data)

lvremove /dev/testvg/testlv

#remove volume group

vgremove testvg

#remove physical volume

pvremove /dev/sdb /dev/sdc /dev/sdd

You might also like