Differences between revisions 3 and 4
Revision 3 as of 2013-10-26 11:28:17
Size: 3188
Comment: See also…
Revision 4 as of 2013-10-26 11:30:16
Size: 3252
Comment: Run from the Debian AMI Account.
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
Not yet a script... This is run in the Asia North-East zone. Not yet a script... This is run in the Asia North-East zone from the Debian AMI Account (account number {{{379101102735}}}).

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 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 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

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

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.

# License: CC0

parted -s /dev/xvdb mklabel msdos mkpart primary 0% 100%
mke2fs -L debian-installer /dev/xvdb1 -F
mount LABEL=debian-installer /mnt/

cd /mnt


wget $BASEURL/initrd.gz $BASEURL/vmlinuz

mkdir -p boot/grub

cat > boot/grub/menu.lst <<__END__
default 0
timeout 3

title  Debian Installer ($DI_VERSION $ARCH)
root   (hd0,0)
kernel /vmlinuz root=LABEL=debian-installer ro console=hvc0 auto=true priority=critical url= DEBIAN_FRONTEND=text
initrd /initrd.gz

sleep 30


See also Cloud/AmazonEC2Image, and Cloud.