Criado por: André M. Faria
- 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.
2. Either reboot the system or initiate a rescan of the SCSI device, (RHEL5), (RHEL6), (RHEL7).
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?
or Use parted to add a primary partition, in virtual environments such as RHEV this has proven more reliable.
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.
6. Check the device nodes for /dev/sda itself and the partitions on it
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
# 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:
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.