I have a virtual machine that I'm trying to extend from 150GB to 500GB.

$ sudo cfdisk /dev/sda
                         cfdisk (util-linux 2.23.2)

                            Disk Drive: /dev/sda
                     Size: 536870912000 bytes, 536.8 GB
           Heads: 255   Sectors per Track: 63   Cylinders: 65270

   Name        Flags     Part Type  FS Type         [Label]       Size (MB)
                          Pri/Log   Free Space                         1.05*
   sda1        Boot       Primary   xfs                              536.88*
   sda2                   Primary   LVM2_member                   536333.00*

I've run fdisk (https://unix.stackexchange.com/a/134813/173008) to delete and create a new sda2 partition.

I am following this guide (https://unix.stackexchange.com/a/108229/173008), however I am stuck because I can't extend vg0 to use this additional space.

$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/vg0-rootvol  146G  123G   16G  90% /
/dev/sda1                509M  268M  242M  53% /boot

$ sudo pvs
  PV         VG  Fmt  Attr PSize    PFree
  /dev/sda2  vg0 lvm2 a--  <149.50g    0

$ sudo vgs
  VG  #PV #LV #SN Attr   VSize    VFree
  vg0   1   2   0 wz--n- <149.50g    0

$ sudo lvs
  LV      VG  Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  rootvol vg0 -wi-ao---- <147.50g
  swap1   vg0 -wi-ao----    2.00g

The problem is there is no "extra space" on /dev/sda2, and still shows <149.5g, so running the following doesn't work:

$ sudo pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

$ sudo lvextend --size +350G /dev/mapper/vg0-rootvol
  Insufficient free space: 89600 extents needed, but only 0 available

I'm stuck and don't know how to fix this. Any help would be appreciated.

  • What is the output of pvs after the resize operation? Does it show the additional space? – larsks Sep 16 at 11:50
  • It is identical sadly. The pvresize and lvextend don't seem to do anything. – mojo1mojo2 Sep 17 at 5:01
  • Huh, your VG is completely filled. My recollection is that you need some free space in order to perform the resize operation. Let me see if I can verify that... – larsks Sep 17 at 10:51
  • Okay I probably ran this earlier but it was only able to increase by ~10 extents or so (i.e. not a lot). But it is definitely thinking it can only have 150GB when there is now 350GB of unused space that I don't know how to tap. – mojo1mojo2 Sep 18 at 1:55
  • You procedure should have worked. Take a look at /proc/partitions and see if the number of blocks for sda2 correspond to the increased partition size. – Emmanuel Rosa Sep 20 at 8:08

You must extend the volume group before you extend the logical volume, because the logical volume is contained in the volume group.

To perform these operations, you must have the filesystems unmounted. The easiest way to have them unmounted and still be able to work on the system is to run a live linux operating system.

Usually this live system would be on a thumb drive, but because you are using a virtual machine, you can mount an live linux system's ISO file to the virtual machine in the virtual machine's settings, then set the boot priority so it boots from the ISO.

I know Ubuntu and Fedora both offer their installation images as live operating systems, as do many other distributions. You may need to install lvm2 (apt package) so that you have the tools you need.

To extend the volume group, you need to create a new physical partition using your free space that the volume group can extend into.

fdisk /dev/sda/

In the interactive menu, do the following:

n to create a new partition
3 for the third partition
Enter for default first sector
Enter again for default last sector
w to write changes and exit

The prompts may vary from system to system, but essentially you just need a new partition of the desired size. What i showed will use all free space on the disk. Now the partition needs to be made into an LVM partition, or physical volume

pvcreate /dev/sda3

Then, you can extend the physical volume that contains the volume group into the new physical volume, combining the two.

pvextend /dev/vg0 /dev/sda3

Now if you do vgs you should see that the volume group is larger, giving the logical volume space to expand.

lvextend --size +350G /dev/mapper/vg0-rootvol

The logical volume should now be larger.

| improve this answer | |
  • Thanks for the reply. I am booting it in Hyper-V from CD. Sadly I can't create /dev/sda3 saying no free sectors available since /dev/sda2 now takes up 536333MB as shown by my cfdisk command. – mojo1mojo2 Sep 18 at 7:38
  • Try running pvresize /dev/sda2 and vgresize /dev/mapper/vg0 to possibly update them, and try again. If that doesnt work, try resizing /dev/mapper/vg0-swap1 using lvextend. If this works, this means youll your swap space is in the way, between your root volume and the free space, so youll have to delete it, extend your root volume, leaving space for swap, then remake your swap with the same parameters. You dont need swap on a system, but it is good practice. I also usually keep my swap before my partitions or at the very end of the disk for this reason – Mock Sep 18 at 15:42
  • @mojo1mojo2 I am sorry, I forgot to tag you in my response. Any luck on resolving your issue? It would be very helpful to the community if you could post your solution if you find one. – Mock Sep 21 at 3:26
  • Sorry for the slow response @Mock. I tried to pvresize and it still complains about about insufficient space. /dev/sda2 has 350GB allocated but it still thinks it only has 147.5 – mojo1mojo2 Sep 21 at 7:04
  • @mojo1mojo2 then either your swap LV is in the way of the root LV from extending, or all of the free space is at the beginning. My next step would be to see if you can resize the swap LV. If that works, you will need to remove the swap and extend the root LV, then recreate the swap at the end of the volume group. – Mock Sep 21 at 13:33

you wont find any more space in /dev/sda2 because you didn't extend it or create another new partition with the new space .

you should create new /dev/sda3 with the 350GB by the following commands :

fdisk /dev/sda 
n create new  
p primary  partition
                 //then change the partition type to lvm using this :
t to change type 
8e is for lvm 

when finished type w to write and reboot your machine

now , after /dev/sda3 is created you can extend the desired vg with the following command s:

pvcreate /dev/sda3

vgextend vg_xxx /dev/sda3



lvextend -l +350GB /dev/vg_xxx-lv_xxyy

xfs_growfs  /dev/vg_xxx-lv_xxyy


| improve this answer | |
  • I have the complaint that the new primary partition 3 cannot be created in fdisk as insufficient space (I think because sda2 has taken it all). – mojo1mojo2 Sep 21 at 7:06
  • if sda2 is extended partition it will take the old disk blocks, you must remove it and then recreate it and you will notice that you can occupy the whole disk blocks and you can then assign 2 new partitions inside it the first with the same blocks and the second new one with the space you want – Nour Eddin Sep 21 at 7:56
  • can you please share the output of fdisk /dev/sda so i can help you more. – Nour Eddin Sep 21 at 7:57
  • Does the output of cfdisk help up top of my question? Not sure which output you mean. – mojo1mojo2 Sep 21 at 23:22

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.