Shrinking a Volume - Amazon Web Services

Overview

Amazon Web Services easily supports expanding a volume on an EC2 server instance. You simply take a snapshot of your volume, then launch a new, larger volume from the snapshot. However, shrinking a volume is not as straightforward. This article provides a procedure for doing so for a Windows Server.

Procedure

1. Connect to the EC2 instance via Remote Desktop

2. Within Disk Management, shrink the volume to the desired size. Obviously, you won't be able to shrink it smaller than its "Used Space".

3. Within the Amazon Console, shut down the server.

4. Launch a new Amazon Linux instance in the same availability zone as the Windows server. Choose an m3.xlarge and EBS-optimized.

5. Document the Volume ID of the volume being migrated.

6. Detach the volume from the Windows server.

7. Attach the volume to the Amazon Linux machine as /dev/sdf.

8. Create a new standard EBS volume of the desired target size in the same availability zone.

9. Attach the new EBS volume to the Amazon Linux instance as /dev/sdg. BE CAREFUL, as it defaults to /dev/sdf.

10. Open a PuTTY window to the Amazon Linux instance.

11. Validate the disks are properly mounted by using the following commands, which return the number of KB on each disk.

sudo fdisk -s /dev/sdf
sudo fdisk -s /dev/sdg

12. Copy the contents of /dev/sdf onto /dev/sdf with the following command.

sudo dd if=/dev/sdf of=/dev/sdg bs=1M

The following screenshot shows sample output from the above command.

DD Command Sample Output

DD Command Sample Output


13. In the Amazon Console, document the Volume IDs

14. Stop the Linux instance

15. Detach both volumes from the Linux instance

16. Attach the new volume to the Windows server as /dev/sda1 (This is the root device name for a Windows instance.)

17. Start the Windows server

18. Connect to the Windows server via Remote Desktop, and verify that the volume is the expected size.

19. Delete the original volume

20. Terminate the Linux instance