- You now know how to work with partitions and filesystems.
Let's talk about the Logical Volume Manager.
The purpose of the Logical Volume Manager
or LVM is to add flexibility to the storage layer.
An LVM has many features that don't exist on partitions.
You can easily resize it.
You can make snapshots for more reliable backups.
You can do software RAID so that you can easily deal
with a situation where one device is failing.
You can use thin provisioning, where it looks
as if you have a lot of storage, but really you don't,
it's just used in a more efficient way.
And you can use multi-device, multiple devices
in one LVM logical volume to make it real big, for instance.
A logical volume behaves like any block device.
So once you have created your logical volume on top of that,
any filesystem can be created.
In order to work with a LVM,
it makes sense to understand a little bit
about the architecture.
It's a three-layer architecture.
It starts with the physical volume or the pv,
which represent the block devices.
So every block device in LVM is known as a physical volume.
Then there is the volume group or vg,
which represents all of the available storage.
And the nice thing about the volume group
is that it's really an abstraction of all the storage
that is available and that is where you are working from
and from which you are creating the logical volumes.
These logical volumes are created as logical block devices
from the volume group and formatted with any filesystem.
And that's what you need to keep in mind.
While working with LVM, you work on the logical volumes.
You don't work on the physical volumes anymore.
Let me make a drawing so that we can visualize this.
So if you want to understand what LVM is all about,
then we should really start from the volume group.
Because the volume group is the abstraction
of all the storage that you have,
it's something that is resizable,
and at the lower end, you can add physical volumes, the pvs.
These pvs are your discs or your partitions
or whatever, your block devices, basically.
So any block device can be added as a physical volume.
On the top end of LVM,
you are going to extract logical volumes
from the volume group.
And these logical volumes also behave
like the block devices.
So on the logical volume, you are going to use your mkfs,
and that is what you are going to mount.
And that is how LVM is organized.
Now the nice thing about it
is that if you run out of a disk space
in a filesystem, then you can easily add more disk space
from the volume group
if the volume group
does have additional disc space available,
and if it doesn't have any disk space available,
well, you can extend it
by just adding another pv to the volume group.
And that's the dynamic of LVM and that's why people like it.