Question
How to increase the existing "/" volume of a running EC2 instance?
Solution
This article explains the procedure to increase the root partition, after a VNF is deployed on AWS with a lesser disk size.
Follow these steps to increase the volume associated with EC2 from 80GB to 100 GB.
- Log into the AWS Management Console.
- Navigate to EC2 Dashboard > Volumes.
- Search for the EC2 instance.
- Run the lsblk Linux command to check volume associated with the EC2.
Exampleubuntu@ip-172-31-16-9:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 80G 0 disk └─xvda1 202:1 0 80G 0 part /
- Click Actions and select Modify Volume.
The Modify Volume window is displayed.
- Modify the size by entering a value in the Size field.
- Click Yes.
- Run the lsblk Linux command to check the updated size.
Exampleubuntu@ip-172-31-16-9:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 100G 0 disk └─xvda1 202:1 0 80G 0 part /
-
Run the sudo /sbin/parted ---pretend-input-tty /dev/xvda resizepart 1 yes 100% command to expand the partition.
Exampleubuntu@ip-172-31-16-9:~$ sudo /sbin/parted ---pretend-input-tty /dev/xvda resizepart 1 yes 100% Warning: Partition /dev/xvda1 is being used. Are you sure you want to continue? Information: You may need to update /etc/fstab.
-
Run the sudo resize2fs /dev/xvda1 command to expand the file system.
Exampleubuntu@ip-172-31-16-9:~$ sudo resize2fs /dev/xvda1 resize2fs 1.42.9 (4-Feb-2014) Filesystem at /dev/xvda1 is mounted on /; on-line resizing required old_desc_blocks = 5, new_desc_blocks = 7 The filesystem on /dev/xvda1 is now 26212391 blocks long.
-
Run the lsblk Linux command to check the updated EC2 volume.
Exampleubuntu@ip-172-31-16-9:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 100G 0 disk └─xvda1 202:1 0 100G 0 part /
-
Run the df -kh command to display the sizes and file system information.
Exampleubuntu@ip-172-31-16-9:~$ df -kh Filesystem Size Used Avail Use% Mounted on udev 3.7G 8.0K 3.7G 1% /dev tmpfs 748M 372K 748M 1% /run /dev/xvda1 99G 2.7G 92G 3% / none 4.0K 0 4.0K 0% /sys/fs/cgroup none 5.0M 0 5.0M 0% /run/lock none 3.7G 0 3.7G 0% /run/shm none 100M 0 100M 0% /run/user