How to resize a cloud volume partition

After extending a volume, it’s important to ensure that the operating system is able to detect and use the additional storage space.

In this article, we’ll walk you through the steps to resize the partition of a volume attached to a Linux instance. By following these steps, you’ll be able to make full use of the additional storage space that you’ve allocated to your volume, and ensure that your system is running efficiently and reliably.

Note: Before unmounting a volume, ensure that there are no running applications actively using the volume as it can result in data loss or corruption.

Steps

  • 1
    First, ensure that the volume is attached to an instance and a file system is mounted to the volume
  • 2
    Connect to the instance’s command line interface (CLI) using your favourite SSH client and ensure you are logged in.
  • 3
    Check to see if the system has detected the new size of the volume. You can do this by running the following command:
    sudo lsblk -p
    This will display a list of all the available storage devices on your machine, including the attached volume. Check the size of the volume to see if it reflects the new size.
  • 4
    Unmount the volume first by using the following command:
    sudo umount /mnt/myvolume 
    Replace /mnt/myvolume with the directory to which the volume was mounted as displayed by the command in Step 3.  
  • 5
    To prepare the volume for resizing, execute the following command:
    sudo e2fsck -f /dev/vdb
    Replace /dev/vdb with the name of your volume.
  • 6
    Next, use the following command to resize the partition on the volume:
    sudo resize2fs /dev/vdb
    Replace /dev/vdb with the name of your volume.
  • 7
    Once the resize operation is complete, you can remount the volume using the following command:
    sudo mount /dev/vdb /mnt/myvolume 
    Replacing  /dev/vdb with the name of your volume and  /mnt/myvolume with your initial directory.
  • 8
    After resizing the file system and mounting it again, verify that the new size is reflected on the volume by running the following command:
    sudo df -h