Friday 9 November 2012

LVM: lvextend failing

02.48pm. Today I ran into the following problem whilst trying to extend a LVM logicial volume.

[root@HOSTNAME mnt]# lvextend -L +20GB /dev/vg_HOSTNAME/lv_var
Extending logical volume lv_var to 60.00 GB
device-mapper: reload ioctl failed: Invalid argument
Failed to suspend lv_var

Version information:

[root@HOSTNAME var]# lvm version 
LVM version:     2.02.56(1)-RHEL5 (2010-04-22)
Library version: 1.02.39-RHEL5 (2010-04-22)  Driver version:  4.11.

Distribution Information:

[ChrisDaish@HOSTNAME ~]$ cat /etc/redhat-release
CentOS release 5.5 (Final)

After a quick google I discovered that these chaps had the same problem: http://www.linuxgeek.net/2011/04/06/three-virtual-machines/

Essentially I had created a new Physical Volume (PV) on /dev/sdb:

[root@HOSTNAME mnt]# pvcreate /dev/sdb2

I then extended the current Volume Group (VG) to include the new PV:

[root@HOSTNAME mnt]# vgextend vg_HOSTNAME /dev/sdb2
  Volume group "vg_HOSTNAME" successfully extended

You can confirm the new PV is part of the VG:

[root@HOSTNAME mnt]# vgdisplay
  --- Volume group ---
  VG Name               vg_HOSTNAME
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  15
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               5
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               116.08 GB
  PE Size               4.00 MB
  Total PE              29716
  Alloc PE / Size       20224 / 79.00 GB
  Free  PE / Size       9492 / 37.08 GB
  VG UUID               OEuajs-XUDQ-tgJB-NIVZ-cCIH-N3fh-1v0rHX

The penultimate task is to extend the Logical Volume, however this is when I ran into the error:

[root@HOSTNAME mnt]# lvextend -L +20GB /dev/vg_HOSTNAME/lv_var
Extending logical volume lv_var to 60.00 GB
device-mapper: reload ioctl failed: Invalid argument
Failed to suspend lv_var

After a good couple of hours experimenting, a fix was discovered (by @JamesYale) that allowed me to extend the LV.

[root@HOSTNAME ~]# lvextend -L +20G /dev/vg_HOSTNAME/lv_var /dev/sdb2
Extending logical volume lv_var to 61.37 GB
Logical volume lv_var successfully resized

By specifying the second PV in the lvextend command, I was able to increase the storage as required.. I can only presume this was because the first PV was getting close to full (even though it reported 6GB free).

Finally I can use resize2fs to extend the file system accordingly.

[root@HOSTNAME ~]# resize2fs /dev/vg_HOSTNAME/lv_var
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg_HOSTNAME/lv_var is mounted on /var; on-line resizing required
Performing an on-line resize of /dev/vg_HOSTNAME/lv_var to 16087040 (4k) blocks.
The filesystem on /dev/vg_HOSTNAME/lv_var is now 16087040 blocks long.

Hopefully this will help others who run into this problem, leave a comment below if so.

No comments:

Post a Comment