Comment on page
How to extend a partition
In Linux, you may need to extend a partition after increasing the underlying disk size. This guide will walk you through the steps using the growpart and resize2fs commands to achieve this.
- a VPS
- an OnetSolutions account
Before you begin, ensure the following:
- 1.Backup Data: Always back up your data before making any changes to disk partitions to avoid data loss.
- 2.Access: Ensure that you have administrative or root access to the Linux system.
- 3.Required Tools: Make sure you have the following tools installed:
growpart: Used to resize a partition.
resize2fs: Used to resize the filesystem within the partition.
- 1.Open a terminal.
- 2.Use the
lsblkcommand to list the available disks and their partitions:lsblkIdentify the disk and partition you want to extend. Note the device name (e.g.,
/dev/vda) and partition number (e.g.,
- 1.Run the
growpartcommand to extend the partition to use all available space on the disk:sudo growpart /dev/<device_name> <partition_number>Replace
<device_name>with the actual device name (e.g.,
<partition_number>with the partition number (e.g.,
- 2.Verify that the partition has been resized by running the
lsblkcommand again. The partition should now show the increased size.
- 1.Run the
resize2fscommand to resize the filesystem to fill the newly extended partition:sudo resize2fs /dev/<device_name><partition_number>Replace
<partition_number>with the actual device name and partition number from Step 1.
resize2fscommand will automatically adjust the filesystem size to match the partition size.
- 1.To confirm that the partition and filesystem have been successfully extended, you can run the
dfcommand to display disk space usage:df -hCheck if the partition in question now shows the increased size.
Congratulations! You have successfully extended a partition after increasing the disk size using the
resize2fscommands. Your system should now have more available storage space.
Remember to carefully follow these steps and back up your data before making any changes to disk partitions to avoid potential data loss.