Finally Getting LVM
I've used LVM – Linux's "Logical Volume Manager" – before. Intuitively it makes sense, and is almost-magically awesome: you can take a bunch of separate disks, and represent them as one big disk! Not only that, you can later add more disks to make an even bigger virtual disk, completely transparently.
Previously all I've done is follow some instructions and type out a
few commands. Actually understanding what I was doing beyond the
rough concepts was a different thing. The commands, and there are
plenty, have names like pvcreate
and lvconvert
, which were
completely unfamiliar and after a short search which got bogged down
in terminology, I moved on.
The third time I resolved to actually dig in just a bit more, and happily the terminology at least now makes more sense! The key for me was the high-level hierarchy, and secondly the similar structure of the commands (once the intuitive concepts made a bit more sense).
-
Physical Volumes: These are the disks themselves1. Commands all use the
pv
prefix. -
Volume Groups: These create a storage pool out of the physical volumes; every virtual disk is drawn from a single volume group. Commands all use the
vg
prefix. -
Logical Volumes: These are the "virtual disks" that you mount as a single block device. This is what gets mounted in the server's file system. Commands all use the
lv
prefix.
Simple operations
This isn't intended to be a tutorial, but once I had absorbed the high-level concepts, there's a certain uniformity to the commands and they become less mysterious. Check the man pages or an actual tutorial for the necessary options.
Creating: pvcreate
creates (registers?) a physical volume;
vgcreate
creates a volume group; lvcreate
creates your logical
volume.
Listing: In a nod to ls
— pvs
to list physical volumes;
vgs
2
Extending: You may also be interested later in adding more storage.
This will involve vgextend
to add another physical volume to your
logical volume, then lvextend
to increase the size of the logical
volume.
Questions I still have
The main thing I don't understand is where the metadata exists: how
does LVM retain information about what groups, etc it has? I suspect
it is in the /dev
file system, but I'm guessing beyond that.
I suspect there has been some changes in either convention or
operation. When you create a logical volume lv1
in a volume group
vg00
, it seems it can be accessed at either /dev/mapper/vg00-lv1
or /dev/vg00/lv1
. In fact in the system I just tested, both were
symlinks to (for me) /dev/dm-1
.