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.

  1. Log into the AWS Management Console
  2. Navigate to EC2 Dashboard > Volumes.
  3. Search for the EC2 instance.
  4. Run the lsblk Linux command to check volume associated with the EC2.
    Example
    ubuntu@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 /
  5. Click Actions and select Modify Volume.
    The Modify Volume window is displayed.
  6. Modify the size by entering a value in the Size field.

  7. Click Yes.
  8. Run the lsblk Linux command to check the updated size.
    Example
    ubuntu@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 /
    
    


  9. Run the sudo /sbin/parted ---pretend-input-tty /dev/xvda resizepart 1 yes 100% command to expand the partition.
    Example

    ubuntu@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.


  10. Run the sudo resize2fs /dev/xvda1 command to expand the file system.
    Example

    ubuntu@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.


  11. Run the lsblk Linux command to check the updated EC2 volume.
    Example

    ubuntu@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 /


  12. Run the df -kh command to display the sizes and file system information.
    Example

    ubuntu@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