Migrating Windows 2008 R2/2012 RTM AWS EC2 Instances to Nitro-based AWS EC2 instances

Scenario:
——————
If you have AWS EC2 instance(Non-Nitro based) that is running Windows 2008 R2 or 2012 RTM OS version that was initially launched using Windows AMIs which are older than December 2017 and if you have changed the instance type for that EC2 instance to Nitro-based EC2 instance after installing all the required drivers, even if you had all the required drivers (AWS PV, ENA, NVMe) installed before changing instance type to Nitro-based instance but still that EC2 instance will fail to boot.

So to fix above issue, We need to execute specific sysprep command to sysprep the device drivers as a part of migration process and if you skip or forget that then you will run into above EC2 instance boot issue, this is not the full Windows OS sysprep. I’m demonstrating this complete process step by step so that it will be easy for you to reference.

If you want to understand what are different types of AWS EC2 instances, you may refer below AWS official documentation.

AWS EC2 Instance Types:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html

Step by Step Lab:
—————————–
1. I have  launched a “T2.large” EC2 instance running Windows 2008 R2 OS, this instance was launched using below Windows AMI. This AMI was registered in March 2017.





2. Now let’s first verify all the existing installed AWS drivers on this EC2 instance. You can run below PowerShell command to check this.

Get-WmiObject Win32_PnPSignedDriver|?{$_.manufacturer -like “*Amazon*”} |select DeviceName, DriverVersion, Manufacturer | ft


So we have AWS PV Drivers installed by default as this non-Nitro based instance and our goal here is to migrate this instance to Nitro-based EC2 instance (T3/M5/R5 etc.), so we will have to first upgrade the existing AWS PV drivers and then install other required drivers for Nitro-based EC2 instances.

3. Now backup your EC2 instance (either create snapshot of root volume or create complete Image including all the volume whatever feasible and easy for you) then proceed further, since we are going to upgrade/install new drivers so we must have a backup copy of current state of the EC2 instance to recover in case if something goes wrong after driver upgrade/Instance type change.

4. Download and install latest AWS PV Drivers.
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html#xen-driver-awspv

AWSPVDriverSetup.msi /quiet /norestart


Note: Even if I used “/norestart” but I had to stop/start the instance because status checks started failing. So reboot is must and it takes around 15 minutes to complete this.

5. Verify the driver version, once Instance reports back online after above reboot.


6. Now download and install ENA drivers.
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/migrating-latest-types.html#upgrade-ena


7. Stop the EC2 instance and enable ENA support attribute on the instance using below CLI command, you can use PowerShell as well either.

https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html#enable-enhanced-networking-ena-WIN



8. Now start the instance and install the NVMe drivers. I ran the script “install.ps1” after removing “reboot” logic so it will not reboot forcefully after NVMe driver installation.

https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/migrating-latest-types.html#upgrade-nvme


9. Open PowerShell session and run the following command:

start rundll32.exe sppnp.dll,Sysprep_Generalize_Pnp –wait

Note: This command only runs sysprep on the driver devices. It does not run the full sysprep preparation. Wait for approx 5 minutes after running this command and then stop the instance.



Important Note from above AWS official documentation:
——————————————————————————————————————
“For Windows Server 2008 R2 and Windows Server 2012 RTM, shut down the instance, change the instance type to a latest generation instance and start it, then proceed to next step. If you start the instance again on a previous generation instance type before migrating to a latest generation instance type, it will not boot. For other supported Windows AMIs, you can change the instance type anytime after the device sysprep.”
 ——————————————————————————————————————-

10. Now stop this instance and change the instance type to M5 or R5 (or any other required Nitro-based instance), I’m changing to M5ad Instance type.



11. Now start the instance, it may take some time for the status checks to pass successfully. Once the status checks pass successfully, then you can login and verify if everything is fine.



12. Now if you verify you will see all drivers related to Nitro-based instances.



13. Now you can go ahead and update EC2Config service as well if it’s running older version.
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/UsingConfig_Install.html

So this was my lab demonstration of migrating Windows 2008 R2 instances to Nitro-based EC2 instances that were launched using Windows AMI registered before December 2017. I hope this document will help in case if you have any such EC2 instances that you would like to plan to migrate to Nitro-based EC2 instances.

Leave a Reply

Your email address will not be published. Required fields are marked *