Citrix Xenserver – Expanding Local Storage

Twice now, I have had the (dis)pleasure of expanding our local storage on a couple of XenServer boxes.  In a nutshell, here is how it works:

1.  Expand physical disk (add more RAID members, ect).  Use the procedure specific to your RAID card.

2.  Use fdisk to expand the partition your Local Storage resides on:

[root@vps1a ~]# pvscan
PV /dev/sda3 VG VG_XenStorage-4c69467e-0352-5bd4-3dee-e17cc18aee08 lvm2 [923.64 GB / 380.14 GB free]
Total: 1 [923.64 GB] / in use: 1 [923.64 GB] / in no VG: 0 [0 ]

Note the bold type to the left, /dev/sda3 is the partition we want to expand by deleting and re-adding to the maximum size in fdisk.  After you do this, you need to reboot so the OS will recognize the larger partition.  The bold type to the right is the UUID we need later.

3.  After rebooting, now we can expand the physical LVM volume:

pvresize /dev/sda3

4.  Now we tell XenServer that we increased the size, so you can actually use your extra space:

xe sr-scan uuid=4c69467e-0352-5bd4-3dee-e17cc18aee08

Note:  The UUID was discovered in step 2.

5.  All done!

Notes:  Rebooting the XenServer host is a real pain.  It can be avoided by adding your extra space as a separate partition or disk, then using vgextend to join the LVM physical volumes, instead of fdisk to expand an existing partition.  Using the vgextend method at step 2, you don’t have to reboot, but you lose the redundancy of having RAID5 or RAID10 backing your whole volume.

12 Responses to Citrix Xenserver – Expanding Local Storage

  1. Felix says:

    How do I extend the partition size using FDISK without loosing the data in the partition?
    Thanks

    Note the bold type to the left, /dev/sda3 is the partition we want to expand by deleting and re-adding to the maximum size in fdisk.

  2. Randy says:

    delete the partition, then create a new one up to the maximum size. Just make sure the starting cylinder and partition type is the same and you won’t lose your data.

  3. Felix says:

    Thanks – I am it worked.

  4. Marc says:

    Hmm can you explain witch commands I need to use to first delete the partition and then create e new one with the same cylinder and partition type?

    Thanks for you help!

  5. Randy says:

    They are not ‘commands’ it is all done in fdisk. Use the ‘h’ option (help) for assistance with listing, deleting, and creating partitions.

  6. Marc says:

    So first I need to delete the /dev/sda3 partition.
    And then I need to make a new partition on /dev/sda3 with the maximum of space and an lvm exetsion with the same cylinders?

    Disk /dev/sda3: 991.7 GB, 991787811840 bytes
    255 heads, 63 sectors/track, 120578 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Thats our /dev/sda3 right now.

  7. Foo says:

    After delete and re-add the partition, all you need to do is:

    pvresize /dev/sda3

    That expands the existing PV to fill the whole partition.

  8. Christian says:

    Hallo @ all and thanks für the good manual, but I have a problem by resize my ext-base storage repository.

    After expanding the Partition with fdisk and do an pvresize (pvs show now the right new size), I can´t tell the XenServer to see ans use the whole space. sr-scan don’t seem to work. It is an ext-basse vhd storage repository. xe sr-param-list displays the old size 🙁

    Does anybody know what I do wrong and how to expand the sr? Please help me. Thanks

  9. Dominik says:

    Good article, I had some issues as I was using a GPT Table, so fdisk would not work with that. Got it working using this article.

    http://thingsandstuff.devide.ch/?p=72

  10. XenServer defaulted to GTP (GUID Partition Table) In this case use gdisk instead of fdisk which is also installed. (parted is not installed) In my case I noticed that the default starting sector for the partition when recreating it was not correct as there was a little bit of space between the second (backup partition) and the third (local storage).

  11. One more thing, the GTP table has a redundant partition table at the end of the disk which needs to be moved back to the end before extending the partition. This is done in gdisk in the x menu with the e command.

  12. Ben says:

    Tried this in a lab, deleting and recreating the partition on the Local Storage wiped out the server and required reloading.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Anti-Spam Quiz: