Increase the size of EBS volume (Root Volume )in your EC2 instance

Create snapshot

It is best practice to create a snapshot of your volume in case something bad happens.

  1. Go to your Create Snapshot in Elastic Block Storage from your EC2 Dashboard Left side menus.
  2. Click Create Snapshot link.
  3. Select Resource Type Volume
  4. In Volume section choose volume which you want to take snapshot
  5. Click button Create Snapshot.
  6. Go grab some snack while it is in progress.
Create Snapshot

Increase the volume

This is how we will increase the volume size. Make sure your snapshot is finished.

  1. Go to your Volume in Elastic Block Storage section from your EC2 Dashboard Left side menus.
  2. Select volume which you want to increase the size (In our case volume name is test so select test volume) and got to Action Drop down and choose Modify instance as shown in below image
Select Volume which you want to increase
Extend Volume

Extending OS file system

After you finish modifying volume, you need to extend OS file system in order to see your increased volume size. The example below is the command I used for Ubuntu OS.

  1. SSH into you instance.
  2. Type df -h to check volume size; You will still have 8GB of volume size.
  3. Type lsblk ; Your increased volume will be shown just above your current volume, e.g. xvda1 is your current volume with 8GB size and xvda with 10GB size. (NOTE:
  4. Extend the partition by typing sudo growpart /dev/xvda 1 ; Note that dev/xvda is the partition name and 1 is the partition number.
  5. Run The following command to check root filesystem:
    [ec2-user ~]$
    sudo file -s /dev/xvda1
    if filesystem is belong to ext4 then
    Extend the volume by typing
    sudo resize2fs /dev/xvda1 .
    and if filesystem belongs to xfs then run following command
    Extend the volume by typing
    [ec2-user ~]$ sudo xfs_growfs -d /
  6. Type df -h to check volume size; It will show 10GB of volume size.
  7. Enjoy

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store