Activities

November 2010
M T W T F S S
« Oct   Dec »
1234567
891011121314
15161718192021
22232425262728
2930  

Amazon :- Windows AMI with instance storage

This is my continuation of my previous post which how to start a windows EBS ami using ephemeral storage.

My new requirement is that client requires to build a private AMI with instance storage. More clearly,

a. Start an AMI using ebs root device from Amazon store
b. Instance storage/ephemeral storage must be enabled
c. Building a Private AMI after installing all the applications in it.
D. Utilize full instance storage as single volume (spanned volume) on every boot. So that the ‘F’ drive always represents an instance storage.

Start a AMI using ebs root device from Amazon store

Here I uses the Window 2008 Datacentre Edition (64 bit) from Amazon image store. Now I’m creating a new security group and instance private key during the instance preparation time. Finally I start the instance. After running the instances I uses ” Get Administrator password” option by selecting the windows instance. We need the instance private key to retrieve the new administrator password for the first time. In technically,

instance Private key : Which helps to retrieve the initial windows administrator password.
Security group : Which is basically a firewall which help to open a port publicly. You must be opened the 3389 port to get the RDP access and open the other required ports according to the server role.
image zone : Pls choose where you want to store your EBS volume. Pls do remember that keep all the instance to use the same region. So that you can easily create snapshot, volume and attach to the any existing instance in case of instance crash.

Now I’m going to terminate the instance which I started. But I have instance private key and security group which created before. Now we have to start the instance from the EC2 command line. Amazon commandline tool can be download from the Amazon portal and configure it accordingly. It might be little bit complicate and a confusing one for the first time.

Let’s start the windows instance from the command line. Pls uses instance private key, AMI name, region name and security group as same as we built before. We can’t enable instance storage through Amazon Management Studio.

This command would work for you,
ec2-run-instances –region us-east-1 -K pk-5SQ.pem -C cert-5SQGV.pem –block-device-mapping “/dev/sdc=ephemeral0” -block-device-mapping “/dev/sdd=ephemeral1” ami-d9e40db0 -g default -t m1.large -k svr-tmpl -z us-east-1c

Pls note : -k , -z,–region.-t , -g and AMI id we are going to use.

Now you have a Amazon instance with instance storage. You can see the instance storage mounted as ‘D’. depend on the instant type used.

An standard EBS ami comes up with 30 GB storage. If you want more storage,

how to extend the EBS volume

a. Create a snapshot of volume which instance using
b. We can create volume from the snapshot. Choose the storage size how much you need during the volume creation time. Remember that choose the same Zone where previous EBS storage running. So that you can add it to running AMI.

Complete the custom application installs and set the server live. From here onwards, I’m going to use a script to automate the instance storage to a single volume. This steps is an optional one.

I’m going to use “m1.large” type to build the AMI. So I would have D and E drive will automatically mounted with the instance. I need to join these two volumes to a single. So that I can get a single drive of 850GB for temporary working files. I uses a windows script for this,
I have created a folder named ‘scripts’ in C drive and placed a batch file (create_vol.bat) and txt (volume.txt) file.

Batch file (create_vol.bat) content are,

IF EXIST F: GOTO noaction
diskpart < c:scriptsvolume.txt echo " no d drive" :noaction

Text file (volume.txt) content are,

select volume 1
delete volume
select volume 2
delete volume
list disk
select disk=1
convert dynamic
select disk=2
convert dynamic
create volume simple disk=1
list volume
select volume 1
extend disk=2
FORMAT FS=NTFS LABEL=”Inst-storage” QUICK
ASSIGN LETTER=F

Add this script on users startup scripts using gpedt.msc ( Start –> Run command window–> type “gpedit.msc”
then go to ” User configuration” –>Windows settings –>Scripts–> startup. Then choose the batch file.

I would recommend you to take a snapshot of running instance before doing this. After that execute this command from the commandline whether it showing any error or not. if everything goes fine, You can see a drive “F” which named “inst.storge”.

How di I verify it ?
Stop and start the instance. Then login to the administrator account. You can see “F” drive is created which having 850GB.

Building your Private AMI,
Choose the instance and right click —> Create image (EBS AMI). Provide appropriate AMI name and description.

Great ! All are set now. Now you can test your private AMI with instance storage. Start the instance and verify it’s listening on the port 3389 to get the RDP,

How do I check the instance is booted,

1. Choose the instance you want to check.
2. Copy the “Public DNS” name listed.
Eg. ec2-183-72-244-195.compute-1.amazonaws.com
3. telnet to this dns name and ensure port 3389 is open

[root@web-test1 ~]# telnet ec2-183-72-244-195.compute-1.amazonaws.com 3389
Trying 184.72.243.195...
Connected to ec2-183-72-244-195.compute-1.amazonaws.com (183.72.244.195).
Escape character is '^]'

NB: You may use the same administrator account to access to server. Termination of this private AMI will not delete the volume created. So we need to delete it after that.

Which shows your AMI build is ready and start to work with 🙂

-njoy

2 comments to Amazon :- Windows AMI with instance storage

  • Andrew

    Thanks for the article, straight forward and a great overview. I have a question: How do you determine how ‘big’ the instance will be? I am trying to setup cc2.8xlarge servers and I can get it to create the instance from my AMI but it always makes it the wrong type of machine. I created an instance, set it up, created the AMI from it but I can’t get it to create the proper machine type. How/where do you specify the machine type?

  • Liju

    What I’m thinking is you can’t build EBS AMI image if that instance is running and attached any volume on it. So detach the volume first and shutdown the server. then build the image unlike linux.

    If you wish to build the image along with EBS storage,

    1. Need to use EBS backend AMI to build the server.
    2. Create a snapshot of EBS root volume
    3. Create a new volume from that snapshot and choose the new volume size.
    4. Shut down the running instance and detach the EBS root device.
    5. Attach the newly created volume as root device to running instance and start the instance.

    Now you will see the instance running with new volume size. At this point you can build the EBS AMI.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>