How to extend EBS boot disk on AWS without an instance reboot

Cpanel/Whm License $3/mo Plesk License $10/mo Cloudlinux License $5/mo

(: April 19, 2019)

On AWS, you can increase EBS volume size, adjust performance, or change the volume type while the volume is in use. The change should guarantee zero downtime, and without any effect on the application operations.

In this example, I’ll extend the boot disk of a CentOS 7 server from 8 GB to 20 GB

Step 1: Resize boot Volume on EBS

Login to AWS console and navigate to:

.td_uid_2_5d906e91abd7d_rand.td-a-rec-img{text-align:left}.td_uid_2_5d906e91abd7d_rand.td-a-rec-img img{margin:0 auto 0 0}

EBS > Volumes > Right Click on volume name > Modify Volume

Change the size from 8 to 20 or whichever value you want to grow to, then click “Modify

Confirm that you want to grow disk.

A successful message should look like below

Step 2: Login to the server via ssh and extend / partition

SSH into your EC2 instance and check block device current size.

# lsblk 
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
xvda          202:0    0    20G  0 disk 
└─xvda1       202:1    0    8G   0 part /

You can see /dev/xvda1 is still 8 GB in size. We need to resize it to 20 GB using the growpartcommand.

Install cloud utils

On Ubuntu / Debian system, run

sudo apt install -y cloud-guest-utils

For CentOS server, run

sudo yum -y install cloud-utils-growpart

For those new to growpart, it is Linux command line tool used to extend a partition in a partition table to fill available space.

Help page can be viewed by passing -h argument.

# growpart -h
growpart disk partition
   rewrite partition table so that partition takes up all the space it can
   options:
    -h | --help       print Usage and exit
         --fudge F    if part could be resized, but change would be
                      less than 'F' bytes, do not resize (default: 1048576)
    -N | --dry-run    only report what would be done, show new 'sfdisk -d'
    -v | --verbose    increase verbosity / debug
    -u | --update  R  update the the kernel partition table info after growing
                      this requires kernel support and 'partx --update'
                      R is one of:
                       - 'auto'  : [default] update partition if possible
                       - 'force' : try despite sanity checks (fail on failure)
                       - 'off'   : do not attempt
                       - 'on'    : fail if sanity checks indicate no support

   Example:
    - growpart /dev/sda 1
      Resize partition 1 on /dev/sda

In our case, we will run

sudo growpart /dev/xvda 1

New disk size should be 20 GB

# lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
xvda          202:0    0    20G  0 disk
└─xvda1       202:1    0    20G  0 part /

Step 3: Resize `/` partition to fill all space

The last step is to resize the file system to grow all the way to fill added space

For ext4 file system, use resize2fs

sudo resize2fs /dev/xvda1

If your filesystem is xfs, an XFS file system may be grown while mounted using the xfs_growfscommand:

sudo xfs_growfs /

Both of these commands will grow the file system to the maximum size supported by the device.

Confirm new size using df -h

# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/xvda1              20G  8.2G   12G  41% /

Congratulations!, you managed to extend a mounted / partition without any downtime.

Other disk management articles available are:

How to resize an ext2/3/4 and XFS root partition without LVM

How to extend root filesystem using LVM on Linux.

How to extend/increase KVM Virtual Machine (VM) disk size

Other AWS articles available in our blog are:

Create AWS S3 Upload and List Objects Policy without Delete Action

How to Configure Cpanel Backups to S3 Object Store

How to Install and Use AWS CLI on Linux – Ubuntu / Debian / CentOS

How to Reset RDS Master User Password on AWS

.td_uid_4_5d906e91abf75_rand.td-a-rec-img{text-align:left}.td_uid_4_5d906e91abf75_rand.td-a-rec-img img{margin:0 auto 0 0}

Related posts

How to change root password on Alpine Linux

SXI ADMIN

BIS Report: Wide-Scale DLT Use ‘Years Away’

SXI ADMIN

Bitcoin Reputation Startup Bonafide to Shut Down

SXI ADMIN

Bitcoin Poker Site Seals With Clubs Closes After Security Compromise

SXI ADMIN

Thailand’s Securities Watchdog Approves Country’s First ICO Portal

SXI ADMIN

Pakistani Bank Teams With Alipay for Blockchain Remittances

SXI ADMIN

Explain Usage Of The Linux Left Bracket /usr/bin/[ Command

SXI ADMIN

Linux / UNIX: Bash Loop Forever

SXI ADMIN

Macbook Shell / MacbookPro shell: Protective Leather Shell

SXI ADMIN

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More