--- wikisrc/amazon_ec2.mdwn 2011/02/18 01:04:32 1.9
+++ wikisrc/amazon_ec2.mdwn 2011/02/18 02:14:27 1.10
@@ -235,14 +235,68 @@ EOF
[root@ip-10-99-86-193 ec2-user]# mv netbsd /mnt/grub/boot/
[root@ip-10-99-86-193 ec2-user]# umount /dev/sdg
[root@ip-10-99-86-193 ec2-user]# gunzip < NetBSD-AMI.img.gz | dd of=/dev/sdf bs=32k
+[root@ip-10-99-86-193 ec2-user]# sync
"""]]
### Shutdown the Linux instance
+We now have to detach volumes, snapshot them, then we shutdown the Linux instance.
+
+[[!template id=programlisting text="""
+# ec2-detach-volume vol-36f88d5e
+ATTACHMENT vol-36f88d5e i-5babe737 /dev/sdf detaching 2011-02-18T00:14:00+0000
+# ec2-detach-volume vol-24f88d4c
+ATTACHMENT vol-24f88d4c i-5babe737 /dev/sdg detaching 2011-02-18T00:14:10+0000
+# ec2-create-snapshot vol-36f88d5e
+SNAPSHOT snap-deef2bb2 vol-36f88d5e pending 2011-02-18T01:17:59+0000 983624114127 5
+# ec2-create-snapshot vol-24f88d4c
+SNAPSHOT snap-8aef2be6 vol-24f88d4c pending 2011-02-18T01:18:10+0000 983624114127 1
+# ec2-terminate-instances i-5babe737
+INSTANCE i-5babe737 running shutting-down
+"""]]
+
## Create your first NetBSD AMI
+An AMI requires multiples components to be registered: the snapshots IDs we made in the previous chapter, as well as a specific AKI: the one that can chain-load Xenified kernels through PyGrub.
+
+/!\ AKIs are entitled to the same conditions as AMIs: their IDs are region-specific. So chose one carefully, or you will not be able to launch a NetBSD instance later!
+
+The list of AKIs that suits our situation can be obtained with the following command:
+
+[[!template id=programlisting text="""
+# Obtain all kernel images (AKI) for region US East, for which manifest location contains pv-grub (for PyGrub)
+# ec2-describe-images -a --region=us-east-1 -F image-type=kernel -F manifest-location=*pv-grub*
+IMAGE aki-407d9529 ec2-public-images/pv-grub-hd0-V1.01-i386.gz.manifest.xml amazon available public i386 kernel instance-store paravirtual xen
+IMAGE aki-427d952b ec2-public-images/pv-grub-hd0-V1.01-x86_64.gz.manifest.xml amazon available public x86_64 kernel instance-store paravirtual xen
+IMAGE aki-4c7d9525 ec2-public-images/pv-grub-hd00-V1.01-i386.gz.manifest.xml amazon available public i386 kernel instance-store paravirtual xen
+IMAGE aki-4e7d9527 ec2-public-images/pv-grub-hd00-V1.01-x86_64.gz.manifest.xml amazon available public x86_64 kernel instance-store paravirtual xen
+"""]]
+
+We pick the one with the correct architecture (x86_64). Its ID is **aki-4e7d9527**. Then we can proceed to the creation of our AMI, with:
+
+1. */dev/sda1* as Grub partition (*/dev/sdg*, snapshot *snap-8aef2be6* of volume *vol-24f88d4c*)
+1. */dev/sda2* as root file-system (*/dev/sdf*, snapshot *snap-deef2bb2* of volume *vol-36f88d5e*)
+
+[[!template id=programlisting text="""
+$ ec2-register -a x86_64 --kernel aki-4e7d9527 --region us-east-1 \
+ -b "/dev/sda1=snap-8aef2be6" -b "/dev/sda2=snap-deef2bb2" -n "NetBSD-x86_64-current" \
+ -d "<add your own description here>
+IMAGE ami-74d0231d
+"""]]
+
# Play with your first NetBSD instance
+You can now start your own NetBSD instance, via:
+
+[[!template id=programlisting text="""
+$ ec2-run-instances ami-74d0231d -t t1.micro -z us-east-1c
+RESERVATION r-08218465 983624114127 default
+INSTANCE i-953d72f9 ami-74d0231d pending 0 t1.micro 2011-02-18T02:05:46+0000 us-east-1c aki-4e7d9527 monitoring-disabled
+$ ec2-get-console-output i-953d72f9
+[...]
+
+"""]]
+
## Create the instance
## Connect to it