Partner links

The Benefits of Using Linux Logical Volume Manager

lvm

This is the first of a three-part series, designed to introduce new users to the concept of logical volume management in Linux. To have the others delivered automatically to you, you may subscribe to our RSS feed by clicking on the RSS icon diagonally above this paragraph

Logical Volume Management is a method of partitioning hard disk drives that provides more flexibility in managing storage space than the traditional method of disk partitioning. The Linux version, Logical Volume Manager or LVM, has been a feature of the Linux kernel since about 1999, and was contributed (to the Linux kernel) by Sistina Software, Inc, a company that was later acquired by Redhat.

Other UNIX-like operating systems – AIX, HP-UX, and Sun Solaris – have their own implementation of logical volume management. Until recently, there was no equivalent technology – feature-wise – in the BSD distributions. FreeBSD only recently added experimental support for Zone File System (ZFS), a recent Sun Solaris technology with LVM-like features as a subset of its capability.

In the early days, the installers of all three major distros – Fedora (was Redhat), openSUSE (was known as SUSE at the time), and Mandriva (was known as Mandrake back then) had support for LVM (and RAID). Today, only a handful of distros gives you the ability to configure LVM during installation. Some distros have support for LVM in their server distribution, but not in their desktop edition. We think that LVM is a technology that all distros – desktop or server – should configure by default, especially since it is already a part of the Linux kernel.

Using LVM has many benefits, but we are only going to address the very basic benefit of (using) LVM for the home user in this article. To get a better understanding of the benefits of using LVM, let’s take a brief overview of the traditional method of disk partitioning in Linux.

Using the traditional disk partitioning method, a hard disk may be partitioned into a maximum of four primary partitions. Alternatively, you may create less than four (primary) partitions, and one or more extended partitions, with each extended partition holding as many as 16 logical partitions. For this example, let’s consider the scenario where four primary partitions are created on a computer with a 40 GB hard disk:

  • Primary partition 1 – /var (500 MB)
  • Primary partition 2 – / (the root file system – 1.5 GB)
  • Primary partition 3 – /usr (2 GB)
  • Primary partition 4 – /home (27.5 GB)

Under this partitioning scheme, the sum of the partitions sizes must equal the size of the hard disk, i.e, the free space on the disk must be completely allocated. If not, the unallocated space will be unusable by the system. Now what happens if, for example, you run out of space in /home (partition 3)? There are solutions. You could, for instance, attach a new disk to the system, create a much larger /home partition in the new disk, and copy the contents of the existing /home to the new one. It works, but not very flexible, and a pain to pull off.

Now, let’s consider the same example, using the same 40 GB hard disk with LVM as the partitioning scheme.

To configure LVM, these are the steps involved:

  1. Starting with a hard disk drive, create a physical volume – PV
  2. Create a volume group – VG. A volume group is a virtual container for one or more physical volumes (hard disks)
  3. Add physical volume to volume group. The size of the VG equals the size of the PV, or the sum of the PVs, if more than one
  4. Create logical volumes. A logical volume, LV, is the LVM equivalent of a partition
  5. Assign filesystems to logical volumes

With LVM, it is not necessary to allocate all the available free space to the logical volumes. In fact, it is recommended that you only assign enough space that is needed to each logical volume. So using the 40 GB disk example, and the creating four logical volumes as in the example above, we have:

  • Logical volume 1 – /var (200 MB)
  • Logical volume 2 – / (the root file system – 1 GB)
  • Logical volume 3 – /usr (5 GB)
  • Logical volume 4 – /home (7 GB)

Notice that the sum of the storage space allocated to the logical volumes is less than the size of the VG. The unallocated space is still available and usable by the system. Now, what happens if, for example, you run out of space in logical volume 3, housing /home? This is where LVM shines. All you need to do is allocate more space (resize upwards) to the logical volume by taking some of the VG’s free space. Depending on the file system in use, you may increase the size of a logical volume while it is online or offline. By “online or offline”, we mean that the logical volume may be resized without first unmounting it or after it has been unmounted. Reiserfs and XFS allows online resizing, but Ext3, the default journaling file system in most Linux distros, requires that a logical volume be unmounted before it can be resized.

We should point out that you may also choose to resize downwards or shrink a logical volume. However, this should never need to happen if LVM is well implemented. Shrinking a logical volume is hazardous. It could lead to loss of data. One of the most important points you should remember when configuring LVM is that you should only allocate just enough space to each logical volume, that the system needs to run. You can always increase the size of a logical volume at any time.

Beyond the ability to resize a logical volume, let’s consider a situation where all the free space in the volume group is allocated. What then? Easy. You just attach a new disk (external or internal) to the system, make it a physical volume, assign it to the volume group, and – voila! – you have more free space to use. It’s so easy and so helpful for storage management, it’s difficult to fathom why most Linux desktop distros are shunning it. We do know that some distro developers have no idea what LVM is. It’s hard to believe, but it’s true.

There are more advanced benefits of using LVM that we did not touch in the article, but the ability to dynamically resize a disk partition (logical volume) is one that we think will be of special interest to most new users.

NEXT:
How Linux Distros Configure and Manage LVM

Share:

Facebook
Twitter
Pinterest
LinkedIn

Partner links

Newsletter: Subscribe for updates

Subscribe
Notify of
guest
9 Comments
Inline Feedbacks
View all comments
MOKONOU IV
MOKONOU IV
8 years ago

Thank you very much for all

suresh
11 years ago

can we create more than one extended partition(s) ?. I think that is not possible . please modify this article.source http://en.wikipedia.org/wiki/Disk_partitioning

toughluck
toughluck
11 years ago

Ever had a disk fail on you? I guess not or you’d be cursing LVM to no end.

There’s no redundancy. There are no checks. There is no data protection in place. In short, one disk goes down, VG goes down, and with it, all your data.
At least it used to be that way, but now you can at least recover data that was physically present on undamaged disks. Nevertheless, there’s no data protection.

There’s a reason why LVM is available on server installations. While ordinary Linux distributions are abhorrent to configure for typical server usage at installation time, they usually allow setting up a few things BEFORE you go into LVM configuration.
First of all, you have to set up multipathing. Second, you configure RAID if you have a JBOD attached. Third, you take the whole RAID and set up LVM on top of it.

LVM is designed to be put on an already redundant block device. Yes, there are benefits, including easily resizable partitions, but only if you are aware of the disadvantages.

Please consider the above. LVM is no free lunch.

WTF?!?
WTF?!?
14 years ago

You do know that you don’t have to use LVM to resize partitions, right? The space you call “unusable” isn’t unusable. You can increase your partition sizes at any time (depending on the filesystem) even without LVM.

Zeerman
Zeerman
14 years ago

Thanks.

Had no idea this existed. Strange because I have been using Linux for over two years.

Does LVM has any disadvantages?

Get the latest

On social media

Security distros

Hacker
Linux distros for hacking and pentesting

Crypto mining OS

Bitcoin
Distros for mining bitcoin and other cryptocurrencies

Crypto hardware

MSI GeForce GTX 1070
Installing Nvidia GTX 1070 GPU drivers on Ubuntu

Disk guide

LVM
Beginner's guide to disks & disk partitions in Linux

Bash guide

Bash shell terminal
How to set the PATH variable in Bash
Categories
Archives
9
0
Hya, what do you think? Please comment.x
()
x