Can I create an AMI that includes multiple ebs volumes (i.e. both sda and sdb)
Asked Answered
A

1

10

I have an ebs-backed instance running on EC2. I'm using it to do some computationally intensive text processing on around 16Gb of data which is stored on sdb (i.e. the larger ebs volume associated with the instance).

I'd like to parallelized the processing by creating replicas of this instance, each with its own copy of the data. I can create an AMI from the instance but I need the image to include BOTH sda (the root ebs volume) AND ALSO sdb, which is the volume where all the data is. How can I make a replica of the whole package?

Creating an image in the AWS Management Console just copies sda (i.e. the root volume, which is too small to hold my data).

Is this even possible?

(PS: I don't even see the sdb volume in the AWS Management Console Elastic Block Store->Volumes panel)

Thanks!

Anjaanjali answered 5/8, 2011 at 5:46 Comment(0)
N
9

I once needed this sort of setting where I had to setup a MySQL on a EBS backed machine with data store in a separate EBS Volume. The AMI had to be such that every time you instanciate it, it should have the data volume (with static data in it) attached. This is how I did:

  1. Created an EBS backed instance from any existing image
  2. Attached a EBS volume, performed mkfs, mounted on /database
  3. Copied data to the volume, e.g. under /database/mysql
  4. Created image of this setup from AMI web console.

Now, every time I launch this image, I see the volume with all the data is there. I just mount it on /database and things get going.

I am not sure, if this is helpful to you but your problem seemed to close to this.


Update after @NAD's comment

Yeah, AMI creation process excludes stuffs that are under

   /sys
   /proc
   /dev
   /media
   /mnt

So, the trick is to not have stuffs that you want to bundle up with your AMI under these directories.

Also, if you have volume that you want to auto-mount at boot, register it in fstab

Nabonidus answered 5/8, 2011 at 7:13 Comment(3)
Thanks Nishant. Yes. I now realize my mistake. I had put my data on /mnt which was the ephemeral storage that comes with and ebs instance. When I explicitly attach an ebs volume (as you described, for instance) the AMI includes both the root and data partitions. Thanks for your clear response anyhow.Anjaanjali
If the volume is registered in fstab by UUID before I create the AMI, then does EC2 automatically replace that with the UUID of the new volume created when launching the instance? The order of NVMe device names can vary so I don't know of a reliable way to configure them in fstab except by UUID.Highwayman
oh, but the UUID is apparently stored in the filesystem when it's formatted, so I'm guessing it will get saved in the AMI and be the same when I launch a new instance from it (making it rather non-unique)Highwayman

© 2022 - 2024 — McMap. All rights reserved.