Note:
- This tutorial requires access to Oracle Cloud. To sign up for a free account, see Get started with Oracle Cloud Infrastructure Free Tier.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
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
- Extend the volume from OCI Console.
- Identify if the volume is attached as logical and then execute the correct set of commands to extend it.
Prerequisites
-
Have required access permissions allowed in Oracle Cloud Infrastructure Identity and Access Management (OCI IAM). The resources required are allowed to create/extend block volumes and view compute instance to which the volume is attached.
-
Access to all required components to view their OCIDs and other relevant information.
-
Access to OCI Cloud Shell or client like putty using which user can access the compute instance on OS level.
Task 1: Extend the volume from OCI Console
-
Go to the compute instance and then navigate to Resources, Attached block volumes, and click to open the Block Volume.
-
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.
-
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
-
SSH to your instance where the Block Volume is attached, and run the
lsblk
command to check the filesystem. If it displays aslsblk
(for/u01
), it means it is a logical 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.
-
-
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
-
Once
lsblk
is showing the correct extended size, run thepvresize
andlvextend
commands on the device path and logical path for the required volume and check if the size of volume is resized using thedf
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
Final command to resize the volume is resize2fs on /dev/mapper/ebs_vg-ebs_lv.
resize2fs /dev/mapper/ebs_vg-ebs_lv df -h
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.
Related Links
Acknowledgments
- Lovelesh Saxena (Cloud Engineering Architect)
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.
Extend a logical Block Volume attached to an Oracle Cloud Infrastructure Compute Instance
F85583-01
August 2023
Copyright © 2023, Oracle and/or its affiliates.