Writing this down since I had such a hard time finding all the pieces. This procedure is for expanding the disk of a Fedora (in this case Fedora Server 35) virtual machine using LVM and XFS (the default). I use VMs on ESXi, but this should apply to any Fedora VM scenario.
-
Expand the disk in your virtualization system, in ESXi I chose the VM, then click Edit, then increase the size next to the Hard Disk.
-
Use
lsblk
to determine which disk holds your root filesystem:; lsblk
On my system, it outputs the following table:
Name Major:Minor Rm Size Read-Only Type Mount Points sda
8:0 0 32GB 0 disk ↳ sda1
8:1 0 1G 0 part /boot ↳ sda2
8:2 0 15G 0 part ↳ fedora_fedora-root
253:0 0 15G 0 lvm / plus the CD-ROM and swap partitions.
This table gives us some valuable information. The
/
filesystem we want to expand is an Logical Volume Manager (LVM) volume calledroot
within a Volume Group calledfedora_fedora
. The logical volume group is atop the physical partition/dev/sda2
, which is a partition of the disk/dev/sda
. We can see the effects of our expansion at the disk level, but we need to propagate it through the partiton, the LVM Physical Volume within our Volume Group, the LVM Logical Volume, and the fileystem. -
Use
parted
to increase the partition size of/dev/sda
1.; sudo parted /dev/sda
Within
parted
, useprint
to list your volumes:(parted) print Model: VMware Virtual disk (scsi) Disk /dev/sda: 34.4GB Sector size (logical/physical): 512B/512B Partiton Table: msdos Disk Flags:
It will then print the following table:
Number Start End Size Type File system Flags 1 1049kB 1075MB 1074MB primary xfs boot 2 1075MB 17.2GB 16.1GB primary lvm Resize partiton number two, which backs LVM, with the size reported next to
Disk /dev/sda:
above:(parted) resizepart 2 34.4GB
Print the updated table:
(parted) print
Number Start End Size Type File system Flags 1 1049kB 1075MB 1074MB primary xfs boot 2 1075MB 34.4GB 33.3GB primary lvm Then exit:
(parted) quit
Now running
lsbk
outputs the following:Name Major:Minor Rm Size Read-Only Type Mount Points sda
8:0 0 32GB 0 disk ↳ sda1
8:1 0 1G 0 part /boot ↳ sda2
8:2 0 31G 0 part ↳ fedora_fedora-root
253:0 0 15G 0 lvm / -
Extend the LVM Physical Volume2 by running:
; sudo pvresize /dev/sda2 Physical volume "/dev/sda2" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized
This will reflect the available space in
/dev/sda2
as free space within the LVM Volume Group. -
Extend the logical volume by running:
; sudo lvextend -l+100%FREE fedora_fedora/root
which extends the LVM Logical Volume
root
within the Volume Groupfedora_fedora
. -
Extend the filesystem3:
; sudo xfs_growfs / ... data blocks changed from 3931136 to 8125440
at this point
df -h
will show the new size of our filesystem.
I attempted to use embiggen-disk
first, but embiggen-disk /
complained that the MBR was an unknown type 8e
. The type 8e
is an LVM volume.
-
See the Red Hat documentation on resizing a partition with
parted
. ↩︎ -
This serverfault answer provided the steps for extending the physical volume and logical volume. ↩︎
-
See the Red Hat documentation on increasing the size of an xfs file system. ↩︎