Learn LVM on Linux with graphical tools

The LVM, as a storage model, has been widely used on machines with Linux architectures, including PCS, NAS, and servers. Its value is self-evident. As a widely used, mature software, the tutorials of how to use LVM are already all over the internet.

However, these tutorials are all based on command-line tools. The command-line tool, while powerful and complete, is complex and very unintuitive, making it difficult for users to understand LVM, especially for beginners.

Just like partitioning tools, various graphical or semi-graphical (character-based) tools make partitioning easy to read in a very intuitive way. Learning LVM concepts and operations through graphical tools also greatly reduces the cost of user learning.

Let's guide you on the LVM concepts & LVM managing through graphical tools.

CONCEPT

1. LVM

LVM Logical Volume Management is a storage Management solution in Linux. It provides users with an extensible and highly flexible storage Management model. With LVM users can achieve server-level storage performance and security inexpensively.

For common users and small-sized server users, LVM supports RAID 0, 1, 4, 5, 6, 10, and JBOD volumes for creating snapshots and storage pools.

For advanced users, LVM supports highly reliable access and can easily implement distributed storage services.

At the same time, volumes created by LVM can be extended and migrated very easily. Replacing/adding devices is easy.

The LVM model consists of three layers: Physical Volume (PV), Volume Group (VG), and Logical Volume (LV).

2. PV

The PV layer is the physical layer of LVM and the basis of LVM's existence. The PV can be regarded as disk in a RAID array. Users can create PVs using disks or partitions. LVM configuration information is usually stored in each PV. The Linux kernel reads configuration information to detect LVM, and when the LVM is damaged, the repair tool also uses this information to restore the LVM configuration.

LVM overflowThe host devices of PVs

There is only one partition on disk 4, which use entire space

There is no partition table(neither MBR nor GPT) on disk5

2 partitions on disk 6

 

3. VG

VG is the management unit of LVM and is used to configure a group of LVs and PVs.

VG consists of one or more PVs. All PVS that make up a VG can be migrated to another machine without additional configuration. One or more LVs can be created in a VG.

There can be multiple VGs in a system.

The VG consists with disk4/part1, disk5, isk6/part1 & disk6/part2

All PVs belong to a VG are highlighted when the mouse points over a member of the VG for user identification


lvm logic

LVM logical description

 

In the LVM model, VG is responsible for organization and management, LV interacts with users, and PV interacts with storage devices.

4. LV

LV is a volume created based on user requirements. It can be mounted directly. LVM provides users with a wealth of features, ranging from high access performance to high security. We'll cover the various features in more detail later.

VG with 2 LVs, one is simple type, and the other is Stripe/RAID 0 type

5. PE

PE, Physical Extent is a unit of PV space allocation, similar to a disk cluster. The default value is 4MB. Users can set different values as needed.

 

6. LE

LE, Logical Extent is the space allocation unit of an LV. The size of a LE is the same as PE in a VG. When users create LV, the size of LV must be an integer multiple of LE.

 

OPERATIONS

To use LVM, you first need to create, then manage, delete, and so on. Let's explain how to do each of these in turn.

1. PV Operations

1.1. Create PV

PV is the lowest level of LVM, and to use LVM you must start by building PVs.

First, a "clean" system looks something like this.

no lvmDisks without LVM configuration

 

Let's create PVs with /dev/sdd1, /dev/sdf1, /dev/sdf2, /dev/sdf3 & /dev/sde.

Select disk/partition to create PV(s)

 

After the creating operation, four PVs appear in the system. At this time, no VG exists in the system, so the four PVs exist in isolation and are marked as orphan PV in GUI.

The GUI showing PV information when mouse pointer over the /dev/sdf2

 

1.2. Delete PV

Selecting PV OPERATION->Delete on menu, and click the PV user want to delete.

Delete 2 PVs -- /dev/sde & /dev/sdf1

 

Operation completed

 

Here we can see the selected PVs are normal partitions

 

A PV belongs to a VG cannot be deleted. If you want to delete a PV, you must first remove it from the VG. It can only be removed as an orphan PV.

1.3. Change configuration of PV

The configurations that can be modified are different for PVs that are added to VG and orphan PVs. Since there is no metadata in orphan PV, only the copies of metadata, metadata area size, and boot area size can be modified.

Orphan PV, user cannot change allocation flag and tag

 

The PV in VG, user can change allocation flag and tag

 

Operation completed

 

After refreshing, we can found the tags in PV

 

2. VG Operations

2.1. Create VG

Selecting VG Operation->Create, and create VG with all 4 PVs.

Selecting all 4 PVs and specify the size of LE, name of VG. Use can click Advance button to configure advance settings

 

User can specify the tags of VG, maximum PV/LV count and the copies of metadata settings in advanced setting of creating VG dialog.

Advanced setting of creating VG

 

After the VG created we can get the layout.

There are 4 PVs in VG weLeesTestVG. The PVs belong to the same VG will show highlight to prompt user when mouse pointer over any PV.

2.2. Delete VG

Selecting VG OPERATION->Delete

Delete VG dialog

 

Click any PV in VG you want to delete, and then press the Done button to delete the VG. Note That to protect user data, VG with LV cannot be deleted. Users need to delete all LVs in VG before deleting it.

VG deleted, click Close button to refresh information

 

At this point, we can see that the 4 PVs have returned to the status of orphan PVs.

A LVM system without VG

2.3. Remove PV

Let's recovery the VG first.

This operation should have been placed after the appending PV, but I changed the order to reduce the operations.

Choose VG OPERATION->Remove PV

Remove PV dialog

Selecting disk5 and click done button to remove it.

Operation completed

We can see the disk5 is a orphan PV now. It does not belong to VG weLeesTestVG.

The VG with one PV removed

2.4. Append PV

After adding a new device, we need to add it to the existing VG, and then we need to use the appending PV operation.

Let's add the PV removed from the previous operation back to the weLeesTestVG.

First, choose VG OPERATION->Append PV

Append PV dialog

Clicking on disk5 for selecting, and select weLeesTestVG in VG list followed(There is only one VG now, of course)

 

Operation completed

 

The orphan PV returns to the VG now

2.5. Rename VG

The rename operation is easy, selecting VG OPERATION->Rename.

Click the VG we want to rename and type the new name in input box, and click Done button.

CAUTION: The LVM has strict restrictions on VG and LV names. Only a-z, A-z,0-9, and._+ characters can be used.

Operation completed

 

We can see the new name of VG after refreshing.

The VG with new name

2.6. Change VG configuration

The user may need to change the VG configuration usually, which is complicated on the command line but very simple on the GUI. Now let's look at how to change the VG configuration.

Select VG OPERATION->Change

Change VG configuration dialog

If there is no VG selected, all settings are disabled. Now select weLeesVG. The configurations that can be changed include LE/PE dimensions. Allocation policy, number of metadata copies, maximum number of PVs & LVs and tags, and some configuration related to LVM control.

It is easy to change the PE/LE size to a smaller value. However, to change the value to a larger value, you need to check whether the start position of the LV in the VG can be exactly divided by the desired value. If not, you cannot set the value.

2.7. Backup/Restore VG

It's a good habit to back up the VG's configuration, and if something goes wrong, it's much easier to recover with backup data.

Visual LVM has automatic backup function. Users can turn on/off automatic backup function in setting menu. The backup VG configuration information is stored in the backup directory under the Visual LVM installation directory. The backup files are named by operation & time.

Setting menu of Visual LVM, user can enable/disable auto-backup, enable/disable access from specified IPs, change login password and port

Now let's talk about how to manually backing up VG configuration information.

Select VG OPERATION->Backup/Restore

Backup/Restore VG dialog

Select the VG to back up in the list of left side in backup dialog, and specify the directory and name of the backup file on the right. Click the Done button when finished.

Operation completed

 

User can restore VG by