AWS, Cloud Computing, Tutorials

2 Mins Read

Shrinking An Amazon EBS Volume

Amazon’s Elastic Block Store Volumes are easy to use and expand but notoriously hard to shrink once their size has grown. Here are the steps for Shrinking any mounted EBS volume on EC2 Instances.

For various reasons you may need to expand or shrink the size of your EBS volume. Because you are only charged for the space currently allocated to your EBS volumes, it is also cost efficient to allocate only your approximate short term need and expand the volume as the need arises (this should be considered during the planning phase of your projects and/or during formulation of growth strategies for your service).

The below steps have been tested on an Amazon Linux instance to resize an EBS Volume using the AWS console

  1. Create a new EBS Voume of your desired size from the console and attach it to your instance
  2. Now login to your instance using ssh and format your new attached volume using the following command (Assuming that  new volume is attached at /dev/sdi)

3.Then make a directory at /mnt/ebs1 and mount the new volume using following commands

4. Now copy your data recursively from your  source volume to your newly created volume using the following         command(Assuming your old volume is mounted at /mnt/ebs)

Copying data recursively preserves the file attributes such as mode,ownership,timestamps and security contexts, if possible additional attributes such as links.

5.  After copying the data detach your old volume and mount your new volume at the same mount point using the following command

Automating the process by Shell Script

In order to automate all this process here is the Script which will  automate the process

Download the zip from this page

Extract the zip and navigate to the extracted folder

Step 1: Place the script on the instance with permissions to execute

Now SSH into the instance using the following command and Update file permissions

Step 2: Configure AWS  Cli

Also before executing the script you need to configure awscli use the following commands to install

Run aws configure at the command line to set up your credentials and settings.

This Script Will Create a New Volume of User Defined,Mount it to /mnt/ebs1 Copy all the data from the attached EBS Volume recursively that need to be Migrated preserving all the user permissions,then Unmount it and Mount the Newly Created EBS Volume at the Same Mount Point

Note:The migrated volume is not deleted it is just unmounted So if any error occurs we can reattach it. This Script can only use for Attached(Mounted) EBS Volumes not Root Volume.




  1. Amazon expands Elastic Block Storage | CloudThat's Blog

    Mar 24, 2015


    […] If you want to increase the size of your existing volumes to take advantage of this new feature release, you can resize your current volumes using our previous blog post here. […]

  2. Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!