How to extend instance storage on Amazon EC2

- by

AWS LogoI’ve just launched an EC2 instance from my own AMI. This time however I wanted it to have more storage so I increased the size of my disk space from 10 to 100GB.

Once the instance had launched I’ve noticed that – as before – only 10GB was actually available.

I’ve had this with other infrastructure before, and I knew that I had to extend the volume as well as the volume and the file system for the OS to recognise the extra space.

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde1            9.9G  2.6G  6.9G  27% /
tmpfs                 1.8G     0  1.8G   0% /dev/shm

What puzzled me was the following error message when using the lvextend command:

lvextend -L +97G /dev/xvde

Path required for Logical Volume "xvde"
Please provide a volume group name
Run `lvextend --help' for more information.

Was I not using the command correctly? Had I miscalculated the space I had in addition? I checked again with fdisk -l:

fdisk -l

Disk /dev/xvde1: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/xvdj: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Nope, I was right – but lvextend wasn’t happy.

The Solution

Amazon had already extended the volume – all I had to do was grow the file system:

resize2fs /dev/xvde1

resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/xvde1 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 7
Performing an on-line resize of /dev/xvde1 to 26214400 (4k) blocks.
The filesystem on /dev/xvde1 is now 26214400 blocks long.

Let’s check it out:

df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde1             99G  2.6G   91G   3% /
tmpfs                 1.8G     0  1.8G   0% /dev/shm

Sometimes things are actually easier than we think 😉



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.