How To Increase LVM Storage in Debian 12

How To Increase LVM Storage in Debian 12

Overview

In proxmox, to increase storage we add additional disks. We have used LVM’s when creating the OS so we can dynamically increase storage.

Increase LVM Storage

Create PV

First, identify the newly added disk

blair@wn-noc-01:~$ lsblk
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                8:0    0   32G  0 disk
└─sda1             8:1    0   32G  0 part
  ├─storage-boot 254:0    0  976M  0 lvm  /boot
  ├─storage-log  254:1    0  4.7G  0 lvm  /var/log
  └─storage-root 254:2    0 26.4G  0 lvm  /
sdb                8:16   0  100G  0 disk
sr0               11:0    1 1024M  0 rom

Now, create a new PV for this new disk

pvcreate /dev/sdb

Extend the Volume Group (vg)

First, identify the volume group

root@wn-noc-01:~# vgs
  VG      #PV #LV #SN Attr   VSize   VFree
  storage   2   3   0 wz--n- 131.99g    0

Now we extend the volume group onto the new pv we created above

vgextend storage /dev/sdb

Increase the volume size

Now, let’s identify the volumes in our volume group

root@wn-noc-01:~# lvs
  LV   VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  boot storage -wi-ao---- 976.00m
  log  storage -wi-ao---- <19.66g
  root storage -wi-ao---- 111.38g

Now, let’s add some more storage to these volumes

If we want to add a certain number of GB to a volume

lvextend -L 15GB /dev/storage/log

If we ant to add a certain percentage of free space to a volume

lvextend -l 100%FREE /dev/storage/root

Extend the filesystem

Now that we have added more storage to our logical volumes, we need to grow the filesystem to use the new space.

When running ext4 as a filesystem, we can use the resize2fs command

resize2fs /dev/storage/log
resize2fs /dev/storage/root

Now, when we run df -H -x tmpfs we can see the volumes have the new sizes

root@wn-noc-01:~# df -H -x tmpfs
Filesystem                Size  Used Avail Use% Mounted on
udev                      2.1G     0  2.1G   0% /dev
/dev/mapper/storage-root  118G  2.6G  110G   3% /
/dev/mapper/storage-boot  989M  111M  810M  13% /boot
/dev/mapper/storage-log    21G   36M   20G   1% /var/log