Slackware custom amazon AMI from scratch 10-04-2013 |
|
Summary:Sometimes ago, I tried to find a Slackware AMI. Unfortunately, I couldn't find any images. So I aimed to build up it myself. After searching the internet, I found a couple of resources which explains how to do it for some other distributions but not for Slackware. So I want to share my practice with others. Below you can find step by step process of building a Slackware amazon ec2 image from scratch. Prerequisites:Linux host machine; Slackware 13.1 installation media, Amazon AWS account, installed Amazon API and AMI tools Steps:1. Create a working directory # mkdir /tmp/amiworks 2. Prepare installation target Create an image file (~ 8Gb) # dd if=/dev/zero of=/tmp/amiworks/img-slackware bs=16M count=$((64*8)) Create a filesystem on the image # mke2fs -F -j /tmp/amiworks/img-slackware Create a mount point and mount the image to there # mkdir /tmp/amiworks/fs-slackware Partitioning the loop device (here it's our image). And remount the image in order to activate new settings # fdisk /dev/loop0 3. Installing Slackware Either insert installation media or mount the iso file to fs. (I used first one) # cd [path to SlackDVD]/slackware change ROOT path and install packages (this step is really important. If you skip it, then you mess up your host machine.) . Allow full installation under the package groups: a ap d f k l n t tcl and x. I know that some are not needed but I didn't have time to filter out them. (In future I may work on it) The packages under t, tcl and x are important since they are needed for installing xen kernel. # export ROOT=/tmp/amiworks/fs-slackware/ Install grub and finalize preparation # cd ../extra/grub
4. Installing xen kernel Create a working directory # mkdir /tmp/amiworks/xen-kernel Before install the kernel We need to populate all required files and prepare them for the installation process. These are xen packages for 13.1 from slackbuild.org, # wget http://slackbuilds.org/slackbuilds/13.1/development/acpica.tar.gz And for dom0's install script, two required files we need so get them by using internet addresses in the readme file. # cd dom0/ Move all of them to the image filesystem # mv /tmp/amiworks/xen-kernel/ /tmp/amiworks/fs-slackware/tmp/ Change root directory, and modify the PATH of the environment for image filesystem # chroot /tmp/amiworks/fs-slackware/ /bin/bash Install xen package # cd /tmp/xen-kernel/acpica Run the dom0 script. # cd dom0/ 5. After install steps. set the root password and leave the image root directory of the image # passwd root make sure that DHCP is active (edit /etc/rc.d/rc.inet1 file: USE_DHCP[0]="YES" is sufficient. ) create the fstab file as /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 Clean up all the temp files for the image file # rm -r /tmp/amiworks/fs-slackware/tmp/xen* 6. Prepare Amazon Image In order to create an AMI you need amazon ec2 ami and api tools, an amazon account and the account number(like 111222333444 without hyphen), private key and certificate files. # ec2-bundle-image -i /tmp/amiworks/img-slackware -k pk-privatekeyfile.pem -c cert-certificatefile.pem -u 111111111111 type i386 and hit the enter. Before upload the files to Amazon AWS, you need to create a bucket at S3 service. I created a bucked named Slackware-images. Again access and secret keys can be obtained from access credential menu of AWS management console. # ec2-upload-bundle -b slackware-images -m /tmp/img-slackware.manifest.xml -a -s Clear working directory # rm -r /tmp/amiworks With these last steps, we created ami image, uploaded it to Amazon AWS and registered it as an AMI. Now one can use it as an instance Note: When initiate a new instance at AWS/EC2 from this image choose the kernel named as aki-f5cbe081. Last wordsHope this explanations will help you. All comments, corrections etc are welcome. My email address is soydaner{at]kahverengi[dot]com. I will also make this image to public at AWS but please be aware that this image is not suited for production environment but for educational purposes only. Used Resources- Building a root Slackware filesystem from scratch for the User-Mode Linux through loopback devices |
|