Reputation: 17
I have an Azure managed disk of 500GB that when used on a virtual machine has a 126GB C drive and a 399GB D drive. This was created in Terraform in the azurerm_virtual_machine resource via:
storage_os_disk {
name = "diskname"
disk_size_gb = "500"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
os_type = "Windows"
}
I am taking a copy of this for use on another virtual machine via:
resource "azurerm_managed_disk" "copy" {
name = "diskcopy"
location = var.rglocation
resource_group_name = var.rgname
storage_account_type = "Standard_LRS"
create_option = "Copy"
source_resource_id = "/subscriptions/xxxxx/originalos"
}
I am then mounting the copy on the new virtual machine via:
storage_os_disk {
name = "diskname"
caching = "ReadWrite"
create_option = "Attach"
managed_disk_id = var.manageddiskid
os_type = "Windows"
}
However, when I open the new virtual machine only the C drive is included in the copy. How can I also copy the D drive? I have tried to use the azurerm_virtual_machine_data_disk_attachment resource to attach the same resource ID of the managed disk but get the following error (which makes sense):
│ Error: updating Virtual Machine "Virtual Machine: (Name \"xxx\" / Resource Group \"xxx\")" with Disk "xxx": compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=409 -- Original Error: Code="ConflictingUserInput" Message="Disk 'xxx' cannot be attached as the disk is already owned by VM 'xxx'."
Upvotes: 0
Views: 919
Reputation: 17
I didn't realise that the C drive was only allocated 126GB and had 374GB of unallocated space. The solution is to extend the C drive to use the unallocated space (giving 500GB total). The point of confusion for me is the existence of a 500GB D drive which I've now realised comes as part of the image and is not a managed disk.
Upvotes: 0