Mar 2014
The following are the major steps involved:
My starting points are two places:
This is relatively straightforward. To save space, I installed the ISO on a 2GB hard disk with VMWare Workstation.
dd if=/dev/sda of=<my root fs image> bs=1M
A lot of try-n-error and dark magic happen in this step. I will try to cover as much as possible.
Mount the root fs image under /mnt/ec2-image
mount -oloop /opt/ec2/images/vyatta-64bit.img /mnt/ec2-image/
Create /mnt/ec2-image/boot/grub/menu.lst (Note the suffix is "L"-st, not "One"-st)
default=0 timeout=0 title Jun Vyatta 64bit root (hd0) kernel /boot/vmlinuz-3.3.8-1-amd64-vyatta ro root=/dev/xvda1 console=hvc0 rd_NO_PLYMOUTH initrd /boot/initrd.img-3.3.8-1-amd64-vyatta
vi /mnt/ec2-image/etc/fstab
/dev/xvda1 / ext4 noatime 0 1 /dev/xvda3 swap swap defaults 0 0
vi /mnt/ec2-image/opt/vyatta/etc/config/config.boot. Main changes are a) remove eth0 MAC address, b) add sshd service, c) change console
nterfaces { ethernet eth0 { address dhcp } loopback lo { } } service { ssh { port 22 } } system { config-management { commit-revisions 20 } console { device hvc0 { speed 9600 } } host-name vyatta-64bit login { user vyatta { authentication { encrypted-password $1$2LZU31YS$ShE9ovJPjaJGZDCw9iLW20 } level admin } } ntp { server 0.vyatta.pool.ntp.org { ....
Also remove default password for 'vyatta' user in /mnt/ec2-image/etc/passwd file.
vyatta:x:1000:100::/home/vyatta:/bin/vbash
Add the following to the /mnt/ec2-image/etc/rc.local file:
# # [jsun] generate host key if not available # if [ ! -f /etc/ssh/ssh_host_key ]; then dpkg-reconfigure openssh-server fi /sbin/ifconfig exit 0
This feature screws up AMI instace each time it is stop and re-started, because the eth0 hw-id will be different. A simple solution is to not remember it at all.
--- backup/opt/vyatta/sbin/vyatta_interface_rescan 2014-03-25 16:53:02.000000000 -0700 +++ /mnt/ec2-image/opt/vyatta/sbin/vyatta_interface_rescan 2014-03-25 15:41:02.505167405 -0700 @@ -132,7 +132,8 @@ my $ifpath = interface_type($ifname) . " $ifname"; syslog(LOG_INFO, "add config for %s hw-id %s", $ifname, $hwaddr); - $xcp->create_node(['interfaces',$ifpath,"hw-id $hwaddr"]); + #$xcp->create_node(['interfaces',$ifpath,"hw-id $hwaddr"]); + $xcp->create_node(['interfaces',$ifpath,"address dhcp"]); # Add existing phy entry for wireless if ($ifname =~ /^wlan/) {
Even though we got a perfect FS image above for AMI, there is no easy way to create one. *sigh*
Vyatta is using its own Linux kernel. We are relying on a AWS EC2 feature, called, PV-GRUB. We use the AKI for 64bit and partionless disk (hd0 version).
We rely on a AMI build host in AWS that helps us to create a volumn with all the root fs image content. We then create an snapshot from the volumn, and then create AMI from thsnapshot. We then copy the AMI to the targeted regions, if they are different from the build host.
Note that we will ssh into the build host. It is much more convenient if we set up key-based access to the build host. Also the login user must be in "disk" group.
We use the ec2 tool PHP SDK. Please install that first.
The PHP script used to create the AMI is listed here.
Run this script from local host (e.g., the debian 6 vyatta build host). The usage is pretty simple
One does not need to go through the above steps if he/she wants to change some source code of a package. Instead, if you already have build vyatta ISO environment and an EC2 instance running the vyatta AMI, use the following procedure.
- debian 6 net iso install VM; system utilities ssh server graphic install - install kernel header sudo apt-get install linux-headers-$(uname -r) - install vmware-tools - install build packages apt-get install ssh build-essential sudo bzip2 curl autoconf git devscripts \ debhelper autotools-dev automake libtool bison flex lintian \ libglib2.0-dev libapt-pkg-dev libboost-filesystem1.42-dev \ libncurses5-dev libdb-dev libssl-dev cdbs libmozjs-dev \ libreadline5-dev libpam0g-dev libcap-dev libsnmp-dev gawk unzip \ kernel-package libatm1-dev git-buildpackage libnfnetlink-dev \ libnetfilter-conntrack-dev libattr1-dev rsync libxml2-dev \ libedit-dev libpcap0.8-dev libpci-dev lsb-release quilt ruby \ genisoimage liblzo2-dev unifont libpopt-dev libgmp3-dev \ libcurl4-openssl-dev libopensc2-dev libldap2-dev libkrb5-dev \ hardening-wrapper libgcrypt11-dev libpcre3-dev libprelude-dev \ libgnutls-dev libperl-dev python-all-dev python-setuptools \ live-helper syslinux libsort-versions-perl libexpat1-dev \ libfile-sync-perl gcc-multilib libfreetype6-dev libusb-dev \ libdevmapper-dev libmysqlclient-dev autogen libdumbnet-dev