LAB 16 ‐ Resizing Block Volumes - gautam-amitesh/OCI GitHub Wiki
Resizing Block Volumes
In OCI we can't directly shrink or reduce the size of block volume due to which resizing block volume means expanding volume capacity. In OCI compute shapes and block storage are managed independently so it is not important to select a flex shape to be able to resize block volume. To resize a block volume first we need to do it in OCI console and then we need to update it via PuTTY terminal.
-
In OCI console navigate to the block volume which you need to resize
Navigation menu > Storage > Block Volumes (under Block Storage) -
Click on the particular Block Volume name (bastion_bv1-50GB) and click
Edit -
On the Edit block volume page increase the size and click
Update -
After clicking
Updatea notice will appear from there copy rescan commandssudo dd iflag=direct if=/dev/<device_name> of=/dev/null count=1 echo "1" | sudo tee /sys/class/block/<device_name>/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
lsblkcommand to check for modifications but you will see change in only block volume not in partition and logical volume -
We can't see any change in partition so to display detailed information about the partition table of a specific storage device (eg. /dev/sdb) we run below command. It will show 53.7GB instead of 50GB because OCI use GiB (binary) and linux parted utility use standard metric GB (decimal) to display sizes)
parted /dev/sdb print -
We see no change in partition size so we need to extend the partition 1 so that it fills all the remaining unallocated space on the volume
growpart /dev/sdb 1 -
We can verify the change using
parted printorlsblkparted /dev/sdb printlsblk -
Now we need to resize physical volume
pvresize /dev/sdb1 -
To verify the change we run
pvdisplaypvdisplay /dev/sdb1 -
When we run
pvdisplaywe see size grown but Allocated PE remained same so we first need to check Volume Group details which shows Free PE is 2560 which is equal to 10 GiBvgdisplay vg_u01 -
We need to expand logical volume to consume all the remaining unallocated free space available in its parent Volume Group
lvextend -l +100%FREE /dev/mapper/vg_u01-lv_u01 -
We need to verify using
lsblkwhich will show us that Logical Volume is resized but when we rundf -hwe still see the same so we need to resize filesystem so that it recognizes and utilizes newly added storage space on a logical volumeresize2fs /dev/mapper/vg_u01-lv_u01 -
Now if we verify using
df -hit we show us the resized filesystem