I was able to upgrade the storage in my desktop recently. LVM is something that makes this addition incredibly easy. This post outlines the process I took to double my storage with my new HDD.

Identify Drive

Find the device file we need. In this case it’s /dev/sdc.

dan@ubuntu-test:~$ lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0           7:0    0  219M  1 loop /snap/gnome-3-34-1804/66
loop1           7:1    0 64.8M  1 loop /snap/gtk-common-themes/1514
loop2           7:2    0 55.4M  1 loop /snap/core18/1997
loop3           7:3    0 32.3M  1 loop /snap/snapd/11588
loop4           7:4    0   51M  1 loop /snap/snap-store/518
sda             8:0    0  100G  0 disk 
├─sda1          8:1    0    1M  0 part 
├─sda2          8:2    0  513M  0 part /boot/efi
└─sda3          8:3    0 99.5G  0 part /
sdb             8:16   0   10G  0 disk 
└─backup-pool 253:0    0   10G  0 lvm  
sdc             8:32   0   10G  0 disk

Create the PV

dan@ubuntu-test:~$ sudo pvcreate /dev/sdc
  Physical volume "/dev/sdc" successfully created.

Add the PV to the VG

To use this new PV we need to know which VG we are trying to extend. Use the command vgs to see the current volume groups on the system.

dan@ubuntu-test:~$ sudo vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  backup   1   1   0 wz--n- <10.00g    0

Then add it to the VG using vgextend.

dan@ubuntu-test:~$ sudo vgextend backup /dev/sdc
  Volume group "backup" successfully extended

Extend the LVM

Now extend the LVM to include the new space.

dan@ubuntu-test:~$ sudo lvextend -l +100%FREE /dev/backup/pool
  Size of logical volume backup/pool changed from <10.00 GiB (2559 extents) to 19.99 GiB (5118 extents).
  Logical volume backup/pool successfully resized.

Extend the Filesystem

The final step is to allow the filesystem to take more space on the LVM. In this post I am using ext4.

dan@ubuntu-test:~$ sudo resize2fs /dev/backup/pool
resize2fs 1.45.7 (28-Jan-2021)
Resizing the filesystem on /dev/backup/pool to 5240832 (4k) blocks.
The filesystem on /dev/backup/pool is now 5240832 (4k) blocks long.