Note:

Extend a logical Block Volume attached to an Oracle Cloud Infrastructure Compute Instance

Introduction

The Oracle Cloud Infrastructure Block Volume service lets you dynamically provision and manage block storage volumes . You can create, attach, connect, and move volumes, as well as change volume performance, as needed, to meet your storage, performance, and application requirements.

While working in Oracle Cloud Infrastructure (OCI) or any other cloud, there can be a requirement for increasing Block Volume size for logical block volumes attached to the instances on cloud. This is a two step process, as step 1 is about identifying and extending the required volume from OCI Console, and step 2 is about extending the volume from OS level after logging into the instance.

Objectives

Prerequisites

Task 1: Extend the volume from OCI Console

  1. Go to the compute instance and then navigate to Resources, Attached block volumes, and click to open the Block Volume.

    Attached Block Volume

  2. Edit the Block Volume and update the size. The new size must be larger than the existing size. You cannot shrink the size of a Block Volume.

    Block Volume

    Edit Block Volume

  3. Save the changes for the Block Volume, and wait for the time the volume is updated and provisioned with the new size on OCI console. Once volume is available again, go to Task 2.

Task 2: Extend the volume from instance OS level

  1. SSH to your instance where the Block Volume is attached, and run the lsblk command to check the filesystem. If it displays as lsblk (for /u01), it means it is a logical volume.

    Check Block Volume

    • By the output of lsblk, you can see the volume of 700 GB is attached to sdb.

    • Also you should notice that sdb is partitioned and divided into logical volumes. Follow further steps only if your volume is attached to a device path which is partitioned and also logically created.

    NOTE: There is another way to identify this, you can execute the readlink command to know about the attachment and compare it with what we can see from OCI console information for Block Volume in Device Path.

  2. Run the following commands to find the device for volume, rescan it and then check the status in lsblk. Now you should see the volume is showing as extended to 1400 GB or 1.4 TB.

    dd iflag=direct if=/dev/mapper/ebs_vg-ebs_lv of=/dev/null
    
    echo "1" | sudo tee /sys/class/block/sdb/device/rescan
    

    Extend Block Volume

  3. Once lsblk is showing the correct extended size, run the pvresize and lvextend commands on the device path and logical path for the required volume and check if the size of volume is resized using the df command. We need to trigger the following command on the device path and logical path on which the Block Volume is attached. For example, here we have it as /dev/sdb and /dev/mapper/ebs_vg-ebs_lv.

    pv resize /dev/sdb
    
    lvextend -l +100%FREE /dev/mapper/ebs_vg-ebs_lv
    

    Extend Block Volume

    Extend Block Volume

    Final command to resize the volume is resize2fs on /dev/mapper/ebs_vg-ebs_lv.

    resize2fs /dev/mapper/ebs_vg-ebs_lv
    
    df -h
    

    Extend Block Volume

We have the extended volume at sdb device path which is mounted to /u01 directory. The new size of the volume is 1.4 TB.

In this way we can extend a Block Volume when it is attached as logical and partitioned device path and mount target.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.