This is an aide-memoire for myself and only applies to Ubuntu running on Oracle Cloud. Whilst Oracle has a relevant guide, it is tailored to Oracle Linux and referres to OCI utilities – in particular oci-growfs – that are not available in Ubuntu.

As always, this guide is provided “AS IS” – you use it at your own risk. If your server blows up, it’s on you. Ensure you have a full backup of the instance and don’t do this during peak periods as a reboot is required.

In Oracle Cloud Console

  1. Log into Oracle Cloud Console and select the appropriate compartment (for most this won’t apply)
  2. From (top left) Main Navigation go to Storage then click on Block Volumes from within the expanded menu
  3. Under the left-hand Block ‘Storage’ menu, select Boot Volumes
  4. From list of Boot Volumes, click on the applicable volume name
  5. In Boot Volume Details, click on the Edit button.
  6. Make the necessary changes and then click on Save Changes. If you change the volume size you will receive a prompt containing two commands to run on the host system

In Shell or SSH

Run the two commands supplied by Oracle (the ones given to me are below)

sudo dd iflag=direct if=/dev/oracleoci/oraclevda of=/dev/null count=1

echo "1" | sudo tee /sys/class/block/readlink /dev/oracleoci/oraclevda | cut -d'/' -f 2/device/rescan

Now run the lsblk command to check the detected disk sizes. You should see something like below (resizing from a 47GB disk to 75GB):

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.8M 1 loop /snap/core20/2571
loop1 7:1 0 55.4M 1 loop /snap/core18/2855
loop2 7:2 0 89.4M 1 loop /snap/lxd/31333
loop3 7:3 0 88.6M 1 loop /snap/oracle-cloud-agent/94
loop4 7:4 0 50.9M 1 loop /snap/snapd/24505
sda 8:0 0 75G 0 disk
├─sda1 8:1 0 46.9G 0 part /
├─sda14 8:14 0 4M 0 part
└─sda15 8:15 0 106M 0 part /boot/efi

The value of sda should that of the resized or expanded value. In this example, this is 75GB. The value of sda1 should be current size of the root partition (at the moment, 46.9G).

To apply the resized disk, simply restart the Ubuntu instance using the reboot command.

reboot -f

Upon restart, use either lsblk or any other tool to check sd3 is now resized.

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 63.8M 1 loop /snap/core20/2571
loop1 7:1 0 55.4M 1 loop /snap/core18/2855
loop2 7:2 0 89.4M 1 loop /snap/lxd/31333
loop3 7:3 0 88.6M 1 loop /snap/oracle-cloud-agent/94
loop4 7:4 0 50.9M 1 loop /snap/snapd/24505
sda 8:0 0 75G 0 disk
├─sda1 8:1 0 74.9G 0 part /
├─sda14 8:14 0 4M 0 part
└─sda15 8:15 0 106M 0 part /boot/efi