Suso Logo suso
Support Site
main site     webmail    

Linux has a feature called Logical Volume Management (LVM) that allows you to resize partition sizes and expand partitions across multiple disks among other features. Your virtual machine comes with all the partitions except for the root partition setup using LVM. To allow you to have the most flexibility, we have started each partition as small as we could to allow you to do what you want with the extra space given to you. So its important that you understand how to use LVM commands so that you can fully utilize the full disk space that you have been allocated.

Contents

Physical volumes, Volume Groups and Logical Volumes, oh my!

There are a jungle of terms out there, but it really doesn't have to be that confusing.

  • Physical Volumes - A physical volume is a disk that has been allocated for use in LVM.
  • Volume Group - A volume group consists of one or more physical volumes clustered together.
  • Logical Volume - This is the actual volume that a filesystem resides on.

We have already setup all this for you, the only thing that you need to concern yourself with for now is how to resize logical volumes and resize the filesystem on it to fit.


Extending a logical volume and the filesystem

This is a simple task, just run the following as root, which will extend the logical volume known as 'home' by 512 megabytes.

lvextend -L+512M /dev/CustVG/home

Note: The name of the logical volume is not directly tied to the disk partition that it is used for. Most of the time it will be though and we do so because it is convenient. But for partitions like /var/log and /var/lib, the logical volume names are var_log and var_lib respectively.

Now expand the filesystem to fit the new size of the logical volume. This next step will depend on what type of filesystems your VM has. Older VMs used reiserfs and newer ones use ext3. Run the df -T command in order to see what kind you have. The type is listed in the second column of the output.

ext3 filesystems

If you are using ext3 filesystems on your VM, then run the following command to expand the filesystem to the new size.

resize2fs /dev/CustVG/home

reiserfs filesystems

We are using reiserfs filesystems because they are fast and flexible for the purpose of Xen virtual machines.

resize_reiserfs /dev/CustVG/home

Both of these commands will resize the filesystem while it is still mounted, so there is no need to unmount the filesystem or restart your virtual machine.

That is just about all you need to know about LVM to get started with your virtual machine. You can keep an eye on how much disk space is being used by running the following command:

df -h

You don't need the -h option, but it makes it more readable.

External links

Here are some links to more information about LVM2 for Linux.