Mastodon LinkedIn GitHub Bandcamp Instagram X.com

Expanding encrypted LVM volume size in Ubuntu

# eng 0 interactions

I installed a fresh copy of Ubuntu 24.04 onto my new home server mini-PC. During installation I went with the default LUKS+LVM volume setup with encryption enabled. Somehow I did not notice at the time that the setup did not allocate all free disk space for the encrypted volume, and capped the Ubuntu filesystem at 100 gigabytes.

ojrask@server:~$ lsblk
NAME                        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
loop0                         7:0    0  50.8M  1 loop  /snap/snapd/25202
loop1                         7:1    0  73.9M  1 loop  /snap/core22/2111
loop2                         7:2    0 114.4M  1 loop  /snap/lxd/33110
loop3                         7:3    0    50G  0 loop  
nvme0n1                     259:0    0 476.9G  0 disk  
├─nvme0n1p1                 259:1    0     1G  0 part  /boot/efi
├─nvme0n1p2                 259:2    0     2G  0 part  /boot
└─nvme0n1p3                 259:3    0 473.9G  0 part  
  └─dm_crypt-0              252:0    0 473.9G  0 crypt 
    └─ubuntu--vg-ubuntu--lv 252:1    0   100G  0 lvm   /

(See the last line of the output, and the size being 100G.)

To fix this and expand the crypted volume to the full size available on the disk, do the following:

$ sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv # find the volume path with `df` command
$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

After that the volume size is what it should be:

ojrask@server:~$ lsblk
NAME                        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
loop0                         7:0    0  50.8M  1 loop  /snap/snapd/25202
loop1                         7:1    0  73.9M  1 loop  /snap/core22/2111
loop2                         7:2    0 114.4M  1 loop  /snap/lxd/33110
loop3                         7:3    0    50G  0 loop  
nvme0n1                     259:0    0 476.9G  0 disk  
├─nvme0n1p1                 259:1    0     1G  0 part  /boot/efi
├─nvme0n1p2                 259:2    0     2G  0 part  /boot
└─nvme0n1p3                 259:3    0 473.9G  0 part  
  └─dm_crypt-0              252:0    0 473.9G  0 crypt 
    └─ubuntu--vg-ubuntu--lv 252:1    0 473.9G  0 lvm   /

I found the solution in an AskUbuntu post, and I’m not sure how applicable the commands are on other distributions. I presume at least Debian and Debian-likes should work pretty much the same way.


Replies, reactions, reposts

None yet! Be the first? Send a webmention my way!

Selfie of Otto Rask on a sunny day, taking part in a political rally. He's wearing a cap and blue-tinted sunglasses.

Otto Rask

A software and product professional, leftist activist, urbanist, cargo biker, husband, dad, electronic musician, gamer, and more. I live in Espoo, Finland.

Read more →