Hodgepodge 3xNAS Part 13 LVM

Published on June 6, 2023 at 9:36 am by LEW


Our last stop before moving on to actual physical hardware is the Logical Volume Manager or LVM. Anyone who has used Linux on a regular basis has probably heard of this application.

LVM has existed on one form or another for a long time. The current code base traces its roots back to the late 1990s and HP-UX. IBM also used a similar application in their earlier UNIX implantation.

LVM is a veteran application for disk pooling and volume management. And while there are some compelling reasons to use it, there are also a few valid reasons not too.

What is LVM

LVM is an abstraction layer that uses the kernel device mapper. Sitting between the user and their disk array, the LVM abstraction layer allows multiple disks to be viewed as a single larger disk. LVM also allows for additional drives to be added to the array.

LVM Overview Diagram

Advantages: LVM provides functionality for resizing volumes to meet changing storage needs, and making more efficient use of available storage.

LVM has a snapshot function which can be helpful with failure restoration.

LVM allows setting up of a drive array with drives of different sizes. In addition, new drives can be added to an existing array to increase storage space.

Disadvantages: LVM adds an addition layer of abstraction, increased complexity, and reducing performance. The performance issue is really only noticeable on older hardware.

LVM has no fault tolerance. While this is the same for normal drive usage, other pooling solutions like RAID 5 have this built in. However this issue can be mitigated to a large extent by regular backups and the snapshot function.

LVM becomes unusable when there is a drive failure within the array. Using a LVM snapshot to restore data is a possibility, but the process is not as straight forward as one would hope, and like any backup technology, the amount of data you retrieve is related to when the snapshot was taken.

Command Line Tools

We are not going into a lot of detail here, except to list some command line tools. Command line usage, while not difficult, can seem somewhat complex to new users. Instead, I am planning on using the built in functionality of Cockpit (see this post) to do the heavy lifting for us.

To use LVM, we need to install the following package.

apt install lvm2

You can use the lvm command itself for a variety of informational purposes. For example;

lvm version
lvm help
lvm fullreport
lvm lastlog

Actual functionality is achieved through commands using various prefixes; pv for physical volume, vg for volume group, and lv for logical volume.

Generally it is necessary to create/prepare a physical volume first. For example, this command could be used on a new raw drive.

pvcreate /dev/sdb

We then need to either add the drive to an existing volume group or create one. In the example below we create a new volume group called “volumegroup1”, then add the drive to it.

vgcreate volumegroup1 /dev/sdb

And finally we create logical volumes within the volume group created, these logical volumes are treated the same as partitions. They can be formatted and assigned mount points.

lvcreate -l 5GB -n mhylvgroup volumegroup1

For a logical volume we need to specify the size, the name, and what volume group it is part of.

As stated this is not an in depth look at using LVM from the command line. Please refer to the manual pages of your distribution for information on all commands and options. We will now move on to using Cockpit to manage LVM.

LVM with Cockpit

Per previous posts, Cockpit is a web based GUI for managing servers. To use Cockpit with LVM, we need to make sure the cockpit-storage module is installed (this is done by default in Debian, but may vary with other distributions). The lvm2 application also needs to be installed (see previous section). In addition we also need the udisks-lvm2 package.

apt install udisks-lvm2

When accessing your server via Cockpit, go to the storagepage. In the upper right device section is a menu icon. Clicking it should show an option to create a volume group.

Selecting this will bring up a window where you can name the Volume Group and assign drives to it. It will take a short amount of time for the volume group to be created.

After the volume group is created it will appear in the Devices section. Clicking on it will open a window where you will have options to change its name, create logical volumes, format new logical volumes, remove existing logical volumes, and add/remove drives from the volume group.

While it is good to use the command line interface a few times, for most people using the Cockpit GUI will be simpler and faster.


In this post we have taken a look at Logical Volume Groups (LVM)as a method for combining multiple drives into a large storage space. This is the last of the software application we will be visualizing for review.

In the remaining posts of this series, we will be building a functional Network Attached Storage (NAS) device out of some spare parts I have lying around the house.

Hodgepodge 3xNAS Part 1 Project Overview

Hodgepodge 3xNAS Part 2 Software Choices

Hodgepodge 3xNAS Part 3 Virtual Install

Hodgepodge 3xNAS Part 4 Initial Configuration

Hodgepodge 3xNAS Part 5 Need a GUI?

Hodgepodge 3xNAS Part 6 Add a Storage Drive

Hodgepodge 3xNAS Part 7 SMB/CIFS

Hodgepodge 3xNAS Part 8 Expanded Storage

Hodgepodge 3xNAS Part 9 Making RAID

Hodgepodge 3xNAS Part 10 Cockpit Web GUI RAID 5

Hodgepodge 3xNAS Part 11 Mergerfs

Hodgepodge 3xNAS Part 12 Snapraid

Hodgepodge 3xNAS Part 13 LVM

Hodgepodge 3xNAS Part 14 The Server Hardware

Hodgepodge 3xNAS Part 15 The Server Operating System

Hodgepodge 3xNAS Part 16 Cockpit Install

Hodgepodge 3xNAS Part 17 SAMBA Setup

Hodgepodge 3xNAS Part 18 PLEX vs Kodi

Add New Comment

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