Official CentOS EC2 AMIs are available on the AWS Marketplace, making it easy to launch new instances into the appropriate region.

However, there is a major caveat that comes with instances launched from the AWS Marketplace: the attached EBS volumes are restricted to the instance on which they were launched, meaning that you cannot move the instance’s root volume to another virtual machine, even if it is a volume created from a snapshot.

Why is there a restriction like this? To protect “paid-for” AMIs on the Marketplace, which makes sense. However, since the CentOS AMIs are free and open-sourced, this restriction actually presents a major headache for sysadmins, as you cannot attach the root volume to another instance to fix a configuration problem or retrieve data.

There is a way to remove the AWS Marketplace code, however, by doing a raw copy to an empty EBS volume, and creating a new AMI with that new volume.


1) Launch an instance from official list of CentOS AMIs.

2) In the AWS EC2 web console, create a new 8GB EBS volume.

3) Attach this secondary volume to your instance with mount point /dev/xvdj

4) SSH into your instance, and format the secondary volume:

mkfs -t ext4 /dev/xvdj

5) Copy the root volume to the new volume:

dd bs=65536 if=/dev/xvde of=/dev/xvdj

6) Once the raw copying has completed, shutdown the instance.

7) Detach the original root volume from the instance. Detach the secondary volume, and re-attach it as /dev/sda1

8) In the EC2 web console, right-click on your instance and select “Create Image”. Once the image process is complete, you will now have a new base CentOS image with no AWS Marketplace code attached to it!


Credit for this solution goes to Jake on the CentOS Bugtracker.