Logical Volume Management on Debian Linux

Debian Linux is a popular Linux distribution and caters to end user workstations as well as network servers. Debian is often praised for being a very stable Linux distribution. Debian’s stability paired with the...

Spread the love

Debian Linux is a popular Linux distribution and caters to end user workstations as well as network servers. Debian is often praised for being a very stable Linux distribution. Debian’s stability paired with the flexibility of LVM makes for a highly flexible storage solution that anyone can appreciate.

Before continuing with this tutorial, Tecmint offers a great review and overview of the installation of Debian 7.8 “Wheezy” which can be found here:

  1. Installation of Debian 7.8 “Wheezy”

Logical Volume Management (LVM) is a method of disk management that allows multiples disks or partitions to be collected into one large storage pool that can be broken up into storage allocations known as Logical Volumes.

Since an administrator can add more disks/partitions as they desire, LVM becomes a very viable option for changing storage requirements. Aside from the easy expandability of LVM, some data resiliency features are also built into LVM. Features such as snap-shot abilities and data migration from failing drives, provide LVM with even more abilities to maintain data integrity and availability.

Setup LVM on Debian

Setup LVM on Debian

Installation Environment
  1. Operating System – Debian 7.7 Wheezy
  2. 40gb boot drive – sda
  3. 2 Seagate 500gb drives in Linux Raid – md0 (RAID not necessary)
  4. Network/Internet connection

Installing and Configuring LVM on Debian

1. Root/administrative access to the system is needed. This can be obtained in Debian through the use of the su command or if the appropriate sudo settings have been configured, sudo can be used as well. However this guide will assume root login with su.

2. At this point the LVM2 package needs to be installed onto the system. This can be accomplished by entering the following into the command line:

# apt-get update && apt-get install lvm2

At this point one of two commands can be run to ensure that LVM is indeed installed and ready to be used on the system:

# dpkg-query -s lvm2
# dpkg-query -l lvm2

Installation of LVM on Debian

Check LVM Installation Status

3. Now that the LVM software is installed, it is time to prepare the devices for use in an LVM Volume Group and eventually into Logical Volumes.

To do this the pvcreate utility will be used to prepare the disks. Normally LVM would be done on a per partition basis using a tool such as fdisk, cfdisk, parted, or gparted to partition and flag the partitions for use in a LVM setup, however for this setup two 500gb drives were raided together to create a RAID array called /dev/md0.

This RAID array is a simple mirror array for redundancy purposes. In the future, an article explaining how RAID is accomplished will also be written. For now, let’s move ahead with the preparation of the physical volumes (The blue blocks in the diagram at the beginning of the article).

If not using a RAID device, substitute the devices that are to be part of the LVM setup for ‘/dev/md0‘. Issuing the following command will prepare the RAID device for use in an LVM setup:

# pvcreate /dev/md0

4. Once the RAID array has been prepared, it needs to be added to a Volume Group (the green rectangle in the diagram at the beginning of the article) and this is accomplished with the use of the vgcreate command.

The vgcreate command will require at minimum two arguments passed to it at this point. The first argument will be the name of the Volume Group to be created and the second argument will be the name of the RAID device prepared with pvcreate in step 3 (/dev/md0). Putting all of the components together would yield a command as follows:

# vgcreate storage /dev/md0

At this point, LVM has been instructed to create a volume group called ‘storage‘ that will use the device ‘/dev/md0‘ to store the data that is sent to any logical volumes that are a member of the ‘storage‘ volume group. However, at this point there still aren’t any Logical Volumes to be used for data storage purposes.

5. Two command can quickly be issued to confirm that the Volume Group was successfully created.

  1. vgdisplay – Will provide far greater detail about the Volume Group.
  2. vgs – A quick one line output to confirm that the Volume Group is in existence.
# vgdisplay
# vgs

Create Volume Group in Debian

Check Volume Group

6. Now that the Volume Group is confirmed ready, the Logical Volumes themselves, can be created. This is the end goal of LVM and these Logical Volumes are were data will be sent in order to get written to the underlying physical volumes (PV) that make up the Volume Group (VG).

To create the Logical Volumes, several arguments need to be passed to the lvcreate utility. The most important and essential arguments include: the size of the Logical Volume, the name of the Logical Volume, and which Volume Group (VG) this newly created Logical Volume (LV) will belong. Putting all this together yields a lvcreate command as follows:

# lvcreate -L 100G -n Music storage

Effectively this command says to do the following: create a Logical Volume that is 100 gigabytes in length that has a name of Music and belongs to the Volume Group storage. Let’s go ahead and create another LV for Documents with a size of 50 gigabytes and make it a member of the same Volume Group:

# lvcreate -L 50G -n Documents storage

The creation of the Logical Volumes can be confirmed with one of the following commands:

  1. lvdisplay – Detailed output of the Logical Volumes.
  2. lvs – Less detailed output of the Logical Volumes.
# lvdisplay
# lvs

Create Logical Volume in Debian

Create Logical Volumes in Debian

Facebook Comments

More Stuff

How to Remove Docker Images, Containers and Volumes Docker is an open-source, powerful, secure, reliable and efficient container platform that enables realistic independence between applications and inf...
How to Install Latest XFCE Desktop in Ubuntu 16.04/16.10 and Fedor... Xfce is a modern, open source and lightweight desktop environment for Linux systems. It also works well on many other Unix-like systems such as Mac OS...
Sony’s incredible beer-holding karaoke speaker lives up to its par... Sony announced the GTK-PG10 at CES 2019 with the promise that it would be the ultimate party speaker, one that not only could play music but also unfo...
Explore the immersive web with Firefox Reality. Now available for ... Earlier this year, we shared that we are building a completely new browser called Firefox Reality. The mixed reality team at Mozilla set out to build ...
Spread the love

Posted by News Monkey