Does anyone know how to create smaller disk size Windows instances on Amazon EC2? Their default is 30 GB, and I have to pay $0.10/GB/month for EBS storage, which means that for each Windows instance I have to pay additional $3 a month. If I have 100 instances, that's $300 wasted. I'd be pretty happy with 5GB or even smaller Windows instances. Thanks!
It seems like this has been done on Win2008-R2, according to http://support.rightscale.com/09-Clouds/AWS/FAQs/How_do_I_shrink_an_EBS-backed_HVM_Windows_AMI%3F :
Invoke imagex as follows, where C: is the root device, D: is the volume containing the image to be shrunk, and E: is the empty volume.
imagex.exe /capture d:\ c:\server-image.wim "Windows Server Image" imagex.exe /apply c:\server-image.wim 1 e:
Close your RDP session, and stop the instance from the AWS Console.
Your new instance might not boot after this, so you need to fix that, using http://www.smattie.com/2011/12/21/windows-72008r2-does-not-load-after-adding-the-drive-to-another-machine-that-also-uses-new-bcd-store/ and https://technet.microsoft.com/en-us/library/cc731245(WS.10).aspx:
The disk signature needs to be fixed as well using regedit and DISKPART as described here http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-passwords.html#ResettingAdminPassword - Step 8:
If your temporary instance is based on the same AMI that the original instance is based on, and the operating system is later than Windows Server 2003, you must complete the following steps or you won't be able to boot the original instance after you restore its root volume because of a disk signature collision.
Locate the four-byte disk signature at offset 0x38 in the data. Reverse the bytes to create the disk signature, and write it down. For example, the disk signature represented by the following data is E9EB3AA5:
...
0030 00 00 00 00 01 00 00 00
0038 A5 3A EB E9 00 00 00 00
0040 00 00 00 00 00 00 00 00
...
In a Command Prompt window, run the following command to start Microsoft DiskPart.
C:> diskpart
Run the following DiskPart command to select the volume. (You can verify that the disk number is 1 using the Disk Management utility.)
DISKPART> select disk 1
Disk 1 is now the selected disk. Run the following DiskPart command to get the disk signature.
DISKPART> uniqueid disk Disk ID: 0C764FA8
If the disk signature shown in the previous step doesn't match the disk signature from BCD that you wrote down earlier, use the following DiskPart command to change the disk signature so that it matches:
DISKPART> uniqueid disk id=E9EB3AA5
To finish up:
Detach the secondary volume from the temporary instance as follows:
a. Using the Disk Management utility, bring the volume offline.
Note The drive is automatically offline if the temporary instance is running the same operating system as the affected
instance, so you won't need to bring it offline manually. From the Amazon EC2 console, in the navigation pane, click Volumes.
b. In the list of volumes, right-click the volume, and then click Detach Volume. After the volume's status changes to available, proceed with the next step.
Reattach the volume to the original instance as its root volume as follows:
a. Right-click the volume and then click Attach Volume.
b. In the Attach Volume dialog box, start typing the name or ID of the original instance in the Instances list, and then select the instance.
c. In the Device box, enter /dev/sda1.
d. Click Yes, Attach.
Restart the original instance as follows:
a. In the navigation pane, click Instances.
b. Right-click the original instance and then click Start.
c. In the Start Instances dialog box, click Yes, Start.
At this point you can create a new image with a the smaller boot volume
It seems that it's no possible at this time:
https://forums.aws.amazon.com/message.jspa?messageID=177749