103 ‐ Resizing Block Volumes - SanjeevOCI/Ocidocs GitHub Wiki

Resize and Extend Block Volumes on OCI Compute Instances

Applies to: OCI Linux compute instances with OCID block volumes
Goal: Increase a block volume’s size and extend the filesystem on the instance so that extra space becomes usable.


✅ Prerequisites

  • A running OCI Compute instance with a block volume attached (e.g. /dev/sdb)
  • Sudo access on the Linux instance
  • Current block volume size (e.g. 50 GB)
  • Understanding of partitions, logical volumes (if applicable), and filesystems (e.g. ext4, XFS)

First step is to resize the block volume in OCI

Step 1 : Increase size in console.

Note :- The existing size is 50 GB.

  1. Select the Edit option on the Block Volume page.

Block_Volume_Resizing_1

  1. Enter the new size you want for the volume and click on save changes.

Block_Volume_Resizing_2


Step 2 : Increase Disk Size

After saving the changes, we get the "Resize Block Volume" box containing the volume rescan commands, as shown below. These 2 commands need to be copied and run in the Linux server(via Putty) to increase the size of the block volume.

Note :- After running the volume rescan commands, we also need to extend the partition for the volume resize to take effect

Block_Volume_Resizing_3

  1. Before running the volume rescan commands, we need to check the size of block volume using "lsblk" command

lsblk

Block_Volume_Resizing_4

  1. We also need to run the command "lsblk -ap /dev/sdb | head -2" to check the current size of the specific disk, which we want to increase

lsblk -ap /dev/sdb | head -2

Block_Volume_Resizing_5

  1. This is an important step. We need to **Edit **the copied rescan commands according to the actual disk name in the Linux we want to upgrade

Copied rescan commands

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

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

Updated rescan commands

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

echo "1" | sudo tee /sys/class/block/sdb/device/rescan

  1. Run the lsblk command to check whether the disk size is increased or not

lsblk

lsblk -ap /dev/sdb | head -2

  1. We can see that the disk size is increased

Block_Volume_Resizing_6

Block_Volume_Resizing_7

  1. However, logical volume & partition size is still not increased

Block_Volume_Resizing_8


Step 3 : Verify in Linux server whether the partition exists

Run the command "sudo parted /dev/sdb print" to check the Disk and the partition size

sudo parted /dev/sdb print

In the output shown below, we can see that the disk size has increased, but the partition size remains the same as before.

Block_Volume_Resizing_9

Note :- Even though we are increasing the volume size from 50 to 70 GB, the disk size shows as 75.2 GB. This is coz Oracle gives some extra space.

Step 4 : **Grow **the partition size to the new size - 70 GB

  1. Use the command "sudo growpart /dev/sdb 1" to grow the partition

sudo growpart /dev/sdb 1

  1. We are able to see both the old and new size of partition

Block_Volume_Resizing_10

  1. Again run the partition command and check the size of part. The size of the partition is now increased.

sudo parted /dev/sdb print.

Block_Volume_Resizing_11

  1. Run lsblk command and check size of disk and partition

lsblk

As we can see, the size of disk and partition has increased, but logical volume

Block_Volume_Resizing_12

  1. Now, run the command to display detailed information about a specific logical volume (lv_u01) in a volume group (vg_u01)

lvdisplay -am /dev/mapper/vg_u01-lv_u01

The logical volume is still the same as before; it has not increased yet

Block_Volume_Resizing_13

  1. Next step is to Resize the Physical Volume using the below commands

pvresize /dev/sdb1 pvdisplay /dev/sdb1

Physical volume still display the old volume in allocated PE

Block_Volume_Resizing_14

  1. We can check volume group allocated PE also

vgdisplay vg_u01

in below screen, we can see total PE, allocated PE and free PE

Block_Volume_Resizing_15

  1. As we can see below, Logical volume size is still not increased

Block_Volume_Resizing_16

Block_Volume_Resizing_17

  1. To increase the Logical volume size, we need to Extend the Logical volume size using the command below

lvextend -l +100%FREE /dev/mapper/vg_u01-lv_u01

Block_Volume_Resizing_18

  1. Logical volume is increased now. However "df -h" still shows the old value

Block_Volume_Resizing_19

Block_Volume_Resizing_20

  1. The last step is to resize the file system to extended 20 GB with right file format

resize2fs /dev/mapper/vg_u01-lv_u01

Block_Volume_Resizing_21

  1. Finally, as shown in the screen below, running df -h confirms that the logical volume has been extended to the required size

Block_Volume_Resizing_22

8. ✅ Summary

In this lab, we increased the size of an OCI block volume and extended it all the way into our OS’s filesystem.
We learned to:

  • Resize the block volume via OCI console
  • Rescan the block device inside Linux
  • Grow partition and/or LVM structures (PV, VG, LV)
  • Expand the filesystem (ext4/XFS) to make the extra space usable

This operation is essential during scale-ups, storage extensions, or when application load grows.