In this post, I would like to explain to extend the hard disk volume of an Ubuntu instance running on Amazon Web Services (AWS), you can follow these steps:
Step 1: Log in to the AWS Management Console and navigate to the EC2 dashboard.
Step 2: Stop the Ubuntu instance that you want to extend the hard disk volume of. (Recommended)
Step 3: In the left-hand menu, click on “Volumes” under the “Elastic Block Store” section.
Step 4: Find the volume that is attached to the Ubuntu instance and select it.
Step 5: Click on the “Actions” button and select “Modify Volume” from the dropdown menu.
Step 6: In the “Modify Volume” dialog box, enter the new size for the volume and click on “Modify”.
Step 7: Start the Ubuntu instance.
Step 8: SSH into the Ubuntu instance.
Step 9: Run the following command to check the file system type:
1 | sudo file -s /dev/xvda1 |
Note that the device name (/dev/xvda1) may differ depending on your setup.
or run the command
1 | sudo lsblk |
We will see as
1 2 3 4 | NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 16G 0 disk └─xvda1 202:1 0 8G 0 part / xvdf 202:80 0 24G 0 disk |
Step 10: If the file system is ext4, you can use the following command to resize it:
1 | sudo resize2fs /dev/xvda1 |
or run the command as
1 | sudo growpart /dev/xvda 1 |
Step 11: If the file system is XFS, you can use the following command to resize it:
1 | sudo xfs_growfs / |
Step 12: Verify that the disk space has been extended by running the following command:
1 | df -h |
Extend the file system
1 | df -hT |
This should display the new size of the root file system.
That’s it! You have successfully extended the hard disk volume of your Ubuntu instance running on AWS.
0 Comments