Official Debian-Installer AMIs

Official Amazon Machine Images for the DebianInstaller

AMI build script

Not yet a script... This is run in the Asia North-East zone from the Debian AMI Account (account number 379101102735). The operations in the cloud are controlled from the local computer using programs from the euca2ools package.

The procedure below runs a helper instance with an attached volume of 1 GiB, partitions it, downwoads Debian-Installer on it and sets up a PV-GRUB configuration file to boot the installer. The snapshot of the resulting volume is registered as a machine image.

Using Ubuntu (12.04 LTS Precise amd64 EBS Asia North-East) as long as we do not have Debian images with cloud-init enabled by default.

HELPER_AMI=ami-7609bb77 # Ubuntu 12.04 LTS Precise amd64 EBS (Asia North-East)

Start the instance with an extra volume of 1 GiB, which will persist after termination (/dev/sdb=:1:false). Pass the script that will format the volume and download Debian-Installer (see below).

HELPER_INSTANCE=$( euca-run-instances \
        --instance-initiated-shutdown-behavior terminate \
        --instance-type t1.micro \
        --block-device-mapping /dev/sdb=:1:false \
        --user-data-file install-debian-installer \
        $HELPER_AMI |
        tee /dev/stderr | grep INSTANCE | awk '{print $2}')

Wait that the boot finished.

while [ ! $(euca-describe-instances $HELPER_INSTANCE | grep INSTANCE | cut -f 6 | tee /dev/stderr) = "running" ]
    do sleep 30
done

Get the volume's identifier

TARGET_VOLUME=$( euca-describe-volumes |
        grep $HELPER_INSTANCE | grep '/dev/sdb' |
        tee /dev/stderr | awk '{print $2}')

Wait that the scripts shuts down the instance.

while [ ! $(euca-describe-instances $HELPER_INSTANCE | grep INSTANCE | cut -f 6 | tee /dev/stderr) = "terminated" ]
    do sleep 30
done

Snapshot the volume and register it as a machine image.

PV_KERNEL=aki-176bf516 # Boot PV-Grub (Asia North-East)

TARGET_SNAPSHOT=$( euca-create-snapshot $TARGET_VOLUME |
        tee /dev/stderr | awk '{print $2}')

while euca-describe-snapshots $TARGET_SNAPSHOT | grep -q pending ; do sleep 30 ; done

euca-register \
    --name test_di \
    --description test_of_debian_installer \
    --snapshot $TARGET_SNAPSHOT \
    --kernel $PV_KERNEL \
    --architecture x86_64
    --root-device-name /dev/sda1

The script install-debian-installer follows here.

   1 #!/bin/sh -ex
   2 # License: CC0
   3 
   4 parted -s /dev/xvdb mklabel msdos mkpart primary 0% 100%
   5 mke2fs -L debian-installer /dev/xvdb1 -F
   6 mount LABEL=debian-installer /mnt/
   7 
   8 cd /mnt
   9 
  10 ARCH=amd64
  11 DIST=wheezy
  12 DI_VERSION=20130613+deb7u1
  13 MIRROR=http://cloudfront.debian.net
  14 BASEURL=$MIRROR/debian/dists/$DIST/main/installer-$ARCH/$DI_VERSION/images/netboot/xen
  15 
  16 wget $BASEURL/initrd.gz $BASEURL/vmlinuz
  17 
  18 mkdir -p boot/grub
  19 
  20 cat > boot/grub/menu.lst <<__END__
  21 default 0
  22 timeout 3
  23 
  24 title  Debian Installer ($DI_VERSION $ARCH)
  25 root   (hd0,0)
  26 kernel /vmlinuz root=LABEL=debian-installer ro console=hvc0 auto=true priority=critical url=http://169.254.169.254/latest/user-data DEBIAN_FRONTEND=text
  27 initrd /initrd.gz
  28 __END__
  29 
  30 sleep 30
  31 
  32 halt


See also Cloud/AmazonEC2Image, and Cloud.