Understanding Azure VM Swap OS Disk

Introduction 

"Swap OS Disk" in Azure VM allows you to replace the existing operating system disk of a virtual machine with another one. This is useful for recovery, OS upgrades, or configuration changes. The process involves deallocating the VM, detaching the current OS disk, attaching the new disk, and then restarting the VM to boot from the new disk.

Swapping the OS disk in an Azure VM may be necessary for several reasons to recover from a corrupted operating system, upgrade to a newer OS version, apply security patches, switch to a different pre-configured environment, or revert to a previous stable state using a snapshot. It also helps in quickly resolving boot-related issues or when migrating to a different OS configuration without rebuilding the VM from scratch.

If you want to Disk Swap your OS, you need to know these 4 Steps.

  1. Deploy your VM Machine
  2. Snapshot your VM.
  3. Create the New Disk
  4. Swap the Disk

Step 1. Deploy your VM

if you want to choose a specific operating system for your VM, you can deploy the virtual machine on the Azure portal by selecting the desired OS image from the available options during the VM creation process. This allows you to customize the VM environment to meet your needs.

Note. In this case, I am Creating Windows Server OS.

 VM

Step 2. Snapshot your VM

First, select your server's disk. After choosing the disk, you'll be directed to the Server Disk page. From there, select your primary disk.

 Server Disk

After selecting the VM disk, navigate to the 'Snapshot' option.

Snapshot

First, select your actual resource group and then choose your disk name. After that, navigate to the 'Review + Create' option.

 Resource Group

Create the snapshot.

Create

Step 3. Create the New Disk

After creating the snapshot, create the disks. You can find the option by searching for 'Disks' in the search bar.

New Disk

Create the new disks.

Location

After selecting 'Disks,' click on the 'Create' option to open the new wizard. Select the snapshot option, then click review + create.

Review

Step 4. Swap the disk

After successfully creating the disk, navigate to the 'VM Disks' option.

DIsks

After selecting the 'Disks' option, you'll see a wizard. Then, choose the 'Swap OS Disks' option.

Swap OS Disks

Select your backup disk image & VM name, then apply the image. Then, apply the OK button.

VM name

Okay, finally, successfully changed the swap disk.

External

Conclusion

Swapping the OS disk in an Azure VM via the Azure Portal is an efficient method to upgrade or replace your VM's operating system with minimal downtime. The process involves stopping the VM, detaching the old OS disk, and attaching a new one. This procedure allows for better management of OS-related issues and ensures that the VM remains stable and functional. By following the steps outlined, users can perform the disk swap seamlessly without affecting the overall performance of the virtual machine. Proper planning and execution are key to avoiding potential pitfalls during the swap.