Growing Amazon EBS Volume sizes [closed]
Asked Answered
C

11

154

I'm quite impressed with Amazon's EC2 and EBS services. I wanted to know if it is possible to grow an EBS Volume.

For example: If I have a 50 GB volume and I start to run out of space, can I bump it up to 100 GB when required?

Chinoiserie answered 15/2, 2009 at 12:16 Comment(6)
I have written a tutorial to grow the size of your ebs volume at - aws-musings.com/how-to-expand-your-ebs-volumeClarettaclarette
Great question (+1). Better fit for Server Fault though?Anoxia
Please upvote this answer as it is much more up to date: https://mcmap.net/q/56615/-growing-amazon-ebs-volume-sizes-closedProspect
@Anoxia I totally agree. For those who can (and also agree) please vote to reopen this question so that it can be migrated. Unless some mod reading this can do the same?Sansone
This should be migrated to Server Fault, if for no other reason than to allow more current answers (such as one that references AWS's documentation on this topic at docs.aws.amazon.com/AWSEC2/latest/UserGuide/…)Easily
I flagged this question for migration, but it is ineligible for migration because it is too old.Easily
M
9

All great recommendations, and I thought I'd add this article I found, which relates to expanding a Windows Amazon EC2 EBS instance using the Amazon Web UI tools to perform the necessary changes. If you're not comfortable using CLI, this will make your upgrade much easier.

http://www.tekgoblin.com/2012/08/27/aws-guides-how-to-resize-a-ec2-windows-ebs-volume/

Thanks to TekGoblin for posting this article.

Monoicous answered 5/3, 2013 at 16:48 Comment(0)
V
103

You can grow the storage, but it can't be done on the fly. You'll need to take a snapshot of the current block, add a new, larger block and re-attach your snapshot.

There's a simple walkthrough here based on using Amazon's EC2 command line tools

Versicolor answered 15/2, 2009 at 12:40 Comment(4)
You'll also need to resize the filesystem. You're probably looking for "resize2fs - ext2/ext3/ext4 file system resizer".Tremendous
I just had to Google this. I hit this question and this video at the same time. This is a really great walkthough, so many thanks to the creator: youtube.com/watch?v=ouYjQ3_I3BA (I figured everything out on my own except for the resizer bit, like James Moore mentioned.)Interpolate
There is also a way to Set EBS Volume Size using AWS-SDK by querying first the VolumeSize of its Snapshot as one of the flexibility on The Benefit using EBS.Mistreat
You can actually resize a live volume now from the AWS console. Seems to work on SSD instances (gp2, io1) only, and you can even switch from one type to the other. I'm not sure when it was added, but this solves a major pain point.Disini
P
44

You can't simply 'bump in' more space on the fly if you need it, but you can resize the partition with a snapshot.

Steps do to this:

  1. unmount ebs volume
  2. create a ebs snapshot
  3. add new volume with more space
  4. recreate partition table and resize filesystem
  5. mount the new ebs volume

Look at http://aws.amazon.com/ebs/ - EBS Snapshot:

Snapshots can also be used to instantiate multiple new volumes, expand the size of a volume or move volumes across Availability Zones. When a new volume is created, there is the option to create it based on an existing Amazon S3 snapshot. In that scenario, the new volume begins as an exact replica of the original volume. By optionally specifying a different volume size or a different Availability Zone, this functionality can be used as a way to increase the size of an existing volume or to create duplicate volumes in new Availability Zones. If you choose to use snapshots to resize your volume, you need to be sure your file system or application supports resizing a device.

Precession answered 15/2, 2009 at 12:37 Comment(0)
M
22

I followed all the answer, all have something missing with all respect.

If you follow these steps you can grow your EBS volume and keep your data (this is not for the root volume). For simplicity I am suggesting to use AWS consule to create snapshot,... you can do that using AWS command line tools too.

We are not touching the root volume here.

Goto your AWS console:

  1. Shutdown your instance ( it will be for a few minutes only)
  2. Detach the volume you are planning to grow (say /dev/xvdf)
  3. Create a snapshot of the volume.
  4. Make a new volume with a larger size using the snapshot you just created
  5. Attach the new volume to your instance
  6. Start your instance

SSH to your instance:

 $ sudo fdisk -l

This gives your something like:

Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
12 heads, 7 sectors/track, 499321 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd3a8abe4

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdf1            2048    41943039    20970496   83  Linux

Write down Start and Id values. (in this case 2048 and 83)

Using fdisk ,delete the partition xvdf1 and create a new one that starts exactly from the same block (2048). We will give it the same Id (83):

$ sudo fdisk /dev/xvdf 

Command (m for help): d
Selected partition 1

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 
Using default value 41943039

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

This step is explained well here: http://litwol.com/content/fdisk-resizegrow-physical-partition-without-losing-data-linodecom

Almost done, we just have to mount the volume and run resize2fs:

Mount the ebs volume: (mine is at /mnt/ebs1)

$ sudo mount /dev/xvdf1 /mnt/ebs1

and resize it:

$ sudo resize2fs -p /dev/xvdf1

resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/xvdf1 is mounted on /mnt/ebs1; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/xvdf1 to 5242624 (4k) blocks.
The filesystem on /dev/xvdf1 is now 5242624 blocks long.

ubuntu@ip-xxxxxxx:~$ 

Done! Use df -h to verify the new size.

Maragaret answered 19/7, 2012 at 20:37 Comment(0)
Z
19

As long a you are okay with a few minutes of downtime, Eric Hammond has written a good article on resizing the root disk on a running EBS instance: http://alestic.com/2010/02/ec2-resize-running-ebs-root

Zulemazullo answered 28/4, 2010 at 14:17 Comment(1)
Inspired by this, i started writing "awscripts", @ github.com/moejay/awscripts it includes Eric's commands as well as ones to change instance types, in an easy, 'crontabbable' scriptLacasse
M
9

All great recommendations, and I thought I'd add this article I found, which relates to expanding a Windows Amazon EC2 EBS instance using the Amazon Web UI tools to perform the necessary changes. If you're not comfortable using CLI, this will make your upgrade much easier.

http://www.tekgoblin.com/2012/08/27/aws-guides-how-to-resize-a-ec2-windows-ebs-volume/

Thanks to TekGoblin for posting this article.

Monoicous answered 5/3, 2013 at 16:48 Comment(0)
D
5

You can now do this through the AWS Management Console. The process is the same as in the other answers but you no longer need to go to the command line.

Downwards answered 5/4, 2011 at 9:57 Comment(3)
Can you post more information about how this is done via the web console? The console may be able to resize the volume, but how does it handle resizing of the partition inside of the volume, especially if it is of a type like XFS, BRTFS, etc?Yorker
This should have been a comment as it only augments existing answers and doesn't add anything new in and of itself.Sansone
Instructions for using the web console are available here: docs.aws.amazon.com/AWSEC2/latest/UserGuide/…Imitable
C
4

BTW: As with physical disks, it might be handy to use LVM; ex:

http://www.davelachapelle.ca/guides/ubuntu-lvm-guide/ http://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/

Big advantage: It allows adding (or removing) space dynamically.

It can also easily be moved between/among instances.

Caveats:

  • it must be configured ahead of time
  • a simple JBOD setup means you lose everything if you lose one "disk"
Chaffer answered 20/5, 2011 at 16:32 Comment(0)
E
4

My steps:

  1. stop the instance
  2. find the ebs volume attached to the instance and create a snapshot of it
  3. create a new volume with bigger disk space using the above snapshot. Unfortunately the UI on the aws console to create a snapshot is almost unusable because it's listing all the snapshots on aws. Using command line tool is a lot easier, like this:

    ec2-create-volume -s 100 --snapshot snap-a31fage -z us-east-1c
    
  4. detach the existing ebs (smaller) volume from the instance

  5. attach the new (bigger) volume to the instance, and make sure attach it to the same device the instance is expecting (in my case it is /dev/sda1)
  6. start the instance

You are done!

Other than step 3 above, you can do everything using the aws management console.

Also NOTE as mentioned here:

https://serverfault.com/questions/365605/how-do-i-access-the-attached-volume-in-amazon-ec2

the device on your ec2 instance might be /dev/xv* while aws web console tells you it's /dev/s*.

Eoin answered 12/7, 2012 at 21:44 Comment(2)
As of November 2013, you can select the newly-created snapshot and then just click 'Create Volume' at the top of the page. This will create a volume from the snapshot, and you can avoid doing step 3 above from the command line.Zinazinah
One note is that you should ensure you are creating the volume in the same availability zone as the instance, otherwise you will be unable to attach it.Ddt
V
3

Use command "diskpart" for Windows OS, have a look here : Use http://support.microsoft.com/kb/300415 Following are the steps I followed for a non-root disk (basic not dynamic disk)

Once you have taken a snapshot, dismounted the old EBS volume (say 600GB) and created a larger EBS volume (say 1TB) and mounted this new EBS volume - you would have to let Windows know of the resizing (from 600GB to 1TB) so at command prompt (run as administrator)

diskpart.exe

select disk=9

select volume=Z

extend

[my disk 9,volume labelled Z, was a volume of size 1TB created from an ec2-snapshot of size 600GB - I wanted to resize 600GB to 1TB and so could follow the above steps to do this.]

Vitale answered 14/2, 2011 at 10:40 Comment(2)
Worked great for my Win Server 2003 R2 Datacenter system. Thanks for the tip!Fiftyfifty
Great post, helped me alot!Jalbert
E
0

I highly recommend Logical Volume Manager (LVM) for all EBS volumes, if your operating system supports it. Linux distributions generally do. It's great for several reasons.

  1. Resizing and moving of logical volumes can be done live, so instead of the whole offline snapshot thing, which requires downtime, you could just add create another larger EBS volume, add it to the LVM pool as a physical volume (PV), move the logical volume (LV) to it, remove the old physical volume from the pool, and delete the old EBS volume. Then, you simply resize the logical volume, and resize the filesystem on it. This requires no downtime at all!

  2. It abstracts your storage from your 'physical' devices. Moving partitions across devices without needing downtime or changes to mountpoints/fstab is very handy.

It would be nice if Amazon would make it possible to resize EBS volumes on-the-fly, but with LVM it's not that necessary.

Exclusion answered 22/6, 2012 at 9:1 Comment(0)
R
0

if your root volume is xfs file system then then run this command xfs_growfs /

Retroact answered 4/2, 2013 at 8:8 Comment(1)
This need a bit more detail to be considered a complete and usable answer.Sansone

© 2022 - 2024 — McMap. All rights reserved.