Thursday, December 03, 2009

I'm gonna create a image with Debian and Django to upload it to AWS.



dd if=/dev/zero of=debian-ami count=1000 bs=1m
sudo mkfs.ext3 -F debian-ami
mkdir /tmp/chroot
sudo mount -o loop debian-ami /tmp/chroot
sudo debootstrap --arch i386 lenny /tmp/chroot/ http://ftp.debian.org
sudo chroot /tmp/chroot/
# Inside the chroot
mount -t proc none /proc
cd /dev
MAKEDEV console
MAKEDEV std
echo -e 'auto lo\niface lo inet loopback\nauto eth0\niface eth0 inet dhcp' >> /etc/network/interfaces
echo -e 'proc /proc proc defaults 0 0\n/dev/sda1 / reiserfs defaults 0 1\n/dev/sda2 swap swap defaults 0 0' > /etc/fstab
aptitude update
aptitude install locales-all
aptitude install ssh
exit

# In your machine
sudo umount -l /tmp/chroot
export EC2_PRIVATE_KEY=xxxxxxx.pem
export EC2_CERT=xxxxxxxxxxxxxxxxxx.pem
export EC2_ACCNO=xxxxxxxxxx
export ACCESS_KEY=xxxxxxxxxxxxxxxx
export SECRET_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ec2-bundle-image -i debian-ami --cert EC2_CERT --privatekey EC2_PRIVATE_KEY -u EC2_ACCNO
ec2-upload-bundle -b 20091203-linux-debian-lenny -m /tmp/debian-ami.manifest.xml -a ACCESS_KEY -s SECRET_KEY
ec2-register -n 20091203-linux-debian-lenny 20091203-linux-debian-lenny/debian-ami.manifest.xml

No comments: