Azure 관리 디스크의 디스크 유형 변경

: ✔️ Linux VM ✔️ Windows

Azure 관리 디스크에는 Azure Ultra Disk, 프리미엄 SSD v2, 프리미엄 SSD, 표준 SSD, 표준 HDD의 5가지 디스크 유형이 있습니다. 성능 요구 사항에 따라 프리미엄 SSD, 표준 SSD, 표준 HDD 간에 쉽게 전환할 수 있습니다. 프리미엄 SSD 및 표준 SSD는 영역 중복 스토리지에서도 사용할 수 있습니다. 아직 Ultra Disk 또는 프리미엄 SSD v2 간에 전환할 수 없으며 기존 디스크의 스냅샷을 사용하여 새 디스크를 배포해야 합니다. 자세한 내용은 프리미엄 SSD v2 또는 Ultra Disk로 마이그레이션을 참조하세요.

이 기능은 현재 비관리 디스크에 지원되지 않습니다. 그러나 CLI 또는 PowerShell를 사용하여비관리 디스크를 관리 디스크로 쉽게 변환하여 디스크 유형 간에 전환할 수 있습니다.

시작하기 전에

변환하려면 VM(가상 머신)을 다시 시작해야 하므로 기존 유지 관리 기간 중에 디스크 마이그레이션을 예약합니다.

제한

  • 하루에 두 번만 디스크 유형을 변경할 수 있습니다.
  • 관리 디스크의 디스크 유형만 변경할 수 있습니다. 디스크가 관리되지 않는 경우 CLI 또는 PowerShell를 사용하여 관리 디스크로 변환하여 디스크 유형 간에 전환합니다.

VM의 모든 관리 디스크를 한 계정에서 다른 계정으로 전환

이 예제에서는 VM의 모든 디스크를 프리미엄 스토리지로 변환하는 방법을 보여줍니다. 그러나 이 예제에서는 $storageType 변수를 변경하여 VM의 디스크 유형을 표준 SSD 또는 표준 HDD로 변환할 수 있습니다. 프리미엄 Managed Disks를 사용하려면 VM이 Premium Storage를 지원하는 VM 크기를 사용해야 합니다. 또한 이 예제에서는 Premium Storage를 지원하는 크기로 전환합니다.

# Name of the resource group that contains the VM
$rgName = 'yourResourceGroup'

# Name of the your virtual machine
$vmName = 'yourVM'

# Choose between Standard_LRS, StandardSSD_LRS, StandardSSD_ZRS, Premium_ZRS, and Premium_LRS based on your scenario
$storageType = 'Premium_LRS'

# Premium capable size
# Required only if converting storage from Standard to Premium
$size = 'Standard_DS2_v2'

# Stop and deallocate the VM before changing the size
Stop-AzVM -ResourceGroupName $rgName -Name $vmName -Force

$vm = Get-AzVM -Name $vmName -resourceGroupName $rgName

# Change the VM size to a size that supports Premium storage
# Skip this step if converting storage from Premium to Standard
$vm.HardwareProfile.VmSize = $size
Update-AzVM -VM $vm -ResourceGroupName $rgName

# Get all disks in the resource group of the VM
$vmDisks = Get-AzDisk -ResourceGroupName $rgName 

# For disks that belong to the selected VM, convert to Premium storage
foreach ($disk in $vmDisks)
{
	if ($disk.ManagedBy -eq $vm.Id)
	{
		$disk.Sku = [Microsoft.Azure.Management.Compute.Models.DiskSku]::new($storageType)
		$disk | Update-AzDisk
	}
}

Start-AzVM -ResourceGroupName $rgName -Name $vmName

개별 관리 디스크의 유형 변경

개발/테스트 워크로드의 경우 비용을 줄이기 위해 표준 및 프리미엄 디스크를 혼합할 수도 있습니다. 더 나은 성능이 필요한 디스크만 업그레이드하도록 선택할 수 있습니다. 이 예제에서는 단일 VM 디스크를 표준에서 프리미엄 스토리지로 변환하는 방법을 보여줍니다. 그러나 이 예제에서는 $storageType 변수를 변경하여 VM의 디스크 유형을 표준 SSD 또는 표준 HDD로 변환할 수 있습니다. 프리미엄 Managed Disks를 사용하려면 VM이 Premium Storage를 지원하는 VM 크기를 사용해야 합니다. 이러한 예제를 사용하여 디스크를 LRS(로컬 중복 스토리지) 디스크에서 ZRS(영역 중복 스토리지) 디스크로 변경하거나 그 반대로 변경할 수도 있습니다. 또한 이 예제에서는 Premium Storage를 지원하는 크기로 전환하는 방법을 보여 줍니다.


$diskName = 'yourDiskName'
# resource group that contains the managed disk
$rgName = 'yourResourceGroupName'
# Choose between Standard_LRS, StandardSSD_LRS, StandardSSD_ZRS, Premium_ZRS, and Premium_LRS based on your scenario
$storageType = 'Premium_LRS'
# Premium capable size 
$size = 'Standard_DS2_v2'

$disk = Get-AzDisk -DiskName $diskName -ResourceGroupName $rgName

# Get parent VM resource
$vmResource = Get-AzResource -ResourceId $disk.ManagedBy

# Stop and deallocate the VM before changing the storage type
Stop-AzVM -ResourceGroupName $vmResource.ResourceGroupName -Name $vmResource.Name -Force

$vm = Get-AzVM -ResourceGroupName $vmResource.ResourceGroupName -Name $vmResource.Name 

# Change the VM size to a size that supports Premium storage
# Skip this step if converting storage from Premium to Standard
$vm.HardwareProfile.VmSize = $size
Update-AzVM -VM $vm -ResourceGroupName $rgName

# Update the storage type
$disk.Sku = [Microsoft.Azure.Management.Compute.Models.DiskSku]::new($storageType)
$disk | Update-AzDisk

Start-AzVM -ResourceGroupName $vm.ResourceGroupName -Name $vm.Name

프리미엄 SSD v2 또는 Ultra Disk로 마이그레이션

현재는 Standard Storage(증분 표준 HDD 스냅샷)에 저장된 스냅샷을 통해서만 기존 디스크를 Ultra Disk 또는 프리미엄 SSD v2로 마이그레이션할 수 있습니다. Premium Storage 및 기타 옵션에 저장된 스냅샷을 사용한 마이그레이션은 지원되지 않습니다.

프리미엄 SSD v2 디스크와 Ultra Disks 모두 자체 제한 집합이 있습니다. 예를 들어 둘 다 OS 디스크로 사용할 수 없으며 모든 지역에서도 사용할 수 없습니다. 자세한 내용은 해당 문서의 프리미엄 SSD v2 제한 사항Ultra Disk GA scope 및 제한 사항 섹션을 참조하세요.

Important

표준 HDD, 표준 SSD 또는 프리미엄 SSD를 Ultra Disk 또는 Premium SSD v2로 마이그레이션할 때 논리 섹터 크기는 512여야 합니다.

다음 스크립트는 표준 HDD, 표준 SSD 또는 프리미엄 SSD의 스냅샷 Ultra Disk 또는 프리미엄 SSD v2로 마이그레이션합니다.

$diskName = "yourDiskNameHere"
$resourceGroupName = "yourResourceGroupNameHere"
$snapshotName = "yourDesiredSnapshotNameHere"

# Valid values are 1, 2, or 3
$zone = "yourZoneNumber"

#Provide the size of the disks in GB. It should be greater than the VHD file size.
$diskSize = '128'

#Provide the storage type. Use PremiumV2_LRS or UltraSSD_LRS.
$storageType = 'PremiumV2_LRS'

#Provide the Azure region (e.g. westus) where Managed Disks will be located.
#This location should be same as the snapshot location
#Get all the Azure location using command below:
#Get-AzLocation

#Select the same location as the current disk
#Note that Premium SSD v2 and Ultra Disks are only supported in a select number of regions
$location = 'eastus'

#When migrating a Standard HDD, Standard SSD, or Premium SSD to either an Ultra Disk or Premium SSD v2, the logical sector size must be 512
$logicalSectorSize=512

# Get the disk that you need to backup by creating an incremental snapshot
$yourDisk = Get-AzDisk -DiskName $diskName -ResourceGroupName $resourceGroupName

# Create an incremental snapshot by setting the SourceUri property with the value of the Id property of the disk
$snapshotConfig=New-AzSnapshotConfig -SourceUri $yourDisk.Id -Location $yourDisk.Location -CreateOption Copy -Incremental 
$snapshot = New-AzSnapshot -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName -Snapshot $snapshotConfig

$diskConfig = New-AzDiskConfig -SkuName $storageType -Location $location -CreateOption Copy -SourceResourceId $snapshot.Id -DiskSizeGB $diskSize -LogicalSectorSize $logicalSectorSize -Zone $zone
 
New-AzDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName

다음 단계

스냅샷을 사용하여 VM의 읽기 전용 복사본을 만듭니다.