[CentOS] Amazon Marketplace AMI

Mon Oct 20 19:11:37 UTC 2014
Patrick Flaherty <pflaherty at wsi.com>

On Fri, Oct 17, 2014 at 3:45 AM, Thorsten Höger <lists at hoegernet.de> wrote:

> Hi,
>
> the updated Amazon Web Service AMI (ami-4ac6653d) has a serious bug.
> It is not possible to resize a disk after creating a new volume with a
> size greater than 8GB.
>
> resize2fs does nothing.
>
> The previous AMI worked perfectly but is no longer available. This bug is
> a show stopper
> for using CentOS on AWS.
>

 I rarely use the CentOS AWS market place AMIs, and frequently build my own
HVM images. It sounds more like the root FS isn't expanding based on the
volume thrown at it. I guess the image could have some sort of "delete last
partition, extend that partition to end of drive, extend root volume to end
of drive" magic in initrd, but that sounds sketch. Multiple volumes mounted
in multiple places are "better" than a single gigantic root partition in
traditional system engineering. You can snapshot your data volume, not your
os install volume, or your os install without your log directory, all using
native amazon tools.

For your specific problem, you can try this for an AWS specific solution:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/storage_expand_partition.html
(easy-ish, but time consuming)
* or you could do the traditional:
http://geekswing.com/geek/unix/extending-a-linux-disk-with-lvm-extending-root-partition/
* Or you could add another volume, and extend your VG onto that volume.
Actually, don't do that, you'd have to shut off the instance to snap shot
the drives to keep the blocks in sync. Which makes this dumb approach of
large root volumes even dumber.

If you want to make your own HVM instance. Here's the basic process I
follow. The post chunk from KS file has been edited a bit, but should work.
This was all stolen from various stack overflow and blog postings, if you
see your code in here, thank you for posting your work.

## Create VM locally in Virtual Box
## Convert VM disk image to RAW
Get qemu-img from http://wiki.qemu.org/Main_Page
qemu-img supports lots of file types, my file type was vmdk non-streaming.
<pre> qemu-img convert -f vmdk -O raw c6ami.vmdk c6ami.raw</pre>
## Upload to Amazon
* Grab tools from: http://aws.amazon.com/developertools/351
* Set up your environment
<pre>
export AWS_ACCESS_KEY=asdfasdfasdf
export AWS_SECRET_KEY=asdfasdfasdfasdfasdfsadfsdasdfasdf
export EC2_HOME=/where/you/downloaded/ec2_dev_tools
export JAVA_HOME=`/usr/libexec/java_home`
</pre>
* Upload your file. Amazon only allows linux to be uploaded to the
following platforms:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/VMImportPrerequisites.html
<pre>ec2-import-instance c6ami.raw -f RAW -t m3.xlarge -a x86_64 -b
c6ami_bucket -o s3bucketkey -w s3bucketsecretkey -p Linux</pre>
* Wait

The kickstart file I use to build the image does this this on post to
enable sudo/centos user, and sriov if launched with enhanced networking
enabled.

yum clean all
chkconfig ntpd on
sed -i 's/^ssh_deletekeys:.*$/ssh_deletekeys:   1/'  /etc/cloud/cloud.cfg
sed -i 's/name: cloud-user/name: centos\
    lock_passwd: True\
    gecos: CentOS\
    groups: \[adm, audio, cdrom, dialout, floppy, video, dip\]\
    sudo: \[\"ALL=(ALL) NOPASSWD:ALL\"\]\
    shell: \/bin\/bash/' /etc/cloud/cloud.cfg
echo '#!/bin/sh
/sbin/modprobe ixgbevf' > /etc/sysconfig/modules/sriov.modules
chmod 755 /etc/sysconfig/modules/sriov.modules
rm  /etc/udev/rules.d/70-persistent-net.rules