Extend LVM partition to >2TB. No need for GPT, Parted or Kernel editing

by | Jan 15, 2015 | RHEL / CentOS

Its now possible to extend LVM disk/partition to more than 2TB that too without using Parted, GPT or Kernel editing.After doing lots of Googling and not a single article explaining about extending LVM volume without GPT, I came up with this article which has been fully tested and working. It was tested on a 4TB disk with a single partition of 3.5TB. The LVM extension can be done without loosing any data although I would still recommend backing up the data as a precautionary measure.

NOTE: This has been tested in a DEV environment and assume no responsibility with regards to performance effect on the disk/volume in Production although the disk tested has been in a perfect condition and working for more than 2 years now.

In this article we would be working with a 20GB LVM disk and increasing it by 10GB but the same would apply if you are increasing space of a LVM disk/partition by more than 2TB.
Assuming we have got a partition “/VolGroup-lv_root” with 20GB space. The task in this guide would be to increase that volume by further 10GB.

First make note of the current size of the LVM Volume.

# df -h

Output :

[root@smtp-proxy ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-lv_root   18G  5.4G   12G  33% /

Then go ahead and add the extra disk to the Linux host. Once added run this command to verify the newly added disk is visible to the OS.

# lvmdiskscan

Output:

[root@smtp-proxy ~]# lvmdiskscan
 /dev/sdb                [      10.00 GiB]

NOTE: If the new disk does not appear, you might have to restart the Linux Hosts or you can also dynamically detect the new disk (this would be valid only for Virtual hosts) without restarting.

Now we need to convert/format the newly assigned disk to LVM so that we can later expand it to the existing LVM volume.

Run this command to convert to LVM format

#  pvcreate /dev/sdb

Output:

[root@smtp-proxy ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created

Run lvmdiskscan again to confirm the changes

# lvmdiskscan

Now it should show you “LVM Physical Volume” beside the new disk.

# /dev/sdb                [      10.00 GiB] LVM physical volume

Now you need to add the above disk to a VolumeGroup is which the primary disk sits / the Volume you want to extend.
Run this command to the PV (Physical Disk) to VG (Volume Group)

# vgextend VolGroup00 /dev/sdb

Output:

[root@smtp-proxy ~]# vgextend VolGroup00 /dev/sdb
  Volume group "VolGroup00" successfully extended

Now we need to extend the new partition/logical volume to the existing VolGroup so that it combines the total space from existing and new partition.

Run this command to 1st check the Total PE (Physical Extents) value of the new partition/disk

# pvdisplay

Output:

 --- Physical volume ---
  PV Name               /dev/sdb
  VG Name               VolGroup00
  PV Size               10.00 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              2559
  Free PE               2559
  Allocated PE          0
  PV UUID               xqOF8U-TRmM-7zpS-v6gs-UgDK-EdzS-kQDBR4

Take note of the above “Total PE” value and give that when running “lvextend” command.
Run this command for extending the LV (logical Volume) to the existing VolGroup

# lvextend  -l  +2559 /dev/VolGroup00/lv_root

* (-l is lowercase)

Output:

[root@smtp-proxy ~]# lvextend  -l  +2559 /dev/VolGroup00/lv_root
  Extending logical volume lv_root to 27.57 GiB
  Logical volume lv_root successfully resized

In the above command we are extending the new partition to /VolGroup/lv_root

Now if you check the total space on /VolGroup-lv_root, by running “df  –h”, it would still show you the same space i.e.20GB that was there before assigning the new disk (go to the begging of this guide). The reason being the new disk is still not visible to the partition manager of Linux.

To expand the new disk and make it visible to the partition manager.
Run this command

# resize2fs /dev/VolGroup00/lv_root

Applies to CentOS6.x

# xfs_growfs /dev/VolGroup00/lv_root

Applies to CentOS7.x

Output:

[root@smtp-proxy ~]# resize2fs /dev/VolGroup00/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup00/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup00/lv_root to 7226368 (4k) blocks.
The filesystem on /dev/VolGroup00/lv_root is now 7226368 blocks long.

Now if you do “df –h” , the expanded disk would available on the /VolGroup-lv_root/

# df –h

Output:

[root@smtp-proxy ~]# df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-lv_root   28G  5.4G   21G  21% /

Its all done now and you can start using the extra space.

If you encounter any errors during the process, let us know via Contact Us and will get it resolved promptly.

Related Articles….