Extend the boot device on OCI compute VM with Oracle Linux 9
I needed more space in my boot volume on a compute instance. The VM is using Oracle Linux 9.
This involves three steps:
- Increase the boot volume from the cloud.oracle.com page
- Make the OS detect this change
- Grow the file system
Increase the boot volume
Log into your cloud account and find your compute instance from Compute ➡️ Instances ➡️ your instance from the list. In the menu on the left side called Resources click on the Boot volume link. Then click on the link for the boot volume. Then finally click the hot Edit button, and set the new volume size, and hit save. There is some information displayed along the way that may be useful.
Make the OS detect the change
In my case the documentation for Rescanning the Disk for a Block Volume or Boot Volume regarding step 2 did not work for me.
Instead of running this command:
echo "1" | sudo tee /sys/class/block/<device_name>/device/rescan
I ran this (as root, of course):
echo 1 > /sys/class/scsi_disk/2\:0\:0\:1/device/rescan
In your case the exact path may be different, there was only one alternative on my machine.
The first command from the manual will not work since there is no directory called device
under /sys/class/block/dm-0
.
By the way, lsblk
is useful to see how these devices are connected (I removed some lines from the output):
[root@ocilab ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 100M 0 part /boot/efi
├─sda2 8:2 0 2G 0 part /boot
└─sda3 8:3 0 44.5G 0 part
├─ocivolume-root 252:0 0 29.5G 0 lvm /
└─ocivolume-oled 252:1 0 15G 0 lvm /var/oled
Also ls -l /dev/ocivolume
shows the link to dm-0
in this case.
Grow the filesystem
Next step is to grow the filesystem, I decided to run it without -y
as the manual
suggests:
[root@ocilab ~]# /usr/libexec/oci-growfs
Volume Group: ocivolume
Volume Path: /dev/ocivolume/root
Mountpoint Data
---------------
mountpoint: /
source: /dev/mapper/ocivolume-root
filesystem type: xfs
source size: 29.4G
type: lvm
size: 29.5G
physical devices: ['/dev/sda3']
physical volumes: ['/dev/sda', '/dev/sda']
partition number: ['3']
volume group name: ocivolume
volume group path: /dev/ocivolume/root
Partition dry run expansion "/dev/sda3" succeeded.
CHANGE: partition=3 start=4401152 old: size=93325312 end=97726463 new: size=205314015 end=209715166
Expanding partition /dev/sda3: Confirm? [y/N] y
Partition expand expansion "/dev/sda3" succeeded.
update-partition set to true
FLOCK: try exec open fd 9, on failure exec exits this program
FLOCK: /dev/sda: obtained exclusive lock
resizing 3 on /dev/sda using resize_sfdisk_gpt
209715200 sectors of 512. total size=107374182400 bytes
## sfdisk --unit=S --dump /dev/sda
label: gpt
label-id: 03BB97DA-6F69-460E-A76C-82C8377A90CF
device: /dev/sda
unit: sectors
first-lba: 34
last-lba: 97727250
sector-size: 512
/dev/sda1 : start= 2048, size= 204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=3AF7074E-C0BB-400D-8FC7-E9EC738AA53F, name="EFI System Partition"
/dev/sda2 : start= 206848, size= 4194304, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=14BE7023-6C02-4573-8891-9F639B9D936A
/dev/sda3 : start= 4401152, size= 93325312, type=E6D6D379-F507-44C2-A23C-238F2A3DF928, uuid=E700F071-90A5-40BB-8132-52AF688193B7
padding 33 sectors for gpt secondary header
max_end=209715166 tot=209715200 pt_end=97726463 pt_start=4401152 pt_size=93325312
resize of /dev/sda returned 0.
FLOCK: /dev/sda: releasing exclusive lock
CHANGED: partition=3 start=4401152 old: size=93325312 end=97726463 new: size=205314015 end=209715166
Extending /dev/sda3 succeeded.
Device /dev/sda3 extended successfully.
Logical volume /dev/ocivolume/root extended successfully.
Successful operation is demonstrated with the command df -h
.
My VM is now ready for more stuff, like running a container with the latest version of the FREE database as shown [here].(https://enesi.no/2023/10/your-own-oracle-database-lab-in-1-2-3/ )