Azure最近推出了一种新型磁盘作为标准SSD磁盘(与高级SSD有所不同)。我想知道是否可以将OS磁盘类型从标准HDD磁盘更改为标准SSD磁盘?
我可以使用与this相同的指令将操作系统磁盘转换为标准SSD吗?
答案 0 :(得分: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 ='StandardSSD_LRS'
答案 1 :(得分:0)
以下示例显示如何将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”。