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