Ubuntu Resize Disk

Ubuntu Resize Disk
Photo by Jandira Sonnendeck / Unsplash

I bought a mini-pc from lenovo for a new home server project. I will cover this project in future posts. So stay tuned.


I have chosen the latest version of Ubuntu 22.04.2 LTS. But during the installation I guess I didn't take care that the complete harddisk is used by Ubuntu.
I found this out with the following command:

panda@homeserver:~$ sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
NAME                      FSTYPE        SIZE MOUNTPOINT        LABEL
loop0                     squashfs     63,3M /snap/core20/1822
loop1                     squashfs    111,9M /snap/lxd/24322
loop2                     squashfs     49,8M /snap/snapd/18357
sda                                   119,2G
├─sda1                                    1M
├─sda2                    ext4            2G /boot
└─sda3                    LVM2_member 117,2G
  └─ubuntu--vg-ubuntu--lv ext4         58,6G /

To use the complete ~120GB disk-space I used the following commands:

panda@homeserver:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <117,24 GiB
  PE Size               4,00 MiB
  Total PE              30013
  Alloc PE / Size       15006 / <58,62 GiB
  Free  PE / Size       15007 / 58,62 GiB

We can see that there is ~58 GiB disk-space free which we can use.

 sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <58,62 GiB (15006 extents) to <117,24 GiB (30013 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
panda@homeserver:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 8, new_desc_blocks = 15
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 30733312 (4k) blocks long.

If we run the vgdisplay command again we will see the following:

panda@homeserver:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <117,24 GiB
  PE Size               4,00 MiB
  Total PE              30013
  Alloc PE / Size       30013 / <117,24 GiB
  Free  PE / Size       0 / 0

That's it, we do know havc doubled our disk-space on our machine.