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.
Requirements
a VPS
an OnetSolutions account
Instructions
Prerequisites
Before you begin, ensure the following:
Backup Data: Always back up your data before making any changes to disk partitions to avoid data loss.
Access: Ensure that you have administrative or root access to the Linux system.
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.
Step 1: Identify the Disk and Partition
Open a terminal.
Use the
lsblk
command to list the available disks and their partitions:Identify the disk and partition you want to extend. Note the device name (e.g.,
/dev/vda
) and partition number (e.g.,/dev/vda1
).
Step 2: Extend the Partition
Run the
growpart
command to extend the partition to use all available space on the disk:Replace
<device_name>
with the actual device name (e.g.,/dev/vda
) and<partition_number>
with the partition number (e.g.,1
).Verify that the partition has been resized by running the
lsblk
command again. The partition should now show the increased size.
Step 3: Resize the Filesystem
Run the
resize2fs
command to resize the filesystem to fill the newly extended partition:Replace
<device_name>
and<partition_number>
with the actual device name and partition number from Step 1.The
resize2fs
command will automatically adjust the filesystem size to match the partition size.
Step 4: Verify the Changes
To confirm that the partition and filesystem have been successfully extended, you can run the
df
command to display disk space usage:Check if the partition in question now shows the increased size.
Congratulations! You have successfully extended a partition after increasing the disk size using the growpart
and resize2fs
commands. 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.
Last updated
Was this helpful?