Mount EC2 snapshot as boot drive
Everytime we release a new version of our C# applications, hosted in IIS on an EC2 instance, we make snapshots prior to the release. We do this as a rollback measure, should the release go awry. We do the same for our EC2 running our hosted WordPress websites.
A while ago, while doing maintenance on the Nginx and CloudFront settings to these websites, I thought I messed up. Under no circumstances could I get it to work. What the hell? I tested it thoroughly on our office server. The only difference should be the firewall. In the AWS cloud you have the added layer of security groups.
In the end I was able to solve it quite easily the next day. It seems that sometimes the buttons in the AWS console don't actually work. This might be a problem isolated to my computer and browser (I have more weird browser issues), but I now always check if the changes are actually saved before proceeding.
However, that is not what I wanted to write down here. Halfway through the release of the new Nginx settings and AWS (CloudFront, EC2 security groups, Hosted Zone) changes, I decided to rollback and go back to the drawing board. Let's review all the changes and try this again when I'm less tired. So, I:
- stopped the EC2 instance
- detached the EBS volume
- created a volume from the snapshot
- and wanted to connect that as the boot drive of the EC2.
That's where I got stuck with a message that it was not allowed to connect the volume to
/dev/sda. Aaah, not now!
Luckily I was not the first with this issue. The solution is quite simple: you have to mount the volume to
/dev/sda1 (some people report
/dev/xvda worked for them) instead of
/dev/sda. With that you can boot the EC2 with the "new" volume.