During the upgrade of Fedora 38 to Fedora 39 (beta) on my main desktop, the first attempt failed due to insufficient free disk space on the root volume. After some manual intervention such as vacuuming the journald logs, I was able to perform the successful upgrade. Not that it matters, but I’m writing this blog post on the same desktop running Fedora 39 Beta.

This post is to record how I increase the root volume on my desktop with the help of a few tools such as growpart, lsblk, resize2fs,…etc. Like always, if you stumble on this post and want to follow along, please do not just copy and pate the commands from here and run on your system. Try to understand what each command does, if you don’t, then you definitely must not copy and pate these commands!

Let’s gather available information before we make change to the disk/volume.

[root@watamem ~]# lsblk /dev/sda
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 232.9G  0 disk
├─sda1                    8:1    0   500M  0 part /boot
└─sda2                    8:2    0 111.3G  0 part
  ├─fedora_watamem-root 253:0    0    57G  0 lvm  /
  └─fedora_watamem-home 253:1    0  53.5G  0 lvm  /home

[root@watamem ~]# pvs
  PV         VG             Fmt  Attr PSize   PFree
  /dev/sda2  fedora_watamem lvm2 a--  111.30g 836.00m

[root@watamem ~]# vgs
  VG             #PV #LV #SN Attr   VSize   VFree
  fedora_watamem   1   2   0 wz--n- 111.30g 836.00m

[root@watamem ~]# lvs
  LV   VG             Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home fedora_watamem -wi-ao---- 53.48g
  root fedora_watamem -wi-ao---- 57.00g

From the above output, we can see that I still have some space left on /dev/sda (232.9G - 111.3G). There are 2 ways I could use to expand the root LVM fedora_watamem/root. The first solution is to create a new partition (e.g. /dev/sda3, create a new LVM physical volume and add it to the VG fedora_watamem with 836.00MiB of free space. The second solution is to expand the existing /dev/sda2 to available free space. I’ll use the 2nd method in this post.

In order to expand or grow the last partition in a disk, we can use growpart to do that. growpart is provided by cloud-utils-growpart package on Fedora.

[root@watamem ~]# dnf install cloud-utils-growpart -y
...
Installed:
  cloud-utils-growpart-0.33-3.fc39.noarch

Complete!

Here is an example of using growpart on /dev/sda device for partition number 1.

   Example:
    - growpart /dev/sda 1
      Resize partition 1 on /dev/sda

    - growpart --free-percent=10 /dev/sda 1
      Resize partition 1 on /dev/sda so that 10% of the disk is unallocated

Before running growpart, pay attention to the size of /dev/sda2 which is 111.3G.

[root@watamem ~]# lsblk /dev/sda
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 232.9G  0 disk
├─sda1                    8:1    0   500M  0 part /boot
└─sda2                    8:2    0 111.3G  0 part
  ├─fedora_watamem-root 253:0    0    57G  0 lvm  /
  └─fedora_watamem-home 253:1    0  53.5G  0 lvm  /home

In my case, I need to grow the partition 2 on device /dev/sda. Therefore, the command would look as the following.

[root@watamem ~]# growpart /dev/sda 2
CHANGED: partition=2 start=1026048 old: size=233414656 end=234440703 new: size=487371087 end=488397134

Now, let’s check the size of the partition 2 again.

[root@watamem ~]# lsblk /dev/sda
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 232.9G  0 disk
├─sda1                    8:1    0   500M  0 part /boot
└─sda2                    8:2    0 232.4G  0 part
  ├─fedora_watamem-root 253:0    0    57G  0 lvm  /
  └─fedora_watamem-home 253:1    0  53.5G  0 lvm  /home

It looks like the /dev/sda2 has been increased to 232.4G. How about LVM size, is there anything that needs to be done?

[root@watamem ~]# pvs
  PV         VG             Fmt  Attr PSize   PFree
  /dev/sda2  fedora_watamem lvm2 a--  232.39g 121.91g
[root@watamem ~]# vgs
  VG             #PV #LV #SN Attr   VSize   VFree
  fedora_watamem   1   2   0 wz--n- 232.39g 121.91g

Nope, both PV and VG have been increased automatically, 121.91GiB. The last thing I need to do is to increase the root volume to a desired size.

I’m going to add just 33 GiB to the fedora-watamame-root LVM to make it 90 GiB total.

[root@watamem ~]# lvresize -rL +33G /dev/fedora_watamem/root
  Size of logical volume fedora_watamem/root changed from 57.00 GiB (14592 extents) to 90.00 GiB (23040 extents).
  File system ext4 found on fedora_watamem/root mounted at /.
  Extending file system ext4 to 90.00 GiB (96636764160 bytes) on fedora_watamem/root...
resize2fs /dev/fedora_watamem/root
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/fedora_watamem/root is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 6
The filesystem on /dev/fedora_watamem/root is now 23592960 (4k) blocks long.

resize2fs done
  Extended file system ext4 on fedora_watamem/root.
  Logical volume fedora_watamem/root successfully resized.

The above output indicates that the LVM fedora_watamem/root has been expanded to 90 GiB successfully. Thanks to the -r option provided to lvresize command, there is no need to manually run resize2fs (for ext4 file system).

[root@watamem ~]# lvs
  LV   VG             Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home fedora_watamem -wi-ao---- 53.48g
  root fedora_watamem -wi-ao---- 90.00g

[root@watamem ~]# lsblk /dev/sda
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 232.9G  0 disk
├─sda1                    8:1    0   500M  0 part /boot
└─sda2                    8:2    0 232.4G  0 part
  ├─fedora_watamem-root 253:0    0    90G  0 lvm  /
  └─fedora_watamem-home 253:1    0  53.5G  0 lvm  /home

Well, everything went smoothly according to plan, it seemed.