Skip to content

Instantly share code, notes, and snippets.

@johncant
Last active August 29, 2015 13:56
Show Gist options
  • Save johncant/9236734 to your computer and use it in GitHub Desktop.
Save johncant/9236734 to your computer and use it in GitHub Desktop.
Import linux server installation to AWS ec2 (CentOS)
## Why?
You spent countless hours installing stuff on a CentOS box, only to have to move it to AWS. You should have used chef or puppet, but didn't have time.
## Steps
Please excuse the format and the amateurishness.
(1) Launch the closest instance you can find to what you need. This is so you can replace config on your old box.
(2) Make an EBS volume large enough to meet your requirements, and attach to the ec2 instance you made in (1)
(3) mount the volume you made in (2)
(4) Copy/Extract the files onto the EBS volume
(5) Make the kernel able to find the root partition. To do this, I did the following very hacky thing:
(5.1) Replace the /boot directory with the one from the EC2 instance launched in (1)
(5.2) Change the kernel option in /boot/grub/menu.lst to something like root=/dev/xvde
Change the option in /etc/fstab to /dev/xvde
When registering an AMI from the snapshot in (7), set the root device name to /dev/xvde
(5.3) In (5.1), we changed the kernel version. Use `yum install <all kernel packages and modules> --install-root <your mount point>`
(6) Reconfigure etc/sysconfig/network-scripts/{ifcfg-eth0,<whatever yours is called>} as required. Make sure it doesn't refer to the MAC address of the network interface
(7) Take a snapshot of your volume, and use it to register it as an AMI. This is now possible using the web interface, but you might find it more convenient to use ec2-register.
(8) Launch an instance from your AMI. It will probably require an fsck. Don't use a key pair since the original settings will work.
(9) If it fails, read the system log on ec2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment