Skip to content

Instantly share code, notes, and snippets.

@nhim175
Last active July 25, 2019 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nhim175/0b71648548ce3a93584994b54333d7ed to your computer and use it in GitHub Desktop.
Save nhim175/0b71648548ce3a93584994b54333d7ed to your computer and use it in GitHub Desktop.
Resizing an EBS volume

Resizing an EBS volume

AWS lets you resize EBS volume without downtime. Here are the steps:

  • Change the size of disk via AWS Console Web UI
  • Login to the EC2 machine
  • Extending the partition
$ lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  16G  0 disk
└─xvda1 202:1    0   8G  0 part /

$ sudo growpart /dev/xvda 1
CHANGED: partition=1 start=2048 old: size=16775135 end=16777183 new: size=33552351,end=33554399

$ lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  16G  0 disk
└─xvda1 202:1    0  16G  0 part /
  • Extending the File System
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/xvda1      7.7G  6.9G  861M  90% /
...

$ sudo resize2fs /dev/xvda1
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/xvda1 is now 4194043 (4k) blocks long.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/xvda1       16G  6.9G  8.6G  45% /
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment