Managing Virtual Disks

Virtual Disks on Xen and KVM

Cloudmin currently only supports management of virtual disk images for Xen and KVM systems, as other virtualization types use a directory on the host filesystem to store files instead of images.

Each open source Xen system has one or more files or devices on the host system (like /xen/mysystem.img mapped to devices on the virtual system (like /dev/sda1). The disks on the host can be regular files, LVM logical volumes, or actual disk partitions. In the virtual system, these are typically mapped to partitions, but can be an entire disk.

When Cloudmin creates a new Xen system, it will also build at least one virtual disk whose contents are a copy of the selected system image. If you select to enable swap as well, another disk will be created for the swap file. These will be mapped to /dev/sda1 and /dev/sda2 on the virtual system respectively.

For KVM, files or devices on the host system (like /kvm/mysystem.img) are mapped to entire disks on the virtual system (like /dev/hda). This disk image then contains one or more partitions, which can be mounted as filesystems on the virtual machine, or used for LVM or RAID.

When Cloudmin creates a new KVM system, it will create a disk image typically with a single partition. This is then mounted as the root filesystem on the virtual machine. In some cases, there may be an additional partition that is used for the /boot filesystem.

Citrix Xen virtual systems also use whole-disk images, on which Cloudmin creates partitions. However, the underlying storage is managed entirely by the Citrix Xen API, so you never need to select a filename or LVM volume group for a new disk.

Expanding a Virtual Disk

The most common operation to perform on a disk image is expanding it when the filesystem is full. The steps to do this are :

  1. Login to Cloudmin, and select the system from the left menu.
  2. If the system is running, shut it down. A virtual system's filesystem cannot be modified while it is running, unless it is a non-root filesystem that is not currently in use.
  3. Go to Resources -> Manage Disks .
  4. Click on the appropriate disk, which is typically mapped to SCSI device A partition 1 for the root filesystem.
  5. Increase the Disk file size , then click Save.
  6. After the resize is complete, start the system up again if needed.

This process is identical for disk images stored in regular files or logical volumes. In both cases, the size increase will fail if the underlying host filesystem or volume group does not have enough free space.

This same procedure can be used to shrink a disk, assuming that the filesystem on is not using more space than the new disk size. However, Citrix Xen does not support the shrinking of disk images.

For KVM and Citrix Xen whole-disk images, expansion of a disk is only possible if there is a single partition or if the final partition contains the filesystem being expanded.

Unsafe Disk Resizes

Cloudmin attempts to work out what filesystem is on a virtual disk by looking at the /etc/fstab file on the virtual system. It then uses this information to properly expand the filesystem.

However, if the filesystem type cannot be worked out then Cloudmin will warn you about possible data loss before resizing a disk. After expanding a disk you will need to login to the virtual system and possibly expand partitions and filesystems on the disk, or create a new partition in the empty space. Disks used for RAID, LVM or by un-supported operating systems like Windows or BSD cannot have their filesystems expanded by Cloudmin.

Scheduled Disk Expansion

Because expanding the size of a disk typically requires a virtual system be shut down, you may want to schedule this for a time when the system is not being heavily used, like 3 AM. This can be done as follows :

  1. Login to Cloudmin, and select the system from the left menu.
  2. Go to Resources -> Manage Disks .
  3. Click on the appropriate disk, which is typically mapped to SCSI device A partition 1 for the root filesystem.
  4. In the Scheduled disk resize section, enter a new size and select a time for it to take effect - the default is 3 AM tomorrow morning.
  5. Click the Add Scheduled Change button.

When the selected time arrives, the system will be shut down if needed, the selected disk resized, and then the system started up again. Only one scheduled change can be created at a time for each disk on each system. Once created, a change can be cancelled before it takes effect on the same page.

Creating a Virtual Disk

You might want to add a disk to a system for use as virtual memory, or to move some files onto. The steps to do this are :

  1. Login to Cloudmin, and select the system from the left menu. It does not have to be shut down.
  2. Go to Resources -> Manage Disks , and click on Create a new virtual disk.
  3. In general, the disk file and device fields will be automatically filled in with reasonable defaults. All you need to enter is the New disk file size.
  4. To have Cloudmin create a filesystem on the disk, select it from the Filesystem to create menu. You can also choose to mount it somewhere on the virtual system by entering a path in the Mount new disk as field.
  5. Click the Create button.

A reboot of the virtual system will be needed before the new disk is available.

Deleting Virtual Disks

If a virtual system no longer needs a disk, you can remove it as follows. All data on the disk will be lost though! Removal of the disk for the system's root filesystem is not possible.

  1. Login to Cloudmin, and select the system from the left menu.
  2. If the system is running, either shut it down or kill any processes on the system using the disk.
  3. Go to Resources -> Manage Disks , and click on the disk.
  4. Click the Delete button.

Moving Virtual Disks

Cloudmin versions 7.1 and above allow you to move existing virtual disks on Xen and KVM systems to a new storage location. This is typically used to move a disk from a regular file to an LVM logical volume, or vice versa. However, you can also move disks between directories or onto an iSCSI server.

To move a disk, follow these steps :

  1. Shut down the system, if it is up
  2. Go to Resources -> Manage Disks , and click on the disk.
  3. In the Move disk form, select either a new storage location or a disk image directory.
  4. Click the Move button, and wait for the move to complete.

Additional disk image directories can be defined at System Storage -> Disk Image Directories. All volume groups on the host system will be available as storage locations that can be selected when moving a disk.

OpenVZ Disk Limits

OpenVZ virtual systems can limit disk usage in a different way - instead of using fixed-size virtual disks, each system can have an optional limit on the amount of disk space its filesystem can consume. This can be set on the Create New System page in the Resource limit options section, or modified later on the Resource Limits page.

Virtual Disks and System Owners

Account plans can be used to define a total disk limit for system owners, which applies to the sum of all disks on all systems belonging to the owner. For example, if an owner has a limit of 10GB of disk he could create a virtual system with two 3GB disks, and other with 1 2GB disk.

For OpenVZ systems, the disk space limit is counted towards the owner's total disk space. If an owner has a disk limit, he will not be allowed to create an OpenVZ system without a limit.