1

I am attempting to customize a base instance-store Centos7 AMI. Image I am using is: RightImage_CentOS_7.0_x64_v14.1.4_HVM - ami-d34b02e3 (instance store hvm)

I start the instance, I customize it, I install the needed tools, do everything that is described in aws doc, upload and register the image, but the image does NOT boot.

The centos7 image comes with grub2 which seems to be a deal breaker, as the tools expect grub.

Here is are the full steps:

if [ ! -e /tmp/build/rpms/flag ]; then
    yum install -y /tmp/build/rpms/ec2-ami-tools.noarch.rpm
    mkdir /usr/local/ec2
    unzip -o /tmp/build/rpms/ec2-api-tools.zip -d /usr/local/ec2
    mkdir -p grub
    rm -rf grub/*
    pushd grub && rpm2cpio /tmp/build/rpms/grub-0.97-93.el6.x86_64.rpm | cpio -idmv && popd
    cp -a grub/sbin/* /sbin/
    cp -a grub/usr/* /usr/
    touch /tmp/build/rpms/flag
fi

export JAVA_HOME="/usr/java/default"
export EC2_HOME=/usr/local/ec2/ec2-api-tools-1.7.3.0
export PATH=$PATH:$EC2_HOME/bin

cp /tmp/build/menu.lst /boot/grub/

ec2-bundle-vol -k /tmp/build/cert/privkey.pem -c /tmp/build/cert/privkey.pem -u {{aws_account_id}} -r x86_64 -e /tmp/build
ec2-upload-bundle -b {{s3_ami_upload_bucket}}/{{current_date_timestamp}} -a {{ec2_access_key_id}} -s {{ec2_secret_access_key}} -m /tmp/image.manifest.xml --region us-west-2
ec2-register {{s3_ami_upload_bucket}}/{{current_date_timestamp}}/image.manifest.xml -n supercow_{{current_date_timestamp}} -O {{ec2_access_key_id}} -W {{ec2_secret_access_key}} --region us-west-2 --virtualization-type hvm

Everything between {{}} is replaced by a tempting engine by actual values.

This is the /boot/grub/menu.lst I've created in an attempt to trick the tools to do the right thing, but it's still not working.

default=0
timeout=0
hiddenmenu

title CentOS Linux (vmlinuz-3.10.0-123.20.1.el7.centos.plus.x86_64) 7 (Core)
    root (hd0,0)
    kernel /boot/vmlinuz-3.10.0-123.20.1.el7.centos.plus.x86_64 ro root=/ consoleblank=0 console=ttyS0 LANG=en_US.UTF-8 loglvl=all sync_console console_to_ring earlyprintk=xen xen_emul_unplug=unnecessary xen_pv_hvm=enable
    initrd /boot/initramfs-3.10.0-123.20.1.el7.centos.plus.x86_64.img

So basically I need to figure out how to make grub happy, which I am basically out of ideas on. Any pointers to make this working would be appreciated.

Mircea
  • 111
  • 3
  • Did you solve this problem? I too am having issues with grub when trying to create an instance-store CentOS 7 AMI. – David Poxon Oct 19 '15 at 03:39
  • yes. added grub-config and -P options to ec2-bundle-vol: – Mircea Oct 19 '15 at 15:57
  • ec2-bundle-vol -k /tmp/build/cert/privkey.pem -c /tmp/build/cert/privkey.pem -u {{aws_account_id}} -r x86_64 -e /tmp/build --grub-config /tmp/build/menu.lst -P mbr – Mircea Oct 19 '15 at 15:58
  • the kernel and initramfs versions need to be picked up from the grub config the image comes up with (i.e. they need to match the ones the image was booted with) – Mircea Oct 19 '15 at 15:59

0 Answers0