Playing with logical volume management – Creating and Managing Single-Instance Filesystems

Share this post on:

Playing with logical volume management

When it comes to filesystems, one of the biggest issues is their inflexibility when it comes to storage. Creating a volume on a disk means the space is locked in for the volume, which also locks in the size of the filesystem. However, Logical Volume Manager (LVM) provides a solution to this problem. LVM is a widely used tool in the field of computer storage management that acts as a layer of abstraction between physical storage devices, such as hard drives or SSDs, and the OS. This enables the flexible and efficient management of storage resources. LVM is especially valuable for Linux systems, as it offers a flexible and scalable storage management solution.

With LVM, administrators can dynamically allocate and resize storage volumes without the need to repartition disks or disrupt the system. This flexibility is particularly useful in environments where storage requirements change frequently or where efficient resource allocation is needed. Additionally, LVM introduces the concept of volume groups, which act as logical containers for physical storage devices. By creating logical volumes within volume groups, administrators can easily allocate and manage storage space, simplifying the management of storage resources in Linux systems and making it easier to organize and utilize storage resources effectively.

With LVM, there are three core components of the storage:

  • Physical volumes (PVs): These are the block-level disk devices that are used for storage. They can be physical disks, virtual disks (such as the MD devices created in the mdadm recipe), or other block-level devices.
  • Volume groups (VGs): These are groups of PVs that are combined into a single logical device. They can be a single device to start with, with new devices added later to add capacity.
  • Logical volumes (LVs): These are logical disks built into the VG. They are used to create filesystems and can be dynamically resized as needed.

LVM, a VG, is a central component that acts as a logical container for one or more PVs. A VG is created by combining physical storage devices, such as hard drives or SSDs, into a single storage pool.

In this recipe, we will show you how to initialize PVs, create a VG, and then add LVs for future use by a filesystem. We will also show some of the basic management commands.

Getting ready

The examples in this recipe will use the /dev/md0 virtual disk created in the mdadm recipe, in addition to a few extra LUNs. The LVM RPMs are normally installed by default with a normal installation.

How to do it…

The first step is to identify what disks we can use. This is done with the lvmdiskscan command:

Figure 4.21 – lvmdiskscan

Here, we can see three devices, md0, sda1, and sda2. We can also see that sda2 is already initialized as a PV. We can use the pvs command to display the PVs on the system:

Figure 4.22 – pvs

Here, we can see that the /dev/sda2 device is used by the ol VG. Let’s go ahead and use pvcreat to initialize /dev/md0. This is done with the following command:


pvcreate /dev/md0

Now that the device is initialized, we can create a VG. This is done with the vgcreate command. The command uses the first parameter as the name of the VG and then a list of devices. In this case, we will only use /dev/md0 to create the DATA VG:


vgcreate DATA /dev/md0

Share this post on:

Leave a Reply

Your email address will not be published. Required fields are marked *