How to extend an LVM disk on a RHEL guest machine running on VMware host?
- Red Hat Enterprise Linux Guest
- Virtual Host
- How to extend an LVM disk on a Red Hat Enterprise Linux guest running on a virtual host?
- How do I to extend lvm in a virtual environment?
- Can I extend my virtual disk to increase lvm size
1. Modify the underlying guest disk for the virtual machine based on instructions from the virtual host vendor.
3. Check to see if the underlying device has changed after the modifications to the guest disk have been made, for example, investigating the size of
# fdisk -l /dev/sda Disk /dev/sda: 160.0 GB, 160000000000 bytes :
4. Create a new partition using
fdisk /dev/sda. For more information refer to the following knowledge base article:
How do you use fdisk to add a primary partition?
NOTE: Red Hat recommends that all critical data be backed up and verified before making any changes to the underlying storage, or filesystem as an unforeseen problem might occur.
5. Read disk and try to add all partitions to the system.
# partx -v -a /dev/sda
6. Check the device nodes for /dev/sda itself and the partitions on it
# ls /dev/sda*
7. Once a new partition has been created, create a new physical volume and add it to the existing volume group:
# pvcreate /dev/sda3 # vgextend VolGroup00 /dev/sda3
8. Verify how many free space are available to the Volume Group:
# vgdisplay VolGroup00 | grep Free
9. Extend the logical volume by the amount of free space.
# lvextend -l +<Free number of PE> /dev/VolGroup00/LogVol00 or # lvextend -L +<Size> /dev/VolGroup00/LogVol00
-l flag will extend or set the logical volume size in units of logical extents. The
-L flag will extend or set the logical volume size in units of megabytes. A size suffix of M for megabytes, G for gigabytes, T for terabytes, P for petabytes or E for exabytes is optional. With the ’+’ sign the value is added to the actual size
of the logical volume and without it, the value is taken as an absolute one.
[See the lvextend(8) man page for more information on options]
10. Issue the
resize2fs command to resize the filesystem:
# resize2fs /dev/VolGroup00/LogVol00
If using Rhel 7, then the command differs, as Red Hat Enterprise Linux 7 uses xfs as the default filesystem
# xfs_growfs /dev/VolGroup00/LogVol00
11. Verify that the additional space has been added to the logical volume
# df -h