How to Extend LVM Boot Partition on Oracle Cloud

So you’re running out of disk space and about to increase the volume boot size, great! Now you met with this dialog.

The documentation link mentions here: https://docs.oracle.com/en-us/iaas/Content/Block/Tasks/rescanningdisk.htm
How lovely, but I’m in Rocky Linux, not Oracle Linux. So, these commands don’t work, and I have to scorch the whole internet resources to make it works!
Let’s break it down:
Rescan The Disk
My partition is look like this:
[root@sgp ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 99M 0 part /boot/efi
├─sda2 8:2 0 1000M 0 part /boot
├─sda3 8:3 0 4M 0 part
├─sda4 8:4 0 1M 0 part
└─sda5 8:5 0 98.9G 0 part
└─rocky-root 253:0 0 98.9G 0 lvm /
As you can see there’s lot of partition but it’s just 100 GB of single boot partition inside a logical disk we call them LVM, which is what / mounts to.
The first command before running anything is test the disk. We use dd for that, and tell it to read /dev/sda to nowhere /dev/null with count=1. We got this:
[root@sgp ~]# dd iflag=direct if=/dev/sda of=/dev/null count=1
1+0 records in
1+0 records out
512 bytes copied, 0.00101196 s, 506 kB/s
Ok it seems it is correctly accessible, let’s continue with actual disk rescan.
[root@sgp ~]# echo "1" | sudo tee /sys/class/block/sda/device/rescan
1
Extending The Disk
The disk has been bumped, now we extend the partition.
If this is not a root / partition i’ll just simply do xfs_growfs /home and call it a day. Unfortunately, we need the root partition to grow right now.
Fortunately, Oracle Cloud says just use oci-growfs so yeah that’s what I’ll use. First, we install it.
[root@sgp ~]# yum install oci-utils -y
Now we extend it
[root@sgp ~]# /usr/libexec/oci-growfs
Volume Group: rocky
Volume Path: /dev/rocky/root
Mountpoint Data
---------------
mountpoint: /
source: /dev/mapper/rocky-root
filesystem type: xfs
source size: 98.9G
type: lvm
size: 98.9G
physical devices: ['/dev/sda5']
physical volumes: ['/dev/sda']
partition number: ['5']
volume group name: rocky
volume group path: /dev/rocky/root
Partition dry run expansion "/dev/sda5" succeeded.
CHANGE: partition=5 start=2265088 old: size=207450079 end=209715166 new: size=333279199 end=335544286
Expanding partition /dev/sda5: Confirm? [y/N]
The log continues until
Extending /dev/sda5 succeeded.
Device /dev/sda5 extended successfully.
Logical volume /dev/rocky/root extended successfully.
Heal yeah, we did it!
[root@sgp ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 5.7G 3.7M 5.7G 1% /dev/shm
tmpfs 2.3G 240M 2.1G 11% /run
/dev/mapper/rocky-root 159G 98G 62G 62% /
/dev/sda2 936M 594M 343M 64% /boot
/dev/sda1 99M 7.3M 92M 8% /boot/efi

