- Here are the requirements for converting a PV instance to HVM.
- A PV based instance, HVM instance (needs to be created) and a conversion instance (needs to be created).
- Snapshots of the EBS volume(s) of the instance to be converted.
- You'll need to snapshot the volume of the existing PV instance. Ideally the snapshot is taken with the instance in a stopped state.
You may also have an instance store volume. During a stop action any data on the instance store will be lost.
Next create an HVM instance, using as close as possible your current OS, (i.e., make sure the kernel versions match).
2.A. Create the HVM instance in the same Availability Zone (AZ) as your PV instance (eu-west-1b) and with the same size EBS volume 15GB.
2.B. Once it has started and is running you can stop it. Tag the Volume with something like OS-HVM and detach it from the HVM instance.
Start a conversion instance wait for it to fully start. (It is important that the instance is fully started before attaching the other volumes.)
3.A. SSH into the conversion instance.
3.B. Attach the HVM volume to the conversion instance as /dev/xvdf. For example:
cd / sudo mkdir /hvmsudo mount /dev/xvdf1 /hvm
The following 3.C, 3.D and 3.E steps may not be needed on all Linux versions, however it is recommended.
3.C. Ensure you keep the HVM boot directory by moving it to the tmp directory.
sudo mv /hvm/boot /tmp/boot.hvm
3.D. Empty out the rest of the drive with:
sudo rm -Rf /hvm/*
3.E. Verify the drive is now empty with:
sudo ls -al /hvm
With the snapshot of the Volume from your PV instance you'll want to Create Volume in the EC2 console. Keep the current volume size and create it in the same AZ (eu-west-1b). Find the new EBS volume and tag it OS-PV.
4.A. Attach it to the conversion instance as /dev/xvdg
sudo mkdir /pvsudo mount /dev/xvdg /pv
4.B. Verify that it is mounted and has the correct file structure.
# You should see the boot and other root directories.sudo ls /pv
4.C. Then copy the contents of /pv to /hvm
sudo cp -p -R /pv/* /hvm
Change the boot directory to be HVM based.
5.A. Remove the PV boot directory and replace it with the HVM boot directory.
sudo rm -R /hvm/boot
5.B. Copy back the saved HVM boot directory.
sudo mv /tmp/boot.hvm /hvm/boot
- Verify there are now all the needed directories and files on the HVM volume with.
sudo ls -al /hvm
- You can now unmount the hvm volume.
sudo umount /hvm
Find the OS-HVM volume and detach it from the conversion instance.
8.A. Attach it back to the HVM instance as device /dev/xvda
8.B. Start the HVM instance.
Clean up the conversion instance and any unwanted or left over volumes/snapshots.