echo 1 > /proc/sys/xen/independent_wallclock
Now you can force the host date.
echo 1 > /proc/sys/xen/independent_wallclock
Now you can force the host date.
Hi,
after looking some usefull guides to create Amazon Machine Image based on CentOS distribution, I decide to write the steps that i followed.
First of all we need of a CentOS machine, if you don’t have it use a virtual machine program (on my Kubuntu based laptop I use VirtualBox), once we have it login and start:
dd if=/dev/zero of=base-server.fs bs=1M count=1024
mke2fs -F -j base-server.fs
mkdir /mnt/ec2-fs
mount -o loop base-server.fs /mnt/ec2-fs
mkdir /mnt/ec2-fs/dev
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x console
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x null
/sbin/MAKEDEV -d /mnt/ec2-fs/dev/ -x zero
mkdir /mnt/ec2-fs/etc
mkdir /mnt/ec2-fs/proc
mount -t proc none /mnt/ec2-fs/proc
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
exclude=*-debuginfo
gpgcheck=0
obsoletes=1
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
reposdir=/dev/null
metadata_expire=1800
[base]
name=CentOS-5.3 – Base
baseurl=http://mirror.centos.org/centos/5.3/os/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
protect=1
#released updates
[update]
name=CentOS-5.3 – Updates
baseurl=http://mirror.centos.org/centos/5.3/updates/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
protect=1
#packages used/produced in the build but not released
[addons]
name=CentOS-5.3 – Addons
baseurl=http://mirror.centos.org/centos/5.3/addons/i386/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
[extras]
name=CentOS 5.3 Extras $releasever – $basearch
baseurl=http://mirror.centos.org/centos/5.3/extras/i386/
enabled=1
yum -c yum-xen.conf --installroot=/mnt/ec2-fs -y groupinstall Core
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
IPV6INIT=no
NETWORKING=yes
cp /etc/resolv.conf /mnt/ec2-fs/etc/resolv.conf
/dev/sda1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/sda2 /mnt ext3 defaults 0 0
/dev/sda3 swap swap defaults 0 0
yum -c yum-xen.conf --installroot=/mnt/ec2-fs -y install wget
yum -c yum-xen.conf --installroot=/mnt/ec2-fs -y install curl
mv /mnt/ec2-fs/lib/tls /mnt/ec2-fs/lib/tls.disabled
#!/bin/sh
if [ ! -d /root/.ssh ] ;
then mkdir -p /root/.ssh
chmod 700 /root/.ssh
fi
# Fetch public key using HTTP
curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/my-key
if [ $? -eq 0 ] ;
then
cat /tmp/my-key >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
rm -f /tmp/my-key
fi
chmod +x /usr/local/sbin/get-aws-credentials.sh
# get AWS credentials
/usr/local/sbin/get-aws-credentials.sh
chroot /mnt/ec2-fs /bin/bash
chkconfig --level 345 sshd on
exit
umount /mnt/ec2-fs/proc
umount -d /mnt/ec2-fs
Now your image file is ready, simply create bundle volume and upload to S3
yum install ruby
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
rpm -Uvh ec2-ami-tools.noarch.rpm
ec2-bundle-image -i base-server.fs -c my-cert.pem -k my-private-key.pem -u 1234-5678-9101 (amazon account id)
ec2-upload-bundle -b base-server -m /tmp/base-server.fs.manifest.xml -a my-aws-access-key-id -s my-secret-key-id
Now you can register an AMI and launch your instance.
Enjoy!