Search code examples
azurescalingazure-vm

Will I lose the data from my disk if I switch from SSD to HDD in a azure VM?


I have $500 to spend in Azure credits. I noticed that the SSD costs to much, So I want to switch from an SSD disk to an HDD disk. I was wondering if I switch will my data be lost? I apologize for the poor grammar in this question. Please comment if you need me to make my question more clear.


Solution

  • You can convert VM OS disk from Premium SSD disk to Standard HDD disk.

    Your data won't be lost.

    Configuration example from Azure Portal:

    1. Select the VM from the list of Virtual machines.
    2. If the VM isn't stopped, select Stop at the top of the VM Overview pane, and wait for the VM to stop.
    3. In the pane for the VM, select Disks from the menu.
    4. Select the disk that you want to convert.
    5. Select Configuration from the menu.
    6. Change the Account type from the original disk type to the desired disk type.

    enter image description here

    https://www.unixarena.com/2019/12/azure-how-to-convert-disk-from-premium-to-standard-ssd-vice-versa.html/

    Configuration example using CLI:

    #resource group that contains the managed disk
    rgName='yourResourceGroup'
    
    #Name of your managed disk
    diskName='yourManagedDiskName'
    
    #Premium capable size 
    #Required only if converting from Standard to Premium
    size='Standard_DS2_v2'
    
    #Choose between Standard_LRS, StandardSSD_LRS and Premium_LRS based on your scenario
    sku='Premium_LRS'
    
    #Get the parent VM Id 
    vmId=$(az disk show --name $diskName --resource-group $rgName --query managedBy --output tsv)
    
    #Deallocate the VM before changing the size of the VM
    az vm deallocate --ids $vmId 
    
    #Change the VM size to a size that supports Premium storage 
    #Skip this step if converting storage from Premium to Standard
    az vm resize --ids $vmId --size $size
    
    # Update the SKU
    az disk update --sku $sku --name $diskName --resource-group $rgName 
    
    az vm start --ids $vmId 
    

    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/convert-disk-storage