2

AWS supports live EBS resize. I increased from 10G to 20G on my /dev/sdb1.

Step 1: pvresize /dev/sdb1

# lsblk
NAME                    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda                    202:0    0  10G  0 disk
├─xvda2                 202:2    0  10G  0 part /
└─xvda1                 202:1    0   1M  0 part
xvdb                    202:16   0  20G  0 disk
└─xvdb1                 202:17   0  10G  0 part
  ├─home_vol  253:0    0   2G  0 lvm  /home
  ├─tmp_vol   253:0    0   2G  0 lvm  /tmp
   ....

Step 2: pvdisplay, lvdisplay

pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               my_vg
  PV Size               <2.00 GiB / not usable 0
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2559
  Free PE               0
  Allocated PE          2559
  PV UUID               ofH9ti-Wcuo-Io4o-796q-q7s8-9Z6S-oDsoEp

and

  --- Logical volume ---
  LV Path                /dev/my_vg/home_vol
  LV Name                home_vol
  VG Name                my_vg
  LV Status              available
  # open                 1
  LV Size                <10.00 GiB
  Current LE             511
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

As you see, the number hasn't changed. All right... let's do lvresize.

Step 3: lvresize -L 10G /dev/my_vg/home_vol

I got this instead:

  Insufficient free space: 2049 extents needed, but only 0 available

What step am I missing?

2

You've partitioned xvdb, and your LVM physical volume is on the first partition (which is still only 10GB). So you need to:

  1. Resize the partition to fill the disk
  2. Run pvresize to pick up the new size.

Personally, on Google Compute instances with LVM, I don't bother partitioning the disk — it serves no real purpose and makes resize much harder. I'd guess the same applies to Amazon. Just put the PV on the full block device (xvdb instead of xvdb1). Then you just have to run pvresize.

To resize the partition, use your favorite partition table editor. You probably have to delete the partition and create a new one making sure the start sector stays the same. That is extremely important; being a single sector off means losing your data. Then partprobe or kpartx might be able to load the updated table into the kernel with it live, otherwise a reboot is required.

Another alternative is presumably just to attach a third virtual disk, and put another PV there. You can add it to the same volume group, and grow your LVs that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.