AWS: Extending Harddrive Online

Revamping/Revisioning content - Still busy - 19/06/2017 18:00

This example doesn't include support for LVS yet. Will add this later. Basics do apply: pvscan, extend pv, add lv space, done!

Login to your server

login as: ec2-user
Authenticating with public key "imported-openssh-key"
Last login: Mon Jun 19 09:37:29 2017 from 123-123-123-123.adsl.xs4all.nl

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2017.03-release-notes/

Check which partition/disk and type (regular/lvs) you want to extend

$ cat /proc/partitions
[ec2-user@ip-345-234-345-345 ~]$ cat /proc/partitions
major minor  #blocks  name

 202        0  681574400 xvda
 202        1  681572335 xvda1
[ec2-user@ip-345-345-345-345 ~]$

This example has only one attached disk with several partitions (0 = boot, 1 = /). Always check which partition it is you want to extend later. The disk is the same but the partition number you want to resize/extend might be different.

$ df
[ec2-user@ip-345-234-345-345 ~]$ df
Filesystem     1K-blocks      Used Available Use% Mounted on
devtmpfs         7821156        60   7821096   1% /dev
tmpfs            7830092         0   7830092   0% /dev/shm
/dev/xvda1     670747036 393213516 277433272  59% /
You have new mail in /var/spool/mail/ec2-user
[ec2-user@ip-345-345-345-345 ~]$

Important to check

/dev/xvda1     670747036 393213516 277433272  59% /

Take a note: it is partition 1 (/) We will extend

Change the volume in AWS

Adding screenshot here soon!

Now:

$ sudo growpart /dev/xvda 1

Note the space between xvda and 1 !

[ec2-user@ip-345-234-345-345 ~]$
 
[ec2-user@ip-345-345-345-345 ~]$

Error

[ec2-user@ip-345-234-345-345 ~]$ sudo growpart /dev/xvda 1
NOCHANGE: disk=/dev/xvda partition=1: size=1363144670, it cannot be grown
[ec2-user@ip-345-345-345-345 ~]$
[ec2-user@ip-345-234-345-345 ~]$
 
[ec2-user@ip-345-345-345-345 ~]$

The disk and the partition are bigger now, but you aren't using the space yet. To facilitate this, we will need to resize the filesystem on top of the partition. We do this "online" with resize2fs

$ sudo resize2fs /dev/xvda1

Error

[ec2-user@ip-345-234-345-345 ~]$ sudo resize2fs /dev/xvda1
resize2fs 1.42.12 (29-Aug-2014)
The filesystem is already 170393083 (4k) blocks long.  Nothing to do!
[ec2-user@ip-345-345-345-345 ~]$

Done!

Author: Angelique Dawnbringer Published: 2014-02-08 09:00:21 Keywords:
  • AWS
  • Extending Harddrive
  • fdisk
  • diskpart
  • grow
  • resize2fs
Modified: 2017-07-24 12:19:48