Expanding Your Boot Volume Storage in Oracle Cloud Infrastructure (OCI) with LVM
When you increase the size of an OCI instance’s boot volume directly from the Oracle Cloud console, the additional storage space is successfully provisioned to the underlying disk. However, the operating system running on your instance won’t automatically recognize or utilize this new capacity. To make the added space available, you must manually extend the disk partition, the Logical Volume Manager (LVM) physical volume, and finally, the filesystem that resides on it.
This comprehensive guide will walk you through the essential steps to achieve this expansion.
1. Initiating the Boot Volume Resize in OCI Console
Your first action is to modify the boot volume’s size within the Oracle Cloud Infrastructure console. Navigate to your specific OCI Instance, then select Boot Volume. From there, choose Edit and then Resize. Input your desired new size—for example, increasing it from 50GB to 100GB.
2. Verifying the Newly Added Volume Capacity
After adjusting the size in the OCI console, execute the lsblk
command on your instance to confirm that the new capacity is reflected at the disk level:
lsblk
A typical output following the resize might look like this:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 100M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 45.5G 0 part
├─ocivolume-root 252:0 0 35.5G 0 lvm /
└─ocivolume-oled 252:1 0 10G 0 lvm /var/oled
In this example, the sda
disk now shows 100GB (your boot volume), but sda3
(the main partition where LVM resides) is still at 45.5GB. This indicates that while the disk has grown, the partition itself has not yet expanded.
3. Extending Partition sda3
To utilize the new disk space, you need to expand the sda3
partition. First, install the growpart
utility:
sudo dnf install -y cloud-utils-growpart
Then, use growpart
to extend the partition. The ‘3’ in the command refers to the third partition on /dev/sda
:
sudo growpart /dev/sda 3
Confirm the partition’s expansion by running lsblk
again:
lsblk
You should now see sda3
reflecting a size closer to 99GB, taking up most of the available disk space.
4. Resizing the LVM Physical Volume
With the partition extended, the next step is to update the LVM Physical Volume (PV) to recognize the new space.
sudo pvresize /dev/sda3
To verify the physical volume’s new size, use:
sudo pvs
5. Expanding the Logical Volume
Currently, your root logical volume (ocivolume-root
) might still be at its original size (e.g., 35.5GB). To extend it and consume all the newly available free space within the volume group:
sudo lvextend -l +100%FREE /dev/ocivolume/root
6. Growing the Filesystem
The final step is to instruct the filesystem itself to use the newly allocated space. The command depends on the filesystem type:
- For XFS filesystems (the default for Oracle Linux 8 and many other modern Linux distributions):
sudo xfs_growfs /
- For ext4 filesystems:
sudo resize2fs /dev/ocivolume/root
7. Verifying the New Filesystem Size
To confirm that the entire process was successful and your root filesystem now has the expanded capacity:
df -h
Your /
mount point should now display a size close to 90GB or whatever total capacity you aimed for, reflecting the successful expansion.