Xenserver and adding/attaching a new storage to a VM – sathyasays.com
This page looks best with JavaScript enabled

Xenserver and adding/attaching a new storage to a VM

 ·   ·  β˜• 2 min read  ·  ✍️ Sathyajith Bhat · πŸ‘€... views

I had an instance today where a local VM(which is provisioned by Xenserver) was running low on disk space and wanted to increase the disk space allocated to it. Last time when I did it by increasing the space from within Xen Manager, I failed miserably(the VM was configured with LVM and neither pvscan or lvscan was able to see the increased space).

This time I tried a different approach:

  • rather than increasing the space of the attached disk, I created a new disk and attach it to the VM from Xenserver Management Console
  • Since the VM is configured with LVM, I decided to add the new disk as a Physical Volume(PV) and then extend the Logical Volume(LV) & Volume Group(VG)

Creating a new disk and attaching it to the VM from Xenserver management Console is fairly straightforward. First make note of the device to which the new disk is attached to. In this case, it is assumed to be xvdc. I’m also assuming that the volume group mesa-nl-vg exists and /dev/mapper/mesa-nl-vg-root is the logical volume path

Here’s the steps ahead

  • Create new partition

    sudo fdisk /dev/xvdc
  • Create a new PV

    sudo pvcreate /dev/xvdc1
  • Extend the VG

    sudo vgextend mesa-nl-vg /dev/xvdc1
  • Extend LV. Note that the +100G indicates the size by which it should be increased

    sudo lvextend -L+100G /dev/mapper/mesa--nl--vg-root
  • Resize the filesystem

    sudo resize2fs /dev/mapper/mesa--nl--vg-root

HowToGeek has a nice writeup & cheatsheet on LVM, you should read that to get you up to speed with LVM.

Share on

Sathyajith Bhat
Sathyajith Bhat
Author, AWS Container Hero and DevOps Specialist

What's on this Page