I have a VM running on my XEN host which goes low on diskspace. It has mounted its volume as /dev/xvda2 formatted with a ext4 filesystem.

This is my xen config for the VM:

# /etc/xen/vm04.experimental.cfg

kernel      = '/boot/vmlinuz-4.9.0-11-amd64'
extra       = 'elevator=noop'
ramdisk     = '/boot/initrd.img-4.9.0-11-amd64'
root        = '/dev/xvda2 ro'
disk        = [

# lvdisplay /dev/vg0/vm04.experimental-disk
  --- Logical volume ---
  LV Path                /dev/vg0/vm04.experimental-disk
  LV Name                vm04.experimental-disk
  VG Name                vg0
  LV Status              available
  # open                 1
  LV Size                60,00 GiB
  Current LE             15360
  Segments               5
  Allocation             inherit

there is still 44GB space left on my volumegroup vg0:

# vgdisplay
  --- Volume group ---
  VG Name               vg0
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  36766
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                27
  Open LV               22
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               1,07 TiB
  PE Size               4,00 MiB
  Total PE              281534
  Alloc PE / Size       270080 / 1,03 TiB
  Free  PE / Size       11454 / 44,74 GiB

How do I allocate the remaining space to my vm04?

2 Answers 2


The proper format for lvextend is:

lvextend -L +40G /dev/vg0/vm04.experimental-disk

For instructions how to extend the partition in the VM itself use this manual.

The partition must first be resized. If you're using LVM, it's easy, and you presumably know how to proceed. If you're using classic partitions, it's a bit more complicated, and may require a reboot (though you never have to boot another system or live CD).

This is how I do it: Use fdisk to first delete the partition (the idea is that the data on disk will be preserved), then carefully recreate it with a larger size at the same position.

Again, it is critical that the new partition starts at the same block as the old. The Id should also match (83 for Linux systems). Be prepared to lose all your data at the slightest typo.

To be on the safe side, you may also restore the boot flag (which according to Wikipedia is still required on some computers) by pressing a.

See the comment section for what to do if your swap partition is in the way.

By now it should be apparent why people recommend using a live CD. ;-) As fdisk helpfully reminds you, you must reload the partition table before proceeding. The safest way is to simply reboot; but you can also use partprobe or kpartx (more information).

Once the partition is resized and the partition table reloaded, it's a simple matter of running resize2fs on the file system, and you can do this even when it's mounted as the root partition.

$ sudo resize2fs /dev/sda1
  • @rubo77, check my edited answer Commented Jan 4, 2020 at 6:01
  • 1
    note that if you're resizing an xfs disk rather than ext, use xfs_growfs instead of resize2fs.
    – steev
    Commented Dec 9, 2022 at 21:48
  1. shutdown the volume with:

    xen shutdown vm04.experimental
  2. delete all snapshots of the volume:

    lvchange -an /dev/vg0/snap-tmp-vm04.experimental-disk    
    lvremove /dev/vg0/snap-tmp-vm04.experimental-disk
  3. resize the volume, for example extend 40GB with:

    lvextend -L +40G /dev/vg0/vm04.experimental-disk

    Now the VM has the larger size of 100GB allocated, but internally it still only has 60GB disk

  4. resize the filesystem

    resize2fs /dev/vg0/vm04.experimental-disk

    see Why do I need to do resize2fs after lvextend?
    (Eventually you have to call e2fsck -f /dev/vg0/vm04.experimental-disk beforehand)

  5. start the VM again:

    xen create /etc/xen/vm04.experimental.cfg

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .