代码之家  ›  专栏  ›  技术社区  ›  Gregory Suvalian

如何在Azure中更改托管磁盘的“ostype”?

  •  0
  • Gregory Suvalian  · 技术社区  · 6 年前

    我有一个托管磁盘,它包含操作系统,但没有标记为具有操作系统(ostype属性为空)。如何更改该属性以便在门户中创建新的VM?

    PS Azure:\> $disk
    
    
    ResourceGroupName  : KoreaCentralShared
    ManagedBy          :
    Sku                : Microsoft.Azure.Management.Compute.Models.DiskSku
    Zones              :
    TimeCreated        : 12/18/18 9:45:26 PM
    OsType             :
    CreationData       : Microsoft.Azure.Management.Compute.Models.CreationData
    DiskSizeGB         : 80
    EncryptionSettings :
    ProvisioningState  : Succeeded
    DiskIOPSReadWrite  :
    DiskMBpsReadWrite  :
    Id                 : /subscriptions/5171/resourceGroups/K/providers/Microsoft.Compute/disks/RHEL_DataDisk_0
    Name               : RHEL_DataDisk_0
    Type               : Microsoft.Compute/disks
    Location           : koreacentral
    Tags               : {}
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Hannel    6 年前

    您应该能够使用下面的命令更新ostype。

    例子:

    $update = New-AzureRmDiskUpdateConfig -OsType <OSType> Update-AzureRmDisk -DiskName <diskname> -DiskUpdate $update -ResourceGroupName <rgname>

    我个人会将磁盘复制到新磁盘,并在创建新磁盘时指定ostype。

    例子:

    $managedDisk = Get-AzureRmDisk -DiskName <diskname> -ResourceGroupName <rgname> $diskConfig = New-AzureRmDiskConfig -SourceResourceId $managedDisk.Id -Location $managedDisk.Location -CreateOption Copy -OsType Linux New-AzureRmDisk -Disk $diskConfig -DiskName <Newdiskname> -ResourceGroupName <rgname>

    https://docs.microsoft.com/en-us/azure/virtual-machines/scripts/virtual-machines-windows-powershell-sample-copy-managed-disks-to-same-or-different-subscription

    希望这有帮助。