Red Hat Family OS's: Extending Root Partition
Windows easily allows extending a partition, while the disk is in use or “online”. Extending a partition is a common task when managing guests in a virtual environment. This process has always been straight forward in Windows, but the Linux commands had eluded me for some time.
Fedora 30 maintains the root partitions as a volume group - a composition from several partitions made into one logical volume. So the solution is to create a new partition, empty and of the size you wish to exapand your root partition by, then add it to the volume group. xvda is the designation for the virtual disk attached to my guest that I’ll be adding the new partition to.
if your virtual disk needs to be expanded to make free space for the new partition, then do that first using your hypervisor’s controls
Creating the new partition
fdisk /dev/xvda
n #new partition
p #primary type partition
[enter] #default option
[enter] #default option
[enter] #default option
w #write partition table
q #quit fdiskThe next code section uses the vgextend command to modify a volume group. To list your volume groups use vgdisplay
Adding the new partition xvda3 to the volume group
partprobe
pvcreate /dev/xvda3
vgextend /dev/fedora /dev/xvda3
lvextend -l+100%FREE /dev/fedora/root
fsadm resize /dev/fedora/rootpartprobe
pvcreate /dev/xvda3
vgextend /dev/cl /dev/xvda3
lvextend -l+100%FREE /dev/cl/root
fsadm resize /dev/cl/rootpartprobe
pvcreate /dev/xvda3
vgextend /dev/rl /dev/xvda3
lvextend -l+100%FREE /dev/rl/root
fsadm resize /dev/rl/rootCheck that your free space has increased with:
df -hThe volume group will appear in the listing as:
/dev/mapper/fedora-root/dev/mapper/cl-root/dev/mapper/rl-root