Repository navigation
Lab 14 ‐ Resizing Block Volumes
In OCI, we cannot directly reduce or shrink the size of a block volume. We can only increase its size.
In OCI, compute shapes and block storage are managed separately. So, we do not need to select a Flex shape to resize a block volume.
To resize a block volume, we first increase its size in the OCI Console and then update it using the PuTTY terminal.
Steps:
- In the OCI Console, navigate to the Block Volume that you want to resize.
Navigation menu > Storage > Block Volumes (under Block Storage)
- Click on the particular Block Volume name (oci_block_volume) and click Edit
- On the Edit block volume page increase the size and click Update
- After clicking Update a notice will appear from there copy rescan commands
sudo dd iflag=direct if=/dev/oracleoci/oraclevd<paste device suffix here> of=/dev/null count=1 echo "1" | sudo tee /sys/class/block/readlink /dev/oracleoci/oraclevd | cut -d'/' -f 2/device/rescan
- Login to instance in PuTTY and run lsblk command to check if volume size is updated but you will see only the physical volume's size is updated
- Paste the above rescan commands
- Again run lsblk command to check for modifications but you will see change in only block volume not in partition and logical volume
- We cannot see any changes in the partition size yet. To view detailed information about the partition table of a storage device (e.g., /dev/sdb), run the command below.
It will show 53.7 GB instead of 50 GB because OCI uses GiB (binary units), while the Linux parted utility displays sizes in GB (decimal units).
9.We need to extend Partition 1 to use all the remaining unallocated space on the volume.
10.We can verify the change using parted print or lsblk
sudo parted /dev/sdb print or lsblk
11.Now we need to resize physical volume
sudo pvresize /dev/sdb1
- To verify the change we run pvdisplay
sudo pvdisplay /dev/sdb1
- When we run pvdisplay, we can see that the size has increased, but the Allocated PE remains the same. So, we check the Volume Group details and see that Free PE is 2560, which equals 10 GiB.
sudo vgdisplay vg_01
- We need to expand logical volume to consume all the remaining unallocated free space available in its parent Volume Group
sudo lvextend -l +100%FREE /dev/mapper/vg_01-lv_01
- We need to verify using lsblk which will show us that Logical Volume is resized but when we run df -h we still see the same so we need to resize filesystem so that it recognizes and utilizes newly added storage space on a logical volume
sudo resize2fs /dev/mapper/vg_01-lv_01
16.Now if we verify using df -h it we show us the resized filesystem df -h