What is LVM?
LVM is an implementation of a logical volume manager for the Linux kernel. It was originally written in 1998 by Heinz Mauelshagen, which was based on the Veritas volume manager used on HP-UX systems.
LVM includes many of the features expected from a volume manager, including:
- Resizing logical groups
- Resizing logical volumes
- Read-only snapshots (LVM2 offers read and write)
- RAID0 of logical volumes.
Once we have reviewed the concepts, let's start:
In this entry we are going to see how to extend a logical and physical volume to expand a file system
We check how much space the disk has
fdisk -l /dev/sdb
Disk /dev/sdb: 50 GB, 53687091200 bytesWe rescan the disk
echo 1 > /sys/block/sdb/device/rescan
echo ‘1’ > /sys/class/scsi_disk/0\:0\:0\:0/device/rescanWe check the disk size again
fdisk -l /dev/sdb
Disk /dev/sdb: 60 GB, 64424509440 bytesAs we can see, the size of the disk increased, but when running pvs it does not show the same information because the volume has not been extended.
pvs | grep /dev/sdb
/dev/sdb vg_app lvm2 a– 50g 0If we expand the volume using the pvresize command
pvresize /dev/sdb
Physical volume «/dev/sdb» changed
1 physical volume(s) resized / 0 physical volume(s) not resizedBy consulting the volume space again we can see how it shows the correct size
pvs | grep /dev/sdb
/dev/sdb vg_app lvm2 a– 60g 0Now we just need to expand the logical volume
lvextend -l+100%FREE /dev/mapper/vg_app-lv_web
resize2fs /dev/mapper/vg_app-lv_webAll the best.
Comments