Slackware on AWS EC2

Andrew Sarangan
asarangan@gmail.com

On AWS, there aren’t any images of Slackware. If you want to run Slackware, you have to create one from scratch. There is a howto on this topic. Although it was very helpful, I still ran into several issues that required a deeper investigation. This post is a summary of the steps I had to take to create a Slackware machine on EC2. This is not a tutorial on Slackware, AWS, VMware or Linux. It is assumed you are proficient in all of these.

1. Create a Slackware virtual machine

2. Recompile the kernel

cd /usr/src/linux
cp /boot/config .config
cp arch/x86/boot/bzImage /boot/vmlinuz-xen

3. LILO vs GRUB

grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

4. Check ssh connectivity

5. Create key pairs and disable password login (optional)

ssh -i private_key IP_NUMBER -l username

6. Export the VMDK file

C:\Program Files\VMware\VMware OVF Tool>ovftool.exe "C:\Users\asara\Downloads\Virtual Machines\Slackware64-current\Slackware64-current.vmx" "C:\Users\asara\Downloads\Virtual Machines\SlackwareSnapshotForAWS"
Opening VMX source: C:\Users\asara\Downloads\Virtual Machines\Slackware64-current\Slackware64-current.vmx
Opening OVF target: C:\Users\asara\Downloads\Virtual Machines\SlackwareSnapshotForAWS
Writing OVF package: C:\Users\asara\Downloads\Virtual Machines\SlackwareSnapshotForAWS\Slackware64-current\Slackware64-current.ovf
Transfer Completed
Completed successfully

7. Upload the vmdk file to S3

8. Create a vmimport role

{
   "Version": "2012-10-17",
   "Statement": [
      {
         "Effect": "Allow",
         "Principal": { "Service": "vmie.amazonaws.com" },
         "Action": "sts:AssumeRole",
         "Condition": {
            "StringEquals":{
               "sts:Externalid": "vmimport"
            }
         }
      }
   ]
}
aws iam create-role --role-name vmimport --assume-role-policy-document "file://trust-policy.json"
{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Effect": "Allow",
         "Action": [
            "s3:GetBucketLocation",
            "s3:GetObject",
            "s3:ListBucket" 
         ],
         "Resource": [
            "arn:aws:s3:::slackvmdk",
            "arn:aws:s3:::slackvmdk/*"
         ]
      },

      {
         "Effect": "Allow",
         "Action": [
            "ec2:ModifySnapshotAttribute",
            "ec2:CopySnapshot",
            "ec2:RegisterImage",
            "ec2:Describe*"
         ],
         "Resource": "*"
      }
   ]
}
aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document "file://role-policy.json"

9. Convert the vmdk file to a snapshot file

{
  "Description": "Slackware64-15.0",
  "Format": "vmdk",
  "UserBucket": {
                  "S3Bucket": "slackvmdk",
                  "S3Key": "Slackware64-current-disk1.vmdk"
                             }
  }
aws ec2 import-snapshot --description "My Slackware Server" --disk-container "file://containers.json"
{
 "Description": "My Slackware Server",
 "ImportTaskId": "import-snap-0df31ad7db80caa02",
"SnapshotTaskDetail": {
   "Description": "My Slackware Server",
    "DiskImageSize": 0.0,
    "Progress": "0",
    "Status": "active",
    "StatusMessage": "pending",
    "UserBucket": {
        "S3Bucket": "SlackwareSnapshots",
        "S3Key": "Slackware64-current-disk1.vmdk"
    }
},
"Tags": []
}
aws ec2 describe-import-snapshot-tasks --import-task-ids "import-snap-0df31ad7db80caa02"

10. Create Amazon Machine Image (AMI) from the snapshot

11. Launch an instance

12. Kernel updates

13. What do to if the instance refuses to boot

mount /dev/xvdf2 /mnt
chroot /mnt

Leave a Reply

Your email address will not be published. Required fields are marked *