How to Extend Disk Space on an Ubuntu server | Ext4 & XFS | RunCloud

A Guide to Extending Disk Space using Growpart and resize2fs or Xfs_growfs Commands


When using a virtual private server (VPS), it's common to have the ability to increase the disk space on demand. However, simply requesting an increase in disk space doesn't automatically update your VPS to use the additional space. 

Introduction


In this blog post, we'll discuss how to extend disk space using the "growpart" and "resizefs"(or xfs_growfs) commands. We'll also cover why some users might experience issues with their disk space not being updated after their server provider has updated it.

Section 1

 Checking Current Disk Space Usage Before beginning the process of extending your disk space, it's a good idea to check your current disk space usage. This can be done by running the command "df -Th", which will display the current disk space usage for each partition along with file system type like ext4 or xfs etc.

Section 2

 Extending the Partition Using Growpart Command To extend the partition, you'll need to use the "growpart" command followed by the device and partition number. For example, if you want to extend the first partition on the device "/dev/sda", you can run the command.

sudo growpart /dev/sda 1

If you have multiple partitions, you'll need to repeat this step for each partition.

Section 3

 Resizing the File System Using Resizefs Command After extending the partition, you'll need to resize the file system to use the newly resized partition. For EXT4 type, To do this, use the "resizefs" command followed by the device and partition number. For example:

sudo resize2fs /dev/sda1

This command will resize the file system on the first partition of the device "/dev/sda".

For XFS file type, Resizing the File System Using Xfs_growfs Command After extending the partition, you'll need to resize the file system to use the newly resized partition. To do this, use the "xfs_growfs" command followed by the mount point of the file system. For example:

sudo xfs_growfs /mnt/filesystem

This command will resize the XFS file system mounted at "/mnt/filesystem" to use the newly resized partition.

Section 4

 Checking New Disk Space Usage Once you've completed the above steps, it's important to check the new disk space usage to confirm that the additional space is now being used. You can do this by running the command "df -h" again.

Section 5

 Troubleshooting Issues If you're still not seeing the additional disk space after completing the above steps, it's possible that your server provider has not yet updated your VPS with the additional space. It's important to note that updating disk space at the server provider side might take some time, and it can take up to several hours for the additional space to become available. In some cases, a server reboot may also be required for the changes to take effect. If you continue to experience issues, it's best to reach out to your server provider for further assistance.

Conclusion

 Extending disk space is a straightforward process that can be done on demand. By following the steps outlined in this guide, you can easily extend your disk space to make use of the additional space provided by your server provider.




Comments