【问题标题】:Convert Azure linux OS disk from normal disk (hdd) to standard ssd disk (preview mode)将 Azure linux OS 磁盘从普通磁盘 (hdd) 转换为标准 ssd 磁盘(预览模式)
【发布时间】:2019-01-05 05:45:19
【问题描述】:

Azure 最近推出了一种新型磁盘作为标准 SSD 磁盘(不同于高级 SSD)。我想知道是否可以将操作系统磁盘类型从标准 HDD 磁盘更改为标准 SSD 磁盘?

我可以使用与this相同的指令将操作系统磁盘转换为标准SSD吗?

【问题讨论】:

    标签: azure azure-virtual-machine disk


    【解决方案1】:

    我认为这个问题更多地与标准 HDD 到标准 SSD 相关。

    $diskName = 'yourDiskName'
    # resource group that contains the managed disk
    $rgName = 'yourResourceGroupName'
    # Choose between Standard_LRS and StandardSSD_LRS based on your scenario
    $storageType = 'StandardSSD_LRS'
    
    $disk = Get-AzureRmDisk -DiskName $diskName -ResourceGroupName $rgName
    
    # Get parent VM resource
    $vmResource = Get-AzureRmResource -ResourceId $disk.ManagedBy
    
    # Stop and deallocate the VM before changing the storage type
    Stop-AzureRmVM -ResourceGroupName $vmResource.ResourceGroupName -Name $vmResource.Name -Force
    
    $vm = Get-AzureRmVM $vmResource.ResourceGroupName -Name $vmResource.ResourceName 
    
    # Update the storage type
    $diskUpdateConfig = New-AzureRmDiskUpdateConfig -AccountType $storageType -DiskSizeGB $disk.DiskSizeGB
    Update-AzureRmDisk -DiskUpdate $diskUpdateConfig -ResourceGroupName $rgName `
    -DiskName $disk.Name
    
    Start-AzureRmVM -ResourceGroupName $vm.ResourceGroupName -Name $vm.Name
    

    cmdlet 中的关键行是设置存储帐户类型。

    $storageType = '标准SSD_LRS'

    文章链接:https://docs.microsoft.com/en-us/azure/virtual-machines/windows/convert-disk-storage#convert-a-managed-disk-from-standard-hdd-to-standard-ssd-and-vice-versa

    【讨论】:

      【解决方案2】:

      以下示例显示了如何将 VM 的所有磁盘从标准存储切换到高级存储。若要使用高级托管磁盘,你的 VM 必须使用支持高级存储的 VM 大小。此示例还切换到支持高级存储的大小。

      #resource group that contains the virtual machine
      rgName='yourResourceGroup'
      
      #Name of the virtual machine
      vmName='yourVM'
      
      #Premium capable size 
      #Required only if converting from standard to premium
      size='Standard_DS2_v2'
      
      #Choose between Standard_LRS and Premium_LRS based on your scenario
      sku='Premium_LRS'
      
      #Deallocate the VM before changing the size of the VM
      az vm deallocate --name $vmName --resource-group $rgName
      
      #Change the VM size to a size that supports premium storage 
      #Skip this step if converting storage from premium to standard
      az vm resize --resource-group $rgName --name $vmName --size $size
      
      #Update the sku of all the data disks 
      az vm show -n $vmName -g $rgName --query storageProfile.dataDisks[*].managedDisk -o tsv \
      | awk -v sku=$sku '{system("az disk update --sku "sku" --ids "$1)}'
      
      #Update the sku of the OS disk
      az vm show -n $vmName -g $rgName --query storageProfile.osDisk.managedDisk -o tsv \
      | awk -v sku=$sku '{system("az disk update --sku "sku" --ids "$1)}'
      
      az vm start --name $vmName --resource-group $rgName
      

      更多详情请参考“Convert Azure managed disks storage from standard to premium, and vice versa”。

      【讨论】:

        猜你喜欢
        • 2023-01-15
        • 2022-01-16
        • 2023-04-04
        • 1970-01-01
        • 1970-01-01
        • 2020-03-31
        • 2022-01-17
        • 2016-05-29
        • 2021-09-22
        相关资源
        最近更新 更多