1.
[IMPORTANT] First of all, take a snapshot of the
EBS volume for backup[1]
2.
Connect to your Windows instance and shrink the
root volume from 1000 GB to 100 GB
a.
Open Disk Management on the Windows instance
b.
Right-click on volume C: -> Choose
"Shrink Volume"
c.
Enter the amount of space to shrink in MB(in
this case, 921600 MB)
3.
Stop the Windows instance
4.
Detach the root EBS volume from the Windows
instance
5.
Launch an Amazon Linux instance in the same
availability zone(AZ) with the Windows instance
a.
*I chose an EBS-optimised m4.large instance type
to improve the disk speed[2]
6.
Attach the EBS volume to Amazon Linux instance
as device /dev/sdf
7.
Create a new 100 GB EBS volume in the same AZ
and attach it to the Amazon Linux instance as device /dev/sdg
8.
Connect to the Linux instance with ssh and copy
all data from the original volume(/dev/sdf) to the new one(/dev/sdg)
a.
Type
"sudo -s" to switch to the root account
b.
Check that the volumes are attached correctly,
type:
i.
fdisk -s /dev/sdf (the size of the 1000 GB
volume should appear in KB, 1048576000 KB)
ii.
fdisk -s /dev/sdg (the size of the 100 GB volume
should appear in KB, 104857600 KB)
c.
Type "yum install pv -y" to install
pv. This tool will show you the progress of data transfer through a pipeline.
d.
Type "dd if=/dev/sdf |pv| dd of=/dev/sdg
bs=1M"
i.
"dd" copy the contents of the source
to the destination. The "bs=1M" tells "dd" to use a block
size of one megabyte.
ii.
Please expect several hours to finish this step.
In my environment, this step took five and half hours.
iii.
The time required depends on the instance type,
network throughput, etc.
9.
Stop the Amazon Linux instance and detach both
volumes(/dev/sdf and /dev/sdg)[4]
10.
Attach the 100 GB volume to the original Windows
instance as device /dev/sda1 \
11.
Start the Windows instance
a.
If everything goes as expected, the Windows
instance should pass the instance status checks.
b.
Logon to the Windows instance and verify from
the Disk Management that the root EBS volume is 100 GB.
12.
Terminate Linux instance, delete the EBS volume
of 1000 GB
Links:-
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-creating-snapshot.html
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-attaching-volume.html
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-detaching-volume.html