Quick 10 minute LVM Setup.

Sometimes, you realize you would want to use LVM in a computer but you want a tutorial to take you there fast, So i have put this post together to get you up and running in 10 minutes or less.

First, let us start with the tools, install the following packages in your debian installation, (Debian 10-Buster in this tutorial)

apt-get install lvm2 dmsetup mdadm reiserfsprogs xfsprogs

In this tutorial, I have two 8TB disks i want to combine with LVM to use as one

1- Create partitions of type LVM on the disks

  • Why not use the disk without a partition ? See this post

Start by running parted on every physical disk, and creating a big partition to span the whole disk (Or if you are using empty spaces on old disks, any partition is good enough really)

In my example, where i wish to combine /dev/sdb and /dev/sdc into one logical volume (To be used as one block)

parted /dev/sdb
mklabel gpt
unit mib
mkpart primary ext4 1 100%
set 1 lvm on

Now, repeat the above, but this time for /dev/sdc

1- Prepare the physical volumes to be added to volume groups (those two partitions) (For instructions on how to add disks directly without an underlying partition which is not recommended, see here)

pvcreate /dev/sdb1 /dev/sdc1

Now, you can see what we have with the commands

pvdisplay or pvs

2- Add the PVs to a logical volume

vgcreate LVMGroup /dev/sdb1 /dev/sdc1
   Volume group "LVMGroup" successfully created

this will create a volume group (VG) called LVMGroup, you can see the VGs you have with the commands (vgdisplay, vgscan, and vgs)

vgs -o +lv_size,lv_name

3- Create a logical group on the volume group

lvcreate -l 100%FREE -n bigvol LVMGroup
  Logical volume "bigvol" created.
mkfs.ext4 /dev/LVMGroup/bigvol
mkfs.ext4 /dev/mapper/LVMGroup-bigvol

4- Mount, and add to fstab

To mount the volume, My mount point is at /hds/lvm

Leave a Reply

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