There is a Rocky Linux 9 VM in the VirtualBox. It’s required to extend the root partition. By default, RHEL-based distros use LVM. It allows to use several physical disks as one logical volume.
-
Check the name of root partition device with
df -h
:Filesystem Size Used Avail Use% Mounted on devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 882M 0 882M 0% /dev/shm tmpfs 353M 5.0M 348M 2% /run /dev/mapper/rl-root 8.0G 1.2G 6.9G 14% / /dev/sda1 960M 223M 738M 24% /boot tmpfs 177M 0 177M 0% /run/user/0
The name of the root partition device is
/dev/mapper/rl-root
. The volume group name isrl
and the logical volume name isroot
. -
Check logical volumes using a command
lvs -a -o +devices
:LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices root rl -wi-ao---- <8.00g /dev/sda2(256) swap rl -wi-ao---- 1.00g /dev/sda2(0)
/dev/mapper/rl-root
using a physical device/dev/sda2
and has a size 8Gb. -
Add one more 10Gb disk to the VM using the VirtualBox configuration screen.
-
Check a name of a new partition with
fdisk -l
:... Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors Disk model: VBOX HARDDISK Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes ...
New disk name is
/dev/sdb
. -
Add new physical disk to the existing volume group:
vgextend rl /dev/sdb
. -
Resize root partition:
lvextend -l +100%FREE /dev/mapper/rl-root
. -
Resize file system:
xfs_growfs /dev/mapper/rl-root
. -
Check if the root partition was extended successfully with
df -h
:Filesystem Size Used Avail Use% Mounted on devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 882M 0 882M 0% /dev/shm tmpfs 353M 5.0M 348M 2% /run /dev/mapper/rl-root 18G 1.3G 17G 7% / /dev/sda1 960M 223M 738M 24% /boot tmpfs 177M 0 177M 0% /run/user/0