Growing Amazon EBS Volume sizes [closed]

2019-01-08 02:36发布

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?

11条回答
手持菜刀,她持情操
2楼-- · 2019-01-08 03:19

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"
查看更多
时光不老,我们不散
3楼-- · 2019-01-08 03:20

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

查看更多
贼婆χ
4楼-- · 2019-01-08 03:21

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.

查看更多
贪生不怕死
5楼-- · 2019-01-08 03:33

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

查看更多
聊天终结者
6楼-- · 2019-01-08 03:34

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.

查看更多
放我归山
7楼-- · 2019-01-08 03:36

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

查看更多
登录 后发表回答