OPS245 Lab 5: Difference between revisions
Line 30: | Line 30: | ||
In this example there are two drives (one 3GB and the other 1GB in size). They are both added to the LVM storage pool (called a volume group). Then two logical volumes are created using the space available in the volume group (one 1GB and the other 4GB in size). | In this example there are two drives (one 3GB and the other 1GB in size). They are both added to the LVM storage pool (called a volume group). Then two logical volumes are created using the space available in the volume group (one 1GB and the other 4GB in size). | ||
Note that this kind of setup would be impossible to | Note that this kind of setup would be impossible to create with traditional partitioning. Since a partition must fit on one drive: you couldn't have a 4GB partition in this case. | ||
== Basic commands == | == Basic commands == |
Revision as of 16:45, 3 March 2023
THIS LAB IS NOT READY YET!!!
LVM Overview
A fixed partitioning setup works fine in many scenarios, but it lacks a lot of flexibility. Using LVM we can avoid the slow and complicated process you've seen in the previous lab, when we tried to extend the size of a partition.
Here's a comparison of how a physical storage device is used in the traditional setup (the one we've worked with in lab 4) and in LVM:
Traditional partitioning | LVM |
---|---|
|
|
Effectively a logical volume is equivalent to a partition, but it is not expected to be fixed in size, and it is not stuck on any specific hardware storage device.
Here's a graphical overview of how storage is managed in an LVM system:
In this example there are two drives (one 3GB and the other 1GB in size). They are both added to the LVM storage pool (called a volume group). Then two logical volumes are created using the space available in the volume group (one 1GB and the other 4GB in size).
Note that this kind of setup would be impossible to create with traditional partitioning. Since a partition must fit on one drive: you couldn't have a 4GB partition in this case.
Basic commands
If you followed the installation instructions from Lab 1: your server2 will be using LVM. Run the following commands on server2:
vgs
lists the volume groups on your system. You will likely never see more than one volume group on one machine. It shows you:- The volume group name (you'll need it for some commands).
- The volume group size (the sum of the sizes of the physical volumes in this volume group).
- The amount of space in the volume group which has not been allocated to any logical volumes.
pvs
lists the physical volumes on your system. It shows:- The device name of the physical volume. Note that it doesn't have to be an entire drive, it can be a partition. On server2 most of your 10GB drive is allocated to a partition (sda5) which is used as a physical volume.
- The volume group this physical volume is part of.
- The size of the physical volume.
- The amount of the space on this physical volume which is not allocated to any logical volumes.
lvs
lists the logical volumes on your system. It shows:- The name of the logical volume.
- The volume group this logical volume is on.
- The size of this logical volume.
- It does not show how much space is used on this logical volume, you'll need to run the
df -h
command to see that.
df -h
does the same thing in an LVM system as in any other system, it shows you which devices you have mounted where and how much space is used on those devices. The device filenames for your logical volumes are in /dev/mapper and their names are a combination of:- The name of the volume group, and
- The name of the logical volume.
- You can also use other familiar commands like
blkid
andlsblk
.