287

As a Linux/Ubuntu newbie, what is LVM and what is it used for?

In terms of a web server installation, what benefits does it provide?

Would you recommend using it?

0

5 Answers 5

265

Benefits

You can think of LVM as "dynamic partitions", meaning that you can create/resize/delete LVM "partitions" (they're called "Logical Volumes" in LVM-speak) from the command line while your Linux system is running: no need to reboot the system to make the kernel aware of the newly-created or resized partitions.

Other nice features that LVM "Logical Volumes" provide are:

  1. If you have more than one hard-disk, Logical Volumes can extend over more than one disk: i.e., they are not limited by the size of one single disk, rather by the total aggregate size.

  2. You can set up "striped" LVs, so that I/O can be distributed to all disks hosting the LV in parallel. (Similar to RAID-0, but a bit easier to set-up.)

  3. You can create a (read-only) snapshot of any LV. You can revert the original LV to the snapshot at a later time, or delete the snapshot if you no longer need it. This is handy for server backups for instance (you cannot stop all your applications from writing, so you create a snapshot and backup the snapshot LV), but can also be used to provide a "safety net" before a critical system upgrade (clone the root partition, upgrade, revert if something went wrong).

While being most useful on server systems, I think that features 1. and 3., combined with LVM's ability to create/resize/delete LVs on the fly, are quite handy on desktop systems as well. (Especially if you experiment a lot with the system.)

Downsides

Of course, all of this comes at a price: the initial setup of LVM is more complex than just partitioning a disk, and you will definitely need to understand the LVM terminology and model (Logical Volumes, Physical Volumes, Volume Groups) before you can start using it. (Once it is set up, using it is much easier, though.)

Also, if you use LVM across hard drives, you may lose all your data when only one drive fails.

Recommended reading

2
  • With LVM2 you can also set up writeable snapshots too!
    – Flimm
    Nov 26, 2012 at 18:51
  • 6
    Basically, LVM takes complicated things and makes them possible, but takes already possible things and makes them more complicated.
    – mwfearnley
    Feb 14, 2020 at 16:03
32

I know that this thread is old and that the OP has a lot better understanding of this, but I came across this thread whilst looking up something with LVM and thought I'd put my 2c in.

The short answer is that increasing the size of a partition on the disk is a pain.


I have an AWS (EC2) server I use for backups (using rsnapshot). As I start backing up more servers or the data changes more frequently I need more space.

My backup drive is currently a 250GB EBS volume that is now completely full and I want to increase it to 350GB in size, so I went to the AWS control panel, created a snapshot of the drive, created a new EBS volume from the snapshot and attached it. I now have a 250GB EXT4 partition full of data on a 350GB drive. I want to tell Ubuntu to use the larger space but I can't use resize2fs to increase the partition size and fdisk doesn't let me change the partition size either. Instead it only lets me delete the partition, create a new one at the larger size and then I have to Rsync the files across with the correct command line to also copy hardlinks.

That's a lot of work, so I recently set it up using LVM and now I can take the new, larger EBS disk and easily increase the LVM volume on it, then a quick resize2fs to tell the EXT4 filesystem that it's got some new space and bam, problem solved without having to copy hundreds of gigabytes of data. LVM is a saviour. Alternatively I could just mount another EBS volume extend the LVM to that and now it's spread over multiple disks but it's seen as only one partition, sweet!

0
16

The main benefit from using LVM is if you have more than one harddrive. With LVM you can group the hardrives into one huge one. Also you can add more space to this group if you add more harddrives.

With LVM you can simple work like you have only one single huge harddrive. Despite that LVM supports a lot expert features.

7

What kind of applications or content are you planning to host ? If it is a personal server or something for a small organization, you probably can get by without using LVM.

LVMs are useful if you need partitions etc across multiple disks. I doubt you would need it, given that you're asking here regarding it :)

3
  • 1
    Yes it's just a personal server, so it sounds like I won't be needing it. Thanks. Sep 4, 2010 at 14:53
  • Late, but still. LVM are useful in situations when you need to create/resize/remove partitions while the machine is running with programs that uses the partitions. So yes, if you have a situation when you have installer on more than one partition, you should have a look att LVM. It isn't that hard to understand actually. Volume group are same has a hard disk. Logical volume are the same as a partition and Physical volumes are the partitions that you build the Volume group on.
    – Anders
    Apr 14, 2016 at 15:40
  • LVM adds a lot of complexity. I left it enabled by default on my small server and now have a confusing situation with all these logical volumes not being set up the way I want, and now I have to go research how to fix this... or just start fresh without LVM (I understand basic partition tables).
    – sudo
    Aug 7, 2017 at 23:45
7

Without answering your question directly (which the other posters already did), there is an easy answer about whether or not you need LVM: If you don't know some feature during installation in detail, leave it at its default setting. The default configuration will be fine for most users (including me and probably you). :)

4
  • 19
    Really self-defeating and destructive logic. People need to learn what's possible so they can decide what they need.
    – user92125
    Nov 28, 2015 at 19:34
  • 13
    @TomDworzanski Actually, this post has merit. There is a principal called "the last responsible moment". There is far too much information in this world to focus carefully on most choices. If you have never had a problem that LVM solves - then it makes sense to ignore it until you do.
    – SteveJ
    Mar 29, 2016 at 14:48
  • 10
    @SteveJ I had a problem LVM solved but wasn't able to solve it well until I knew LVM existed. Sometimes you need to survey what's out there which is what OP is clearly doing. There was probably a time you did the same. Besides, we're not talking about all the information in the world ... we're talking about mainstream Linux distribution installers with a small set of questions some smart people thought were important enough to ask every user.
    – user92125
    Mar 29, 2016 at 15:06
  • 2
    With Ubuntu, it's enabled by default. I didn't know what it was and left it enabled. I wish I could go back.
    – sudo
    Aug 7, 2017 at 23:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .