This is my third post on getting Mageia2 running on Amazon Web Services' Elastic Compute Cloud. See my first post in the series for an overview.
In my last post I described how to create and upload an AMI that allows you to run Mageia2 on EC2. There were two issues with that method:
- The EC2 instances are using a one-off unverified kernel, obtained for testing purposes only.
- The instances launched can only be instance-store backed, ephemeral disk.
Both of these problems are solvable. We'll address the kernel first. The solution? Compile your own!
As with any good open-source project, you can easily obtain the source code. The same holds for Mageia. For recompiling the kernel, I plucked the kernel's SRPM file off mirrors.kernel.org. Reviewing the source, there were considerable tweaks made by the Mageia development team - so much so that they were bundled together inside the SRPM. Once I was able to dig into that tarball, I found where to enable CONFIG_KERNEL_GZIP and disable CONFIG_KERNEL_XZ in the configuration.
Now it was a matter of getting a system to build the kernel on. Initially, I tried to do it on my local seed Mageia VM, but the 10GB disk was too small to hold all the compiled kernel sources. So, I launched an instance using the EC2 console of the freshly-uploaded Mageia2 AMI. This is where I ran into the limitation of the first revision of the AMI I created - 2GB was insufficient to install all the compiler dependencies needed for creating a kernel package - but 8GB was ok.
Finally, I launched an m2.xlarge instance via the EC2 console with an 8GB root disk on instance-store to do the compilation. I wanted an instance with at least 2 cores to speed up the compile and sufficient additional space on ephemeral disk (/dev/xvdb) that could hold the compiled kernel sources. It still took a considerable amount of time - approximately 2 hours to compile the RPM. When I have to do this again in the future, I might consider a high I/O instance to reduce the time spent waiting for the compile. Either way, the cost is negligible if you remember to shut it down after you're done - the m2.xlarge was around $1.35 for 3 hours and a hi1.4xlarge would be $3.10 for one hour. For those who follow this blog, you should recognize the build script.
EDIT: on 1/18/13, I recompiled the kernel using an hi1.4xlarge and the final timing from "time ./do-build.sh" was:
real 51m5.356s
user 173m1.470s
sys 32m44.040s
Of course, it took a little longer than that to install all the packages needed for building, but it can be done in less than 2 hrs.
Here are the steps for compiling the Mageia2 kernel:
Now it was a matter of getting a system to build the kernel on. Initially, I tried to do it on my local seed Mageia VM, but the 10GB disk was too small to hold all the compiled kernel sources. So, I launched an instance using the EC2 console of the freshly-uploaded Mageia2 AMI. This is where I ran into the limitation of the first revision of the AMI I created - 2GB was insufficient to install all the compiler dependencies needed for creating a kernel package - but 8GB was ok.
Finally, I launched an m2.xlarge instance via the EC2 console with an 8GB root disk on instance-store to do the compilation. I wanted an instance with at least 2 cores to speed up the compile and sufficient additional space on ephemeral disk (/dev/xvdb) that could hold the compiled kernel sources. It still took a considerable amount of time - approximately 2 hours to compile the RPM. When I have to do this again in the future, I might consider a high I/O instance to reduce the time spent waiting for the compile. Either way, the cost is negligible if you remember to shut it down after you're done - the m2.xlarge was around $1.35 for 3 hours and a hi1.4xlarge would be $3.10 for one hour. For those who follow this blog, you should recognize the build script.
EDIT: on 1/18/13, I recompiled the kernel using an hi1.4xlarge and the final timing from "time ./do-build.sh" was:
real 51m5.356s
user 173m1.470s
sys 32m44.040s
Of course, it took a little longer than that to install all the packages needed for building, but it can be done in less than 2 hrs.
Here are the steps for compiling the Mageia2 kernel:
# # prep stuff done as root # sudo bash -o vi # mount the ephemeral storage mkfs -t ext4 /dev/xvdb mkdir /media/extra mount /dev/xvdb /media/extra # create some swap dd if=/dev/zero of=/media/extra/swapfile00 bs=1024 count=4194304 mkswap /media/extra/swapfile00 swapon /media/extra/swapfile00 # setup space for kernel building mkdir /media/extra/kernel chown $USER:$USER /media/extra/kernel exit # # build stuff done as normal user # # prep for kernel building cd $HOME ln -s /media/extra/kernel cd kernel/ # bring down the source curl -O http://mirrors.kernel.org/mageia/distrib/2/SRPMS/core/updates/kernel-3.3.8-2.mga2.src.rpm mkdir SOURCES cd SOURCES # extract the source rpm2cpio ../kernel-3.3.8-2.mga2.src.rpm | cpio -i # make a working copy of the .spec file cp -p kernel.spec .. # extract the mageia customizations tar Jxf linux-3.3.8-mga2.tar.xz cd 3.3.8-mga2/configs/ # modify the kernel config for gzip compression cp -p x86_64.config x86_64.config.orig vi x86_64.config # diff of what it looks like when it's done $ diff -u x86_64.config.orig x86_64.config --- x86_64.config.orig 2012-07-12 08:53:47.000000000 +0000 +++ x86_64.config 2012-11-15 04:48:37.000000000 +0000 @@ -67,10 +67,10 @@ CONFIG_HAVE_KERNEL_LZMA=y CONFIG_HAVE_KERNEL_XZ=y CONFIG_HAVE_KERNEL_LZO=y -# CONFIG_KERNEL_GZIP is not set +CONFIG_KERNEL_GZIP=y # CONFIG_KERNEL_BZIP2 is not set # CONFIG_KERNEL_LZMA is not set -CONFIG_KERNEL_XZ=y +# CONFIG_KERNEL_XZ is not set # CONFIG_KERNEL_LZO is not set CONFIG_DEFAULT_HOSTNAME="(none)" CONFIG_SWAP=y # rebuild the mageia customizations cd ../.. mv linux-3.3.8-mga2.tar.xz linux-3.3.8-mga2.tar.xz.orig tar Jcf linux-3.3.8-mga2.tar.xz 3.3.8-mga2 # install builder dependencies sudo urpmi easyrpmbuilder sudo urpmi elfutils-devel zlib-devel binutils-devel newt-devel python-devel pciutils-devel asciidoc xmlto docbook-style-xsl # setup the build script cat do-build.sh #!/bin/sh -x rm -rf BUILD BUILDROOT RPMS SRPMS tmp || true mkdir -p BUILD BUILDROOT RPMS SRPMS tmp OPTS="" OPTS="$OPTS --with=server" OPTS="$OPTS --without=desktop" OPTS="$OPTS --without=desktop586" OPTS="$OPTS --without=netbook" rpmbuild $OPTS -bb --define="_topdir $PWD" --define="_tmppath $PWD/tmp" kernel.spec 2>&1 | tee kernel-build.txt # do the build time ./do-build.sh # save the rpm scp -p RPMS/x86_64/kernel-server-3.3.8-2.mga2-1-1.mga2.x86_64.rpm $REMOTE_SERVER:
No comments:
Post a Comment