Extend the file system of a cloud volume

Note: This tutorial applies to Linux operating systems using the ext4 file system.

In xneelo Cloud you can extend your storage volumes at any time to increase the size and access more storage.

However, when an attached volume is resized, the file system on the volume does not automatically resize to use the new space. You need to do this manually.

This requires both the partition and the file system to be extended. Follow the steps below to learn how.



  • Confirm the resize has been detected

    By following the steps below you will be able to confirm if the system has successfully detected the new size of the volume.

    Note: If you do not see the volume listed, ensure that the volume is attached to an instance and a file system is mounted to the volume.

    Steps

    1. 1
      Connect to the instance via SSH.
    2. 2
      Type in the following command:

          sudo lsblk -p
          1. 3
            This will display a list of volumes and their partitions attached to the instance.
          2. 4
            Confirm if the size of the volume (and the partition) has been updated.
          3. 5
            Follow on to the next steps to extend the file system.





        • Extend the file system (boot / partitioned volume)

          Follow these steps to extend the file system of the boot volume of a cloud instance, or a partitioned volume.

          Note: Instance boot volumes are partitioned drives.

          Extend the partition

          The partition must be extended to fill the available free space on the disk. This is only required if the partition size is smaller than the volume size (see previous steps to confirm the resize). 

          If this is not required, move onto the extend the file system steps below.

          Steps

          1. 1
            Type in the following command:

                  sudo growpart /dev/myvolume 1

                  Replace /dev/myvolume with the name of your volume.

                  Replace 1 with the partition number (this is the number after the p shown in the previous example in myvolumep1).

                  1. 2
                    Verify that the partition has been extended with the following command:

                            sudo lsblk -p
                            1. 3
                              The partition size should now be equal to the volume size.
                            2. 4
                              Follow on to the next steps to extend the file system.

                            Extend the file system

                            Steps

                            1. 1
                              Use the following command to resize the file system on the volume:

                                            sudo resize2fs /dev/myvolume

                                            Replace /dev/myvolume with the name of your volume.

                                                                        1. 2
                                                                          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

                                                                        You can now access the additional storage space on your Cloud volume.





                                                                      • Extend the file system (attached volume)

                                                                        Follow these steps to extend the file system of volume that is attached to a cloud instance.

                                                                        It is recommended to unmount the volume before resizing the file system. 

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

                                                                        Steps

                                                                        1. 1
                                                                          Unmount the volume first by using the following command:

                                                                        sudo umount /mnt/myvolume

                                                                        Replace /mnt/myvolume with the directory of the volume.

                                                                        1. 2
                                                                          To prepare the volume for resizing, execute the following command:

                                                                        sudo e2fsck -f /dev/myvolume

                                                                        Replace /dev/myvolume with the name of your volume.

                                                                        1. 3
                                                                          Next, use the following command to resize the file system on the volume:

                                                                        sudo resize2fs /dev/myvolume

                                                                        Replace /dev/myvolume with the name of your volume.

                                                                        1. 4
                                                                          Once the resize operation is complete, you can remount the volume using the following command:

                                                                        sudo mount /dev/myvolume /mnt/myvolume

                                                                        Replacing  /dev/myvolume with the name of your volume and  /mnt/myvolume with your initial directory.

                                                                        1. 5
                                                                          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

                                                                        You can now access the additional storage space on your Cloud volume.



                                                                      Assist Note

                                                                      Take a look at our other articles and guides on xneelo Cloud.