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.
Resizing a disk in ESXi -
Use
lsblkto determine which disk holds your root filesystem:; lsblkOn my system, it outputs the following table:
Name Major:Minor Rm Size Read-Only Type Mount Points sda8:0 0 32GB 0 disk ↳ sda18:1 0 1G 0 part /boot ↳ sda28:2 0 15G 0 part ↳ fedora_fedora-root253: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 calledrootwithin 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
partedto increase the partition size of/dev/sda1.; sudo parted /dev/sdaWithin
parted, useprintto 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.4GBPrint the updated table:
(parted) printNumber 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) quitNow running
lsbkoutputs the following:Name Major:Minor Rm Size Read-Only Type Mount Points sda8:0 0 32GB 0 disk ↳ sda18:1 0 1G 0 part /boot ↳ sda28:2 0 31G 0 part ↳ fedora_fedora-root253: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 resizedThis will reflect the available space in
/dev/sda2as free space within the LVM Volume Group. -
Extend the logical volume by running:
; sudo lvextend -l+100%FREE fedora_fedora/rootwhich extends the LVM Logical Volume
rootwithin the Volume Groupfedora_fedora. -
Extend the filesystem3:
; sudo xfs_growfs / ... data blocks changed from 3931136 to 8125440at this point
df -hwill 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. ↩︎