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.

  1. In OCI console navigate to the block volume which you need to resize

    Navigation menu > Storage > Block Volumes (under Block Storage)
    
  2. Click on the particular Block Volume name (bastion_bv1-50GB) and click Edit

  3. On the Edit block volume page increase the size and click Update

  4. After clicking Update a notice will appear from there copy rescan commands

    sudo dd iflag=direct if=/dev/<device_name> of=/dev/null count=1
    echo "1" | sudo tee /sys/class/block/<device_name>/device/rescan
    
  5. 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

  6. Paste the above rescan commands

  7. Again run lsblk command to check for modifications but you will see change in only block volume not in partition and logical volume

  8. 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
    
  9. 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
    
  10. We can verify the change using parted print or lsblk

    parted /dev/sdb print
    
    lsblk
    
  11. Now we need to resize physical volume

    pvresize /dev/sdb1
    
  12. To verify the change we run pvdisplay

    pvdisplay /dev/sdb1
    
  13. When we run pvdisplay we 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 GiB

    vgdisplay vg_u01
    
  14. 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
    
  15. 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

    resize2fs /dev/mapper/vg_u01-lv_u01
    
  16. Now if we verify using df -h it we show us the resized filesystem