Unless you want the extra flexibility provided by the Logical Volume Manager (LVM), you don't need to use LVM. You can instead just put a filesystem on the AoE or md block device itself.
Using LVM means mastering a few new concepts and the corresponding jargon. We'll cover these concepts and terms below, reviewing them at the end of the section.
The Logical Volume Manager software on systems with a 2.6 Linux kernel is LVM2. In the text below, "LVM" refers to LVM2, because the CLN runs a 2.6 kernel.
LVM uses the kernel's device mapper module to create the block devices you want out of lower level block devices. For example, if you have two SATA+RAID shelves with seven terabytes of storage on each one, you can combine the two 7TB AoE devices into one 14TB block device, where you can create a filesystem for NFS export.
To make a block device ready for use with LVM, we use the pvcreate
command. LVM will write information to the end of the block device.
This "LVM metadata" will completely describe your LVM setup, so you
won't have to store information about your LVM setup on the CLN.
Continuing the example from the previous section, we'll use pvcreate
to create an LVM "physical volume" out of the RAID 1 block device we
just made, /dev/md0.
makki:~# pvcreate /dev/md0 Physical volume "/dev/md0" successfully created
You could, of course, use an AoE device like /dev/etherd/e0.0 as a
physical volume, too. You can make any block device into an LVM
physical volume.
Now we want to create a logical volume that we can grow later. You create logical volumes by allocating "extents" from a collection of LVM physical volumes. The collection is called a "volume group". We now have one such physical volume, the one we just created, so we put it in a volume group called "vg0". You can use a more descriptive name like "accounting" if it's helpful.
makki:~# vgcreate vg0 /dev/md0 Volume group "vg0" successfully created
Now we can use vgdisplay vg0 to examine the characteristics of the
new volume group. Notice the line that says "Free PE / Size"? The
number before the slash is the number of extents in the volume group.
We'll use all the extents to create one logical volume with the
mundane name, "lv0".
makki:~# vgdisplay vg0 | grep Free Free PE / Size 136792 / 534.34 GB makki:~# lvcreate --extents 136792 --name lv0 vg0 Logical volume "lv0" created
There is a new block device ready for us to use, /dev/vg0/lv0.
We'll create a filesystem on it in the section on filesystem creation.
An existing logical volume can grow if there's more space available in its volume group. That space is measured in free extents.
Here is an example, building upon the previous example, where we add a new AoE device to the existing volume group and grow the existing logical volume.
Here's vg0, with no free space available.
makki:~# vgdisplay vg0 | grep Free Free PE / Size 0 / 0
The new AoE device is e0.1. We'll make it into a physical volume
and add it to vg0.
makki:~# aoe-stat
e0.1 536.870GB eth0 up
e1.0 573.749GB eth0 up
e1.1 576.437GB eth0 up
makki:~# pvcreate /dev/etherd/e0.1
Physical volume "/dev/etherd/e0.1" successfully created
makki:~# vgextend vg0 /dev/etherd/e0.1
Volume group "vg0" successfully extended
Now there's free space, so we can extend the old logical volume. Notice that you have to put a plus before the number of extents to add.
makki:~# vgdisplay vg0 | grep Free Free PE / Size 127999 / 500.00 GB makki:~# lvextend --extents +127999 /dev/vg0/lv0 Extending logical volume lv0 to 1.01 TB Logical volume lv0 successfully resized
If you have a filesystem on lv0, note that you have done nothing to
it yet. To LVM, the filesystem itself is just data on the logical
volume. See the section on Growing a Filesystem for
specifics.