Skip to content
Geek and I
Go back

Amazon Linux to Vagrant Box - Part 1

Updated:
Mike Horwath2 min read

You will need to get a few things set up for this to move forward.

Head over to aws.amazon.com and log yourself in. You then need to fire up a new instance using the Amazon Linux AMI. Machine type does not matter in this case and I used a t1.micro as my base.

Once your instance is running you will need to install some software and update the system software, after you log in and become root:

Terminal window
sudo su - root
yum install make
yum install kernel-devel
yum install gcc
yum install grub
yum update

You will prompted before each install, and you should say ‘y’ (or yes) and let it run. When complete you should then issue the reboot command:

Terminal window
reboot

Now the Amazon Linux instance is ready for us to continue.

In your virtualization platform (Fusion in my case), make yourself a VM with 2 virtual disks.

Attach your CDROM device to your new virtual machine and boot up.

Install your distribution on to the 10 GiB virtual disk and reboot.

Once the system is back up, log in and become root (prompt will use a # symbol).

From the command line, log into a root shell so you can skip prefacing everything with sudo:

Terminal window
sudo su - root

Now that you are in a root shell, make a new primary partition on /dev/sdb and build a filesystem:

Terminal window
fdisk /dev/sdb
mkfs.ext4 /dev/sdb1

Install dump (and restore) utilities, mount virtual disk and prepare for building phase 1 of the image:

Terminal window
apt-get install dump
mkdir -p /mnt
mount -o noatime,async /dev/sdb1 /mnt

Now copy all the data from your Amazon Linux EC2 image to this new virtual disk:

Terminal window
ssh \
-i /path/to/your.pem \
ec2-user@remote-ip-address \
"sudo dump -0 -f - /" | \
(cd /mnt ; restore -rf -)

And a breakdown of the above command line:

Depending on your download speed from the Internet this should take between 3-10 minutes to complete.

While this is still not a bootable system, if all went well, you now have a copy of Amazon Linux locally.

The next post will show you how I set up the environment to boot for the first time.



Related Posts

Previous Post
Amazon Linux to Vagrant box
Next Post
How To Patch vSphere 5 ESXi Without Update Manager