Guangning Yu's Blog

Expand the EBS root volume of EC2 Linux instance

2019-02-24 07:10:42  |  AWS
  1. Modify the EBS Volume from the console https://console.aws.amazon.com/ec2/
  2. Use the lsblk command to list the block devices attached to the instance

    1. $ lsblk
    2. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    3. xvda 202:0 0 30G 0 disk
    4. `-xvda1 202:1 0 8G 0 part /
    5. loop0 7:0 0 91M 1 loop /snap/core/6405
    6. loop1 7:1 0 87.9M 1 loop /snap/core/5742
    7. loop2 7:2 0 17.9M 1 loop /snap/amazon-ssm-agent/1068
    8. loop3 7:3 0 16.5M 1 loop /snap/amazon-ssm-agent/784
    9. loop4 7:4 0 18M 1 loop /snap/amazon-ssm-agent/930
  3. Use the df -h command to report the existing disk space usage on the file system

    1. $ sudo df -h /dev/xvd*
    2. Filesystem Size Used Avail Use% Mounted on
    3. udev 488M 0 488M 0% /dev
    4. /dev/xvda1 7.7G 7.4G 370M 96% /
  4. Expand the modified partition using growpart

    1. $ sudo growpart /dev/xvda 1
    2. CHANGED: partition=1 start=2048 old: size=16775135 end=16777183 new: size=62912479,end=62914