17

I increased the size of the partition which I'm using as a LVM PV, but running pvresize doesn't seem to see the extra space:

cuttle:~# fdisk -l /dev/vda

Disk /dev/vda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00027dbb

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1          31      248976   83  Linux
/dev/vda2              32        2610    20715817+  8e  Linux LVM

Which says that vda2 is about 20gigs

cuttle:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               debian
  PV Size               4.76 GiB / not usable 3.08 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1217
  Free PE               0
  Allocated PE          1217
  PV UUID               tehZic-5vfN-rsrm-B8lN-lpgc-yQT1-ioH1V0

So currently the pv is about 4-5 gigs

cuttle:~# pvresize -v /dev/vda2
    Using physical volume(s) on command line
    Archiving volume group "debian" metadata (seqno 12).
    No change to size of physical volume /dev/vda2.
    Resizing volume "/dev/vda2" to 9975981 sectors.
    Updating physical volume "/dev/vda2"
    Creating volume group backup "/etc/lvm/backup/debian" (seqno 13).
  Physical volume "/dev/vda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

pvresize says "No change to size of physical volume /dev/vda2"

cuttle:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               debian
  PV Size               4.76 GiB / not usable 3.08 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1217
  Free PE               0
  Allocated PE          1217
  PV UUID               tehZic-5vfN-rsrm-B8lN-lpgc-yQT1-ioH1V0

and the size of the pv hasn't changed.

Not sure what else I might do to use the extra space. I suppose I could resize the partition to the size of the pv, then add a second partition, but it really seems to me that what I'm trying to do here should work.

7
  • What are the underlying disks?
    – Andrew
    Jul 20, 2012 at 1:37
  • they are virtio
    – stew
    Jul 20, 2012 at 1:50
  • How did you create this extra space? Did you do the fdisk trick where you switch compatibility mode off, note the starting sector, delete the existing one, and then create the new LVM physical partition using the old starting sector?
    – Magellan
    Dec 25, 2012 at 22:02
  • Did this ever get resolved, stew? If not, could you add the output vgdisplay? (Community bump resurrection.) Jan 24, 2013 at 16:04
  • 1
    Quoting from the man page: "pvresize won't currently work correctly on LVM1 volumes or PVs with extra metadata areas". Is this your case? Also have you tried running with an explicit size, e.g. pvresize --setphysicalvolumesize 15G /dev/vda2? Feb 24, 2013 at 15:07

6 Answers 6

3

In my case, I had a volume of 60GB, and I extended it to 110GB.

After resizing the disk from AWS console, then when running df -kh, the system shows the new size of the disk, as expected:

nvme3n1                         259:4    0  110G  0 disk
└─nvme3n1p1                     259:5    0   60G  0 part
  └─vg_user01-lv_user01 253:0    0   60G  0 lvm  /home/user01

In a normal case, the next step would be expanding the physical volume, /dev/nvme3n1p1, but the command pvresize did not reflect the new extra space as expected.

sudo pvresize -v /dev/nvme3n1p1
    Archiving volume group "vg_user01" metadata (seqno 22).
    Resizing volume "/dev/nvme3n1p1" to 125827072 sectors.
    No change to size of physical volume /dev/nvme3n1p1.
    Updating physical volume "/dev/nvme3n1p1"
    Creating volume group backup "/etc/lvm/backup/vg_user01" (seqno 23).
  Physical volume "/dev/nvme3n1p1" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

After investigating the issue, it looks like this is a Kernel issue, that normally the new Kernels would detect this extra space automatically. I saw that some, advise rebooting the instance, but this also did not work.

To solve this issue, we need to run the growpart on the target disk partition.

[root@ec2-basic user01]# growpart /dev/nvme3n1 1
CHANGED: partition=1 start=2048 old: size=125827072 end=125829120 new: size=230684639 end=230686687

Then, we can see the changes reflected:

[root@ec2-basic user01]# lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme3n1                         259:4    0  110G  0 disk
└─nvme3n1p1                     259:5    0  110G  0 part
  └─vg_user01-lv_user01 253:0    0   60G  0 lvm  /home/user01

Then we need to check the LVM path:

[root@ec2-basic user01]# sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg_user01/lv_user01
....

Tell LVM to extend the logical volume to use all of the new partition size:

[root@ec2-basic user01]# lvextend -l +100%FREE /dev/vg_user01/lv_user01
  Size of logical volume vg_user01/lv_user01 changed from <60.00 GiB (15359 extents) to <110.00 GiB (28159 extents).
  Logical volume vg_user01/lv_user01 successfully resized.

Finally, we extend the filesystem:

[root@ec2-basic user01]# resize2fs  /dev/vg_user01/lv_user01
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vg_user01/lv_user01 is mounted on /home/user01; on-line resizing required
old_desc_blocks = 8, new_desc_blocks = 14
The filesystem on /dev/vg_user01/lv_user01 is now 28834816 blocks long.

[root@aws-test user01]# lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme3n1                         259:4    0  110G  0 disk
└─nvme3n1p1                     259:5    0  110G  0 part
  └─vg_user01-lv_user01 253:0    0  110G  0 lvm  /home/user01
2

partprobe /dev/vda

man partprobe

NAME partprobe - inform the OS of partition table changes

SYNOPSIS partprobe [-d] [-s] [devices...]

2
  • The OS already knows about the correct partition size, and there have been many reboots.
    – stew
    Jul 17, 2012 at 14:51
  • 1
    Note: partprobe is a part of parted package
    – Antonio
    May 8, 2013 at 10:46
1

You need to add space first from storage level, and then increase the space on ISCSI device by executing:

pvresize --setphysicalvolumesize 40G /dev/sda1..
1

I was running into this issue on a CentOS 7 guest system. In my case I had increased the ZFS ZVOL size and didn't see any change in the guest and the pvresize would not change it. I ended up booting into SystemRescueCD 4.4.0 and used "parted" with the resizepart command. In CentOS I had parted 3.1, and this command was not available. Looks like parted 3.2 is in SysRescCD now, which worked.

After boot into the sysresc iso, run parted /dev/ and use the following as an example :

resizepart 2 37.6G

Where 2 is the partition number, and desired new larger size was 37.6G.

After that, while I was still in the boot iso, I ran the pvresize and it worked correctly. Reboot into the VM (or your system) and all looked good from there. :) Hope that helps!

0

You have to first extend the partitions size using fdisk or cfdisk. Only after that it becomes available to pvresize.

1
  • 1
    You should provide the command to achieve this. Otherwise, you're telling how something is broken but not offering a solution
    – F1Linux
    Jan 13, 2020 at 9:09
0

I used these commands to achieve extending of LVM partition. The guide below has been written for sda2 drive, so pay attention for it, don't execute commands blindly.

FYI I bumped into the similar problem as OP. Steps 2,3 helped me to make system (lsblk) show the new size of the drive.

  1. Use lsblk -a -o +FSTYPE,LABEL,FSAVAIL,FSUSE%,STATE,UUID to check that system sees full size of your drive.
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT    FSTYPE      LABEL FSAVAIL FSUSE%    
sda                 8:0    0  110G  0 disk                                                
├─sda1              8:1    0    1G  0 part /boot         ext4               754,1M    16%         
└─sda2              8:2    0   59G  0 part               LVM2_member                              
  ├─ro_redos-root 253:0    0 35,6G  0 lvm  /             ext4                 5,4G    79% 
  ├─ro_redos-swap 253:1    0    6G  0 lvm  [SWAP]        swap                             
  └─ro_redos-home 253:2    0 17,4G  0 lvm  /home         ext4                  16G     0% 
sr0                11:0    1 1024M  0 rom                                                 

Additionally you can check raw unused space with parted /dev/sda unit MB print free.

  1. echo 1 > /sys/block/sda/device/rescan

  2. Expand drive (sda in my case) with command parted /dev/sda resizepart 2 100%

*On the place of number "2" specify number of the partition that has lvm flag, which you can see from the response of parted /dev/sda unit MB print free

  1. pvresize /dev/sda2

  2. lvscan

  ACTIVE            '/dev/ro_redos/swap' [5,98 GiB] inherit
  ACTIVE            '/dev/ro_redos/home' [17,39 GiB] inherit
  ACTIVE            '/dev/ro_redos/root' [35,62 GiB] inherit

Additionally you can check the results of pvdisplay.

  1. In the next command substitute name of the partition from the previous step: lvextend -l +100%FREE /dev/ro_redos/root -r
  Size of logical volume ro_redos/root changed from 35,62 GiB (9119 extents) to 85,62 GiB (21919 extents).
  Logical volume ro_redos/root successfully resized.
resize2fs 1.44.6 (5-Mar-2019)
Filesystem at /dev/mapper/ro_redos-root is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 11
The filesystem on /dev/mapper/ro_redos-root is now 22445056 (4k) blocks long.
  1. Check the results with lsblk -a -o +FSTYPE,LABEL,FSAVAIL,FSUSE%,STATE,UUID
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT    FSTYPE      LABEL FSAVAIL FSUSE%
sda                 8:0    0  110G  0 disk                                               
├─sda1              8:1    0    1G  0 part /boot         ext4               754,1M    16%
└─sda2              8:2    0  109G  0 part               LVM2_member                     
  ├─ro_redos-root 253:0    0 85,6G  0 lvm  /             ext4                52,7G    33%
  ├─ro_redos-swap 253:1    0    6G  0 lvm  [SWAP]        swap                            
  └─ro_redos-home 253:2    0 17,4G  0 lvm  /home         ext4                  16G     0%
sr0                11:0    1 1024M  0 rom                                                

As you can see, my sda2 has grown up in SIZE from 59 GB to 109 GB. Now commands df -h and lvs will show new sizes of partitions.

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.