Amazon AWS snapshot vs. volume

We stop and start AWS EC2 instances.  We have created our own private AMI.  All good.
Problem is that we'd like each instance to be configured with slightly different files.

When we launch the "standard AMI", it seems that the additional drive is included in the AMI -- we can't seem to find a way to select a "volume" afterwards.

In other words, we'd like to attach a "D:" drive that we choose.   Machine1, based on our StandardAMI,  would get the volumeA this week...  next time we launch Machine1 we could select volumeB.

Could someone please walk me through that?
Francois KoutchoukCTOAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shalom CarmelCTOCommented:
Create your AMI without the D: drive attached, and then see this explanation how to attach a volume to a windows server.

There is a nice script on Stackoverflow that accomplishes the attaching part automatically, while pulling the volume to use from the instance user defined metadata.

REM Originally from 
REM @echo off

C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 100 /so AttachEbsBoot /d "Starting attach-ebs-boot.cmd"

REM local variables
REM Make sure you include the directory with curl.exe and the EC2 command line tools in the path
set path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Utils;C:\ebin\ec2\bin
set JAVA_HOME=c:\java
set EC2_HOME=c:\ebin\ec2
set EC2_CERT=<your_cert>
set EC2_PRIVATE_KEY=<your_private_key>

REM Please note: you should use the Ec2 Config Serive Settings application to ensure
REM that your EBS volume is mapped to a particular drive letter.
REM edit as needed
set EBS_DEVICE=xvdp

REM Test to see if the drive is already attached. If it is then we're done.
if exist %EBS_DRIVE%\nul (goto done)

REM get the EBS volume ID from the user data and the instance ID from the meta-data
for /f "delims=" %%a in ('curl') do (set EBS_VOLUME=%%a)
for /f "delims=" %%b in ('curl') do (set INSTANCE_ID=%%b)

C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 102 /so AttachEbsBoot /d "Volume == %EBS_VOLUME%"
C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 103 /so AttachEbsBoot /d "Instance == %INSTANCE_ID%"

REM attach the volume
REM Use a series of set command to build the command line

C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 104 /so AttachEbsBoot /d "calling ec2attvole %COMMAND_LINE%"

call ec2attvol.cmd %COMMAND_LINE%

C:\WINDOWS\system32\eventcreate /l SYSTEM /t information /id 101 /so AttachEbsBoot /d "Exiting attach-ebs-boot.cmd"

REM Events logged in the System event log
REM source === AttachEbsBoot
REM Event 100 - Script start
REM Event 101 - Script end
REM Event 102 - Volume ID
REM Event 103 - Instance ID
REM Event 104 - Command line for ec2attvol

Open in new window

Francois KoutchoukCTOAuthor Commented:
Great, thank you.  I can see that I can start an instance, attach/force-detach a volume.
Now what I would like is to "copy" a Volume.
I see that I can "Copy" a snapshot --> but no option to create a New Volume from that snapshot
I don't see the option to copy a volume.

The idea is:  machine1 put all its configuration on the attached D: drive.  I want machine5 to now use that.  I would briefly force detach the D: drive, make a quick copy, then attach back to machine1, then attach the new copy to machine2.
Stuart ScottAWS Content Lead at Cloud AcademyCommented:

You can create a new volume from a snapshot - See the link below on how to do this.


- Go to your AWS Console
- Select "EC2"
- Go to "Snapshots" under "Elastic Block Store"
- Select the Snapshot you want to create a volume from
- Select "Actions"
- Select "Create Volume"

Hope this helps,



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.