In the last days I spent some time to take care of some AWS instances, and I ported one of this from instance-store to EBS, so the whole server is persistent and can be restarted without any data loosing.
- Start ad instance-store machine, modify as you like.
- Create a Volume with the size of 10GB and attach it to instance (suppose that it will be /dev/sdf).
-
format it as EXT3
mkfs.ext3 /dev/sdf -
mount it
mkdir /mnt/ebs
mount /dev/sdf /mnt/ebs
-
sync the instance with the volume
rsync -avHx / /mnt/ebs
rsync -avHx /dev /mnt/ebs
-
flush and umount
sync
umount /mnt/ebs
- detach the volume and create a snapshot
-
register the AMI
ec2-register --region $REGION -s $SNAP –name $NAME –description “$DESC” –architecture $ARCH --root-device-name /dev/sda1 --block-device-mapping '/dev/sda2=ephemeral0' --block-device-mapping '/dev/sda3=ephemeral1'
change the appropriate parameter with your own
Now you have a fresh EBS AMI ready to boot into a new instance.
Tags: Amazon Web Services, AMI, EC2
Hi this is the great stuff. Fantastic it works. But I don’t understand at the final when its goes to register the AMI. Can you give an example for this?
ec2-register –region $REGION -s $SNAP –name $NAME –description “$DESC” –architecture $ARCH –root-device-name /dev/sda1 –block-device-mapping ‘/dev/sda2=ephemeral0′ –block-device-mapping ‘/dev/sda3=ephemeral1′
Hi John,
take a look at the official reference
http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-RegisterImage.html
A point worth checking is – should I definitely be making the volume directly on the raw device vs. on a partition on the device?
that is to say, should I not use fdisk to make a /dev/sdf1, and put the filesystem on there?