LVM: Difference between revisions
(Created page with "ADD NOTES: https://xan.manning.io/2017/05/29/best-practice-for-mounting-an-lvm-logical-volume-with-etc-fstab.html (LVM snapshot can cause issues if you mount using UUID!!!) ====LVM Architecture and Terminology==== ---- <b>lvm</b> - Logical Volume Manager/management. * It is a storage device management technology that gives users the power to pool and abstract the physical layout of component storage devices for easier (ha) and flexible administration. * It utilizes...") |
No edit summary |
||
Line 42: | Line 42: | ||
Extents are behind much of the flexibility and power of LVM. The logical extents that are presented as a unified device by LVM do not have to map to continuous physical extents. LVM can copy and reorganize the physical extents that compose a logical volume without any interruption to users. Logical volumes can also be easily expanded or shrunk by simply adding extents to or removing extents from the volume. | Extents are behind much of the flexibility and power of LVM. The logical extents that are presented as a unified device by LVM do not have to map to continuous physical extents. LVM can copy and reorganize the physical extents that compose a logical volume without any interruption to users. Logical volumes can also be easily expanded or shrunk by simply adding extents to or removing extents from the volume. | ||
====How to find free space in a Volume Group==== | |||
---- | |||
https://www.thegeekdiary.com/centos-rhel-how-to-find-free-space-in-a-volume-group-in-lvm/ | |||
Latest revision as of 18:33, 19 September 2024
ADD NOTES: https://xan.manning.io/2017/05/29/best-practice-for-mounting-an-lvm-logical-volume-with-etc-fstab.html (LVM snapshot can cause issues if you mount using UUID!!!)
LVM Architecture and Terminology
lvm - Logical Volume Manager/management.
- It is a storage device management technology that gives users the power to pool and abstract the physical layout of component storage devices for easier (ha) and flexible administration.
- It utilizes the device mapper Linux kernel framework, the current iteration, LVM2, which can be used to gather existing storage devices into groups and allocate logical unites from the combined space as needed.
- Main advantage: increased abstraction, flexibility, and control.
- Volumes can be resized dynamically as space requirements change and migrated between physical devices within the pool on a running system or exported easily.
- LVM also offers advanced features like snapshotting, striping, and mirroring.
In summary, LVM can be used to combine physical volumes into volume groups to unify the storage space available on a system. Afterwards, administrators can segment the volume group into arbitrary logical volumes, which act as flexible partitions.
LVM Storage Management Structures
LVM functions by layering abstractions on top of physical storage devices. The basic layers that LVM uses, starting with the most primitive are:
- Physical Volumes
- LVM utility prefix: pv...
- Physical block devices or other disk-like devices (for example, other devices created by device mapper, like RAID arrays) are used by LVM as the raw building material for higher levels of abstraction. Physical volumes are regular storage devices. LVM writes a header to the device to allocate it for management.
- Volume Groups
- LVM utility prefix: vg...
- LVM combines physical volumes into storage pools known as volume groups. Volume groups abstract the characteristics of the underlying devices and function as a unified logical device with combined storage capacity of the component physical volumes.
- Logical Volumes
- LVM utility prefix: lv...
- A volume group can be sliced up into any number of logical volumes. Logical volumes are functionally equivalent to partitions on a physical disk, but with much more flexibility. Logical volumes are the primary component that users and applications will interact with.
What are Extents?
Each volume within a volume group is segmented into small, fixed-size chunks called extents. The size of the extents is determined by the volume group (all volumes within the group conform to the same extent size).
- The extents on a physical volume are called physical extents.
- The extents of a logical volume are called logical extents.
A logical volume is simply a mapping that LVM maintains between logical and physical extents. Because of this relationship, the extent size represents the smallest amount of space that can be allocated by LVM.
Extents are behind much of the flexibility and power of LVM. The logical extents that are presented as a unified device by LVM do not have to map to continuous physical extents. LVM can copy and reorganize the physical extents that compose a logical volume without any interruption to users. Logical volumes can also be easily expanded or shrunk by simply adding extents to or removing extents from the volume.
How to find free space in a Volume Group
https://www.thegeekdiary.com/centos-rhel-how-to-find-free-space-in-a-volume-group-in-lvm/
How to extend an LVM filesystem after increasing EBS volume size
How do I create an LVM logical volume on an entire EBS volume? https://aws.amazon.com/premiumsupport/knowledge-center/create-lv-on-ebs-volume/
https://www.linuxtechi.com/extend-lvm-partitions/
https://passwd.org/2012/06/linux-lvm-resizing-and-extending-amazon-ec2
https://unix.stackexchange.com/questions/138090/cant-resize-a-partition-using-resize2fs
(partprobe)
https://www.thegeekdiary.com/centos-rhel-how-to-resize-extend-existing-physical-volume-pv/
If you modify the EBS volume size, perform the following additional steps:
Check the current sizes by running lsblk and df -hT Check pvdisplay and lvdisplay Resize the physical volumes using the pvresize/pvextend command. Resize the logical volumes using the lvresize/lvextend command. Resize the file system.
(My notes/experience) Extend the filesystem:
After installing 'growpart' we ran the command below to grow the /dev/xvda2 partition to the new size:
$ growpart /dev/xdva 2
- Note: If you get "command not found, install it by running (RHEL8):
# yum install cloud-utils-growpart -y
The command was successfuly but changes weren't reflected in 'lsblk'. We ran 'partprobe' command to inform the OS of the partition table changes. We found that the kernel was unable to make those changes because the device /dev/xvda was busy, so we had to reboot the system. Once rebooted, we saw the size of /dev/xvda2 in crease to about 69.5 GB.
Verify things:
$ fdisk -l $ lbslk -f
Next step was to run 'pvresize' to extend the PV:
$ pvresize /dev/xvda2
Verify the increased size of the Physical Volume:
$ pvs
Verify the increased available space within the Volume Group:
$ vgs
Next, we extended the LV: lv_root
# looked for the LV name: lv_root $ lvdisplay # Extend lv_root (this does 100% of the free space, so if you do +50%FREE, that's 50% of the free space): $ lvextend -l +100%FREE /dev/vg_ecmapp2/lv_root # Verify the increased in size: lvs
We were then able to resize the filesystem successfully:
$ sudo resize2fs /dev/mapper/vg_ecmapp2-lv_root or (xfs) # xfs_growfs /dev/mapper/vg_ecmapp2-lv_root
Harshita's notes
How do I create an LVM logical volume on an entire EBS volume? https://aws.amazon.com/premiumsupport/knowledge-center/create-lv-on-ebs-volume/
$ sudo growpart /dev/xvdf 1
$ fdisk -l
$ lsblk
$ pvextend /dev/xvdf1
$ lvextend -L20G /dev/mapper/myvgo-personal
$ lsblk -f
- If filesystem is ext:
$ resize2fs /dev/mapper/myvg0-personal
- If filesystem is xfs:
$ xfs_growfs /lv2 (you can use the mountpoint or the whole path)
How do I create an LVM logical volume on a partition created on an EBS volume?
https://aws.amazon.com/premiumsupport/knowledge-center/create-lv-on-ebs-partition/
How to add New Disk to LVM
https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/
1. Create physical volumes (pv) on new disk named /dev/vdb. Type the following command:
$ sudo pvcreate /dev/vdb
Sample outputs:
Physical volume "/dev/vdb" successfully created
2. Now run the following command to verify:
sudo lvmdiskscan -l
Sample outputs:
WARNING: only considering LVM devices /dev/vda5 [ 39.52 GiB] LVM physical volume /dev/vdb [ 5.00 GiB] LVM physical volume 1 LVM physical volume whole disk 1 LVM physical volume
3. Add newly created pv named /dev/vdb to an existing lv. Type the following command to add a physical volume /dev/vdb to volume group:
sudo vgextend <vg_name> /dev/vdb
Sample outputs:
Volume group "<vg_name>" successfully extended
4. Finally, you need extend the /dev/<vg_name>/var to create new size (/dev/vdb (5G)+ existing /dev/<vg_name>/var (old size))
(/dev/vdb (5G)+ existing /dev/<vg_name>/var (old size)) sudo lvm lvextend -l +100%FREE /dev/<vg_name>/var or run this to specify XGiB of size: sudo lvm lvextend -L +5G /dev/<vg_name>/var
Sample outputs:
Size of logical volume ubuntu-box-1-vg/root changed from 37.49 GiB (9597 extents) to 42.52 GiB (10885 extents). Logical volume root successfully resized.
5. Now, if you run df -h or any other command you will still see /dev/<vg_name>/var as the old size. You need to run the following command to enlarge the filesystem created inside the “var” volume:
sudo resize2fs -p /dev/mapper/<vg_name>-var or if its xfs filesystem sudo xfs_growfs /dev/mapper/<vg_name>-var
6. Confirm with
df -h
Good reads
https://askubuntu.com/questions/76095/what-is-the-use-of-boot-lvm-based-in-partitioning/76109#76109
References:
[+] https://www.thegeekdiary.com/redhat-centos-a-beginners-guide-to-lvm-logical-volume-manager/
[+] https://www.systemmen.com/storage-fs/how-to-extend-linux-lvm-partition-in-aws-379.html
[+] https://www.digitalocean.com/community/tutorials/an-introduction-to-lvm-concepts-terminology-and-operations
[+] https://www.apptio.com/emerge/lvm-still-relevant-cloud
[+] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/index