Skip to content

Instantly share code, notes, and snippets.

@btutal
Created March 25, 2020 08:31
Show Gist options
  • Save btutal/d602f545065a613bcb8113f9d71d4df1 to your computer and use it in GitHub Desktop.
Save btutal/d602f545065a613bcb8113f9d71d4df1 to your computer and use it in GitHub Desktop.
How to Extend AWS EBS volumes with no downtime in Ubuntu

Modify Volume on AWS Console

  1. Login to your AWS console
  2. Choose “EC2” from the services list
  3. Click on “Volumes” under ELASTIC BLOCK STORE menu (on the left)
  4. Choose the volume that you want to resize, right click on “Modify Volume
  5. Set the new size for your EBS volume (in this case i extended an 8GB volume to 20GB)
  6. Click on modify.

Now volume needs to be extend on EC2 instance

Extend the volume on Instance

  1. SSH to the EC2 instance
  2. Type lsblk to list our block devices
  3. You should be able to see a similar output
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0 89.1M  1 loop /snap/core/8213
loop1     7:1    0 89.1M  1 loop /snap/core/8268
loop2     7:2    0   18M  1 loop /snap/amazon-ssm-agent/1480
xvda    202:0    0  100G  0 disk 
└─xvda1 202:1    0  16G  0 part /

4.As you can see size of the root volume reflects the new size, 100GB, the size of the partition reflects the original size, 16 GB, and must be extended before you can extend the file system.

sudo growpart /dev/xvda 1
  1. Now we can check that the partition reflects the increased volume size (we can check it with the lsblk command we already used):
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0 89.1M  1 loop /snap/core/8213
loop1     7:1    0 89.1M  1 loop /snap/core/8268
loop2     7:2    0   18M  1 loop /snap/amazon-ssm-agent/1480
xvda    202:0    0  100G  0 disk 
└─xvda1 202:1    0  100G  0 part /
  1. We need to extend the filesystem itself. If your filesystem is an ext2, ext3, or ext4, type:
sudo resize2fs /dev/xvda1
  1. Finally we can check our extended filesystem by typing:
Filesystem      Size  Used Avail Use% Mounted on
udev            480M     0  480M   0% /dev
tmpfs            99M  716K   98M   1% /run
/dev/xvda1       97G   11G   87G  11% /
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/loop0       90M   90M     0 100% /snap/core/8213
/dev/loop1       90M   90M     0 100% /snap/core/8268
/dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1480
tmpfs            99M     0   99M   0% /run/user/1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment