When doing a standard Linux installation on a XenServer virtual machine, the installation process typically allocates all of the available virtual disk space to the Linux file system and swap partitions. The size of the virtual disk can easily be changed using the XenCenter utility, but as neither the partition table or the file systems themselves are modified by XenCenter, the guest system does not see the new virtual disk size. This article describes how to safely change the partitions.
When doing a standard Linux installation on a XenServer virtual machine, the installation process typically allocates all of the available virtual disk space to the Linux file system and swap partitions. The size of the virtual disk can easily be changed using the XenCenter utility, but as neither the partition table or the file systems themselves are modified by XenCenter, the guest system does not see the new virtual disk size.
This article describes how to safely change the partitions.
There are two scenarios:
- the Linux system uses standard Linux partitions
- the Linux system uses Logical Volume Manager (LVM) partitions
The file system sits on top of a single block of data storage, such as a piece of the harddisk or, in the case of a XenServer virtual machine, a virtual block device. It can only be as large as this storage block, but not larger. Therefore, if the file system is to be increased, this storage block must be increased first.
After the size of the storage block has been increased, execute the
resize2fs command, which can be safely run even on a mounted filesystem.
It is very simple to increase the size of the underlying storage block if you are using LVM (and this is a good reason to always use LVM). Just add more blocks to it using the
The blocks added to the storage block are taken from the current volume group. If the volume group does not have free block, new blocks must be made available by adding a new physical device such as a second harddisk, or by increasing an existing physical device.
Provide more disk space to the guest system
There are two ways to do this: you could either increase the size of the existing XenServer virtual disk, or add a second virtual disk to this guest.
Add a physical device
Increase the size of an existing XenServer virtual device
The XenCenter administration software provides a dialog to change the size of the XenServer virtual disk. Select the new storage size by entering the value in the dialog. The virtual disk will be resized to the new value. When increasing the size, the data on the disk is preserved.
Note: do not decrease the size without decreasing the file system first. Otherwise the file system will be damaged.
Increasing the size of the XenServer virtual disk size does not change the filesystem on that disk. So the new disk space is not yet visible to the user. To use the new disk space, the partition table must be modified (which makes the new device size known to the file system) and the file system must be extended (to use the extra space).
The easiest way to do this is delete the last partition and create it again which will then use all of the remaining disk space by default. Obviously, this will work only if the last partition is in fact the partition that is to be increased.
In the example below, the XenServer virtual disk size has been resized from 10 GByte to 50 GByte. The following steps will be performed with
- print old partitions
- delete last partition (#2)
- create new partition using default settings (use the whole virtual disk for this partition)
- set partition type to LVM
- print partitions settings again, note increased size for partition #2
Tell LVM of the new resized physical volume
The partition #2 has now successfully increased in size, now let LVM use the new blocks. Note how the "Free PE" value increases after the
Resize logical volume
The next step is to add those new blocks to the logical volume. The volume group now has an extra 10240 free extents (each 4 KByte in size). New storage can be added to a logical volume with the
Resize file system
The last step is to resize the file system. This can be done even when the file system is currently in use. However, a reboot is recommended as massive changes have been made to the file system. During reboot, a file system check is executed which will print out a scary warning message but that's normal. The system will reboot again and this time no messages or warnings should be sent.