Replace AWS Root volume

Amazon EC2 announces the Replace Root Volume feature that enables customers to replace the root volume for a running instance. Earlier we need to stop EC2 instance if we want to change root volume due to any issue or corrupt.

The feature restores the root volume of an instance to its launch state, or to a specific snapshot, without stopping the instance. This allows us to fix issues, such as root volume corruption or guest operating system network configuration errors.

When you replace the root volume for an instance, a new volume is restored to the original volume's launch state, or using a specific snapshot.

As you can see below, I have a EC2 instance named Docker which has a root volume - vol-0ddb10f0d968aa6b8, Now I'm going to replace it without stopping EC2.

image.png

Select an EC2 - Actions - Monitor & troubleshoot - Replace root volume

image.png

To restore the instance's root volume to a specific snapshot, for Snapshot, select the snapshot to use, and then select create replacement task.

To restore the instance's root volume to its initial launch state, choose create replacement task without selecting a snapshot.

image.png

Now we can see volume replacement task status from pending to successful.

image.png

image.png

The original volume is detached from the instance, and the new volume is attached to the instance in its place. The original volume is not automatically deleted. If you no longer need it, you can delete it manually after the root volume replacement task completes.

Also you can see earlier volume id was vol-0ddb10f0d968aa6b8 & now it's vol-045970ba9afbbed32

image.png

There are few limitations as well:

You can't replace the root volume if it is an instance store volume.

You can't replace the root volume for metal instances.