0

I am attempting to create an EBS-backed image from a running instance, similar to this post on SO. I'm using primarily these sites as references:

  1. Create a bootable EBS AMI from a running instance
  2. A script to rsync a running Linux OS to an image file

I successfully created the EBS volume, ran mkfs.ext3 against it (I formatted the whole drive, not a partition -- is this the problem, perhaps?) and used the following rsync command to make a copy of the filesystem:

rsync --stats -avv --exclude=/root/.bash_history --exclude=/home/*/.bash_history --exclude=/etc/ssh/ssh_host_* --exclude=/etc/ssh/moduli --exclude=/etc/udev/rules.d/*persistent-net.rules --exclude=/mnt/* --exclude=/proc/* --exclude=/tmp/* --exclude=/sys/* --exclude=/dev/* --exclude=/production --exclude=/media / /mnt/ebs-root/

(where /media and /production are directories mounted from other EBS volumes, and /mnt/ebs-root/ is the new EBS volume which will contain the image)

the rsync works well enough, I can unmount the volume, snapshot it, and use the AWS console to make a bootable image... but when it boots, I can't access it over the web/ssh (after changing its elastic IP in the AWS console).

I noticed that I might need to edit some files in the new EBS volume (like /etc/fstab) but I'm not sure. Here's the contents of my /mnt/ebs-root/etc/fstab, anyway:

# Legacy /etc/fstab
# Supplied by: ec2-ami-tools-1.3-34544
/dev/sda1 /     ext3    defaults 1 1
/dev/sda2 /mnt  ext3    defaults 0 0
/dev/sda3 swap  swap    defaults 0 0
/dev/sdp1 /production  ext3    defaults 0 0
none      /proc proc    defaults 0 0
none      /sys  sysfs   defaults 0 0

I'm way outside my knowledge base here and hoping someone can point me in the right direction. Thanks in advance.

Community
  • 1
  • 1
Alex W
  • 719
  • 7
  • 14
  • Can you clarify: does the new image actually boot successfully (check console log)? Can you ssh to the machine before assigning the EIP? Does your Security Group allow ssh access? Are you unable to ssh after assigning EIP, and are you allowing enough time for the EIP to become effective? – Eight-Bit Guru Jan 17 '12 at 10:27
  • here's the system log from amazon: http://pastebay.com/289600 I can't SSH in at all -- before or after assigning EIP. I just tried with the same instance after it's been running overnight so it's probably not waiting. – Alex W Jan 17 '12 at 21:56
  • looks like the problem may be corruption from taking a snapshot of the system while it's running. I'll try stopping mysql/apache/etc and see if that helps. (reference: https://forums.aws.amazon.com/thread.jspa?threadID=84523 ) – Alex W Jan 17 '12 at 22:05
  • 1
    Yep, absolutely never take a snapshot of a bootable volume (and, ideally, not from any attached volume) when the instance is running. Always stop the instance first, as this ensures the OS won't be doing any writes to the volume whilst you're snapping it. Also check your security group is allowing ssh through to the instance. – Eight-Bit Guru Jan 17 '12 at 22:48

1 Answers1

1

The problem was that I attempted to image the instance while it was running. I figured since nobody was accessing the site that I could image it while running, but apparently not. Here's what I ran:

/etc/init.d/apache2 stop

/etc/init.d/mysql stop

and then I re-ran my rsync command from above, and the instance is now reachable by SSH! (I have a new problem now, but that's for another topic ;)

Thanks Jonners for the tips.

Community
  • 1
  • 1
Alex W
  • 719
  • 7
  • 14