Extend rootvg filesystem in openstack instances running RHEL 7.1

Latest response

I have created a RHEL 7.1 cloud-image with a couple of partitions and filesystems with a total size of 75GB as per my client's requirements. When this image is launched in OpenStack as an instance, with different disk sizes (for ex: 100 GB), the VG still shows up with 75GB only. While fdisk reports 100 GB, it doesn't show the additional sectors when trying to create additional partitions that can be added to the VG.

[root@test009 ~]# vgs
  VG   #PV #LV #SN Attr   VSize  VFree
  vg00   2  11   0 wz--n- 74.25g 13.00g
[root@test009 ~]# fdisk -l |grep "^Disk /dev/vd"
Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
[root@test009 ~]# lvs
  LV       VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  auditvol vg00 -wi-ao---- 256.00m
  crashvol vg00 -wi-ao----   8.00g
  homevol  vg00 -wi-ao----   5.00g
  logvol   vg00 -wi-ao----   5.00g
  nmonvol  vg00 -wi-ao----   6.00g
  optvol   vg00 -wi-ao----  10.00g
  repovol  vg00 -wi-ao----   5.00g
  rootvol  vg00 -wi-ao----  10.00g
  swapvol  vg00 -wi-ao----   2.00g
  tmpvol   vg00 -wi-ao----   5.00g
  varvol   vg00 -wi-ao----   5.00g

How can I make the OS use the additional disk space allocated to it?

Responses

I assume pvresize /dev/vdaX where X is the partition number of your physical volume would do the job. Once you see the free extents in the vg, you have to do a lvextend to extend the capacity of the desired lv and then, resize the filesystem with resize2fs.

unfortunately, /dev/vdaX isn't working...

Here's what worked for me:

I ran parted to fix it:

# parted /dev/vda 
......
parted > print list
Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the disk is smaller.  Fix, by
moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? Fix
Warning: Not all of the space available to /dev/vda appears to be used, you can fix the GPT to use all of the space (an extra 69206016 blocks) or continue with the
current setting?
Fix/Ignore? Fix

Then I used fdisk /dev/vda to create the new filesystem, used partprobe /dev/vda to reread the partition table and it worked.

Now, I'd like to know how I can script this fix? I tried something like the one below:

#!/bin/bash
(echo print list; echo Fix; echo Fix; echo print list; echo quit) | parted /dev/vda

But unfortunately, the Fix answer isn't echoed to the question but rather only to the parted> prompt. so it isn't working....

Maybe you can use "expect" to talk to parted.

Maybe someting like this (not tested)

#!/usr/bin/expect
eval spawn parted /dev/vda
expect "Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?"
send "F\r"
expect "Warning: Not all of the space available to /dev/vda appears to be used, you can fix the GPT to use all of the space (an extra 69206016 blocks) or continue with the
current setting?"
send "F\r"
send "print list\r"
send "quit\r"
expect eof

All,

I see a mixture of /dev/vda, /dev/sda and /dev/vdaX.

Can the original poster please show the output of the below mentioned commands:

vgs

lvs

pvs

Here it is:

[root@test10 '/root']# vgs
  VG   #PV #LV #SN Attr   VSize  VFree
  vg00   2  11   0 wz--n- 74.25g 9.00g
[root@test10 '/root']# lvs
  LV       VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  auditvol vg00 -wi-ao---- 256.00m
  crashvol vg00 -wi-ao----   8.00g
  homevol  vg00 -wi-ao----   5.00g
  logvol   vg00 -wi-ao----   5.00g
  nmonvol  vg00 -wi-ao----   6.00g
  optvol   vg00 -wi-ao----  10.00g
  repovol  vg00 -wi-ao----   5.00g
  rootvol  vg00 -wi-ao----  10.00g
  swapvol  vg00 -wi-ao----   6.00g
  tmpvol   vg00 -wi-ao----   5.00g
  varvol   vg00 -wi-ao----   5.00g
[root@test10 '/root']# pvs
  PV         VG   Fmt  Attr PSize  PFree
  /dev/vda4  vg00 lvm2 a--  35.62g 9.00g
  /dev/vda5  vg00 lvm2 a--  38.62g    0
[root@test10 '/root']#

Hello Sagayaraj,

You should run parted against /dev/vda, not /dev/sda

so parted /dev/vda

now you should be able to create /dev/vda6

vgextend vg00 /dev/vda6

this should add the extra space to the volumegroup and you should be able to manage the extra space, add it to an existing logical volume or create new logical volumes.

Kind regards,

Jan Gerrit

Thanks Jan. That was a typo as I didn't copy and paste the entire stuff.

I'm aware of the steps to resize/extend vgs/lvs. The problem was that fdisk didn't read all partitions in the disk but reported as a single partition. Whereas, parted was able to find the problem and offered to Fix it.

Now my concern is, how do I script it? Unfortunately, the system doesn't have expect installed. so I'm left with just bash to do this task. Any help would be appreciated :)

Additionally, using sgdisk with -e option against the device file fixes it as well

[root@test '/root']# sgdisk -e /dev/vda
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.