Logical Volume Manager – LVM





Last Updated on 04/02/2017 by dboth

Managing disk space has always been a significant task for sysadmins. Running out of disk space used to be the start of a long and complex series of tasks to increase the space available to a disk partition. It also required taking the system off-line. This usually involved installing a new hard drive, booting to recovery or single-user mode, creating a partition and a filesystem on the new hard drive, using temporary mountpoints to move the data from the too-small filesystem to the new, larger one, changing the content of the /etc/fstab file to reflect the correct device name for the new partition, and rebooting to remount the new filesystem on the correct mountpoint.

I have to tell you that, when LVM first made its appearance in Fedora Linux, I resisted it rather strongly. My initial reaction was that I did not need this additional layer of abstraction between me and the hard drives. It turns out that I was wrong, and that logical volume management is very useful.

Logical Volume Manager, LVM, allows for very flexible disk space management. It provides features like the ability to add (or remove) disk space to a filesystem while that filesystem is mounted and active and it allows for the collection of multiple physical hard drives and partitions into a single volume group which can then be divided into logical volumes.

Running out of Disk Space in VirtualBox

June 9, 2009 was the first day of release for the new Fedora 11 distribution. I always like to run new distributions in a VirtualBox virtual machine for a few days or weeks to ensure that I will not run into any devastating problems when I start installing it on my production machines.

The next morning, June 10, I started installing Fedora 11 in a new virtual machine on my primary workstation, thinking I had enough disk space allocated to the filesystem in which it was being installed. I did not. About a third of the way through the installation I ran out of space on that filesystem. Fortunately VirtualBox is great software itself. It detected the out of space condition and paused the virtual machine and even displayed an error message indicating the exact cause of the problem.

Adding Disk Space on the Fly

Since most modern distributions use Logical Volume Management, and I had some free space available on the hard drive, I was able to assign additional disk space to the appropriate filesystem on the fly. This means that I did not have to reformat the entire hard drive and reinstall the operating system or even reboot. I simply assigned some of the available space to the appropriate logical volume and resized the filesystem — all while the filesystem was on-line and the running program, VirtualBox was using the filesystem and waiting. I resumed running the virtual machine and the installation continued as if nothing had occurred.

Although this type of problem may never have happened to you, running out of disk space while a critical program is running has happened to many people. And while many programs, especially Windows programs, are not as well written and resilient as VirtualBox, Linux Logical Volume Management made it possible to recover without losing any data and without having to restart the time-consuming installation.

Tips

Over the years I have learned a few things that can make logical volume management even easier than it already is. Hopefully these tips can prove of some value to you.

  1. Use the Extended file systems unless you have a clear reason to use another filesystem. Not all filesystems support resizing but EXT2, 3, and 4 do. The EXT filesystems are also very fast and efficient. In any event, they can be tuned by a knowledgeable sysadmin to meet the needs of most environments if the defaults tuning parameters do not.
  2. Use meaningful volume and volume group names.
  3. Use EXT filesystem labels.

 





Leave a Reply