Repository navigation
LAB 15 ‐ Resizing Block Volumes
In Oracle Cloud Infrastructure, block volumes can be resized to increase storage capacity without recreating the volume or losing data.
This feature allows you to:
-
Expand storage as your data grows
-
Avoid downtime in most cases
-
Dynamically scale your infrastructure
👉 After resizing the block volume in OCI, you must also extend the partition/LVM and file system at the OS level to use the additional space.
The block volume size was first updated to 60GB from the OCI Console. This confirms that the additional storage has been successfully allocated.
Note: At this stage, the increased size is visible in the console but is not yet usable inside the instance.
When you click on copy then copy the both rescan command in your notepad because we will use it later.
Although the volume shows 60GB in the console, it is not usable until the partition, LVM, and filesystem are extended from the instance. These steps were performed using PuTTY.
Next, we will use a rescan command that needs to be run in PuTTY to increase the size of the block volume.
Before running this command, we will check the size of block volume
lsblk
To check the current size of the specific disk we want to increase
lsblk -ap /dev/sdb | head -2
Now, Edit the copied rescan command (that you have copied from the OCI console) according to the current requirement (i.e., which disk we want to upgrade ex. /dev/sdb because sdb is the disk here)
sudo dd iflag=direct if=/dev/sdb of=/dev/null count=1
echo "1" | sudo tee /sys/class/block/sdb/device/rescan
and then run lsblk command to check disk size is increased or not
lsblk
lsblk -ap /dev/sdb | head -2
sudo parted /dev/sdb print
sudo growpart /dev/sdb 1
Again run the partition command and check the size of part
sudo parted /dev/sdb print
Now size of the partition is increased
Run lsblk command and check size of disk and partition
lsblk
As we can see, the size has increased
Now, run the command to display detailed information about a specific logical volume (lv_u01) in a volume group (vg_u01)
sudo su - root
lvdisplay -am /dev/mapper/vg_u01-lv_u01
The logical volume is still the same as before; it has not increased yet
next, we Resize the Physical Volume
pvresize /dev/sdb1
pvdisplay /dev/sdb1
Physical volume still display the old volume in allocated PE
we can check volume group allocated PE also
vgdisplay vg_u01
As we can see below, Logical volume is still not increased
df -h
lsblk
Now, we Extend the Logical volume
lvextend -l +100%FREE /dev/mapper/vg_u01-lv_u01
Logical volume is increased now
lsblk
But df –h still shows the old value
df -h
The last step is to resize the file system to extended 10 gb with right file format
resize2fs /dev/mapper/vg_u01-lv_u01
Finally, as shown in the screen below, running df -h confirms that the logical volume has been extended to the required size