Safely Restore an AWS EC2 Root Volume from Snapshot

Sure, most people with servers in AWS occasionally take snapshots of their EC2 instances’ root volumes to protect against crashes, corrupt updates, etc., but many new AWS admins never actually attempt to to restore a server’s backed-up root volume from a snapshot until they have to. So, if you’ve never had to do it before, and now a series of panicked web searches has lead you here, then don’t worry – it’s easy to restore the server back to its snapshotted state, even maintaining its original IP address and host name, just like nothing happened. Here’s how…

  1. Find the instance in EC2 and stop it.
  2. Make a note of the instance’s Availability Zone, and then scroll down to where it lists the instance’s “Root device” and make a note of what it’s called (it usually is “/dev/sda1”). Now click on the Root device, and in the little window that appears, click on the EBS ID (“vol-xxxxxxxxxxx”).
  3. You’ll be sent to the EBS Volumes page, filtered to only show the volume you’re interested in. Right-click on the volume name and choose “Detach Volume.”
  4. Now go to the EBS Snapshots page and find the snapshot you want to use as the new root volume. Right-click on it and choose “Create Volume.”
  5. In the “Create Volume” page, make sure the availability zone of the volume matches the availability zone that you made a note of in Step 2 (i.e., the EBS volume you create must be in the same AZ as its instance).
  6. Also, in the “Create Volume” page, be sure to check the box at the bottom to “Add tags to your volume” and then create a “Name” tag with a value of something like: “<instance name> – <device name> (from Step #2 above) – restored <today’s date>”. (So, we’re giving the new volume the same name the original one had when it was created, and appending some info at the end to indicate it’s a restored copy.) When done, click the Create Volume button.
  7. Once the volume has been created, go back to the EBS Volumes page and right-click on the volume you just created, then choose “Attach Volume.”
  8. When you click in the “Instance” field, it will bring up a list of instances in your account/region that you can attach it to. Select the instance you’re interested in.
  9. In the “Device” field, it will make a suggestion for a device name that would make sense if you were adding this volume to the instance as an additional disk, but since we’re making it the root volume, you can ignore the suggested name and enter the name you made a note of in Step #2 above. (e.g., /dev/sda1)
  10. Once you click the “Attach” button to close that window, it will attach the volume to the instance you specified as the root volume. You can now go back to the “Instances” page and start your instance. If everything went smoothly, the instance will start as normal, like nothing happened. If not, you’ll get a message telling you the instance can’t boot, so check that you entered the correct device name when trying to attach the volume.
  11. Now that your server is up and running on the new volume, you can do a little housekeeping by going back and deleting the old volume, if you won’t be using it anymore.

That’s it! See, nothing to worry about – it’s easy when you know how! :)

Steve