locked
Extend unmanaged virtual disk in Azure RRS feed

  • Question

  • Hi guys, 

    I have an unmanaged virtual disk in Azure that is about to run out of free space. 

    The OS of virtual machine itself is Windows Server 2016 Standard. 

    Could you please advise how to extend an unmanaged disk in Azure. 

    Regards

    Thursday, July 26, 2018 2:26 AM

Answers

  • To Resize the data disk, I would suggest you to follow the below steps:

    • Stop the vm.
    • Click on the disk name(ex:73ee..).
    • Enter the size of the disk(ex:1000gib) and save.
    • Once the it is done start the vm and login.
    • open a command prompt and type diskpart.
    • At the DISKPART prompt, type list volume. Make note of the volume you want to extend.
    • At the DISKPART prompt, type select volume <volumenumber>. This selects the volume volumenumber that you want to extend into contiguous, empty space on the same disk.
    • At the DISKPART prompt, type extend size=<size>. This extends the selected volume by size in megabytes (MB Example:409600).



    Let me know if there are still any questions I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

    • Proposed as answer by VeeraGiri Babu Saturday, July 28, 2018 8:07 AM
    • Marked as answer by Nightwolf_82 Thursday, August 2, 2018 11:17 AM
    Saturday, July 28, 2018 8:06 AM
  • Shutdown the VM from portal and then only you can do any modification.

    For more information, suggest you to refer Difference Between the States of Azure Virtual Machines: Stopped and Stopped (Deallocated).

    Let me know if there are still any questions I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here


    • Proposed as answer by VeeraGiri Babu Saturday, July 28, 2018 10:04 AM
    • Edited by VeeraGiri Babu Saturday, July 28, 2018 10:07 AM link missing
    • Marked as answer by Nightwolf_82 Monday, July 30, 2018 2:17 AM
    Saturday, July 28, 2018 10:04 AM

All replies

  • I would suggest you to follow the below steps for "Extend unmanaged virtual disk in Azure".
    Open your PowerShell ISE in administrative and run the below cmdlets:

    #login 
    
    Connect-AzureRmAccount
    
    Select-AzureRmSubscription –SubscriptionName 'my-subscription-name'
    
    # Set your resource group name and VM name 
    
    $rgName = 'my-resource-group-name'
    
    $vmName = 'my-vm-name'
    
    # Obtain a reference to your VM 
    
    $vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName
    
    # Stop the VM before resizing the disk
    
    Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName
    
    # Set the size of the unmanaged OS disk to the desired value and update
    the VM
    
    $vm.StorageProfile.OSDisk.DiskSizeGB = 1023
    
    Update-AzureRmVM -ResourceGroupName $rgName -VM $vm
    
    # restart the vm
    
    Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName 

       

    NOTE: The new size should be greater than the existing disk size. The maximum allowed is 2048 GB for OS disks. (It is possible to expand the VHD blob beyond that size, but the OS will only be able to work with the first 2048 GB of space.)

    Expand the volume within the OS:

    Once you have expanded the disk for the VM, you need to go into the OS and expand the volume to encompass the new space. There are several methods for expanding a partition. 

    • Open an RDP connection to your VM.

    • Open a command prompt and type diskpart.

    • At the DISKPART prompt, type list volume. Make note of the volume you want to extend.

    • At the DISKPART prompt, type select volume <volumenumber>. This selects the volume volumenumber that you want to extend into contiguous, empty space on the same disk.

    • At the DISKPART prompt, type extend size=<size>. This extends the selected volume by size in megabytes (MB Example: 917503).

    For more information, suggest you to refer How to expand the OS drive of a virtual machine.


    Let me know if there are still any additional issues I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here
    • Proposed as answer by VeeraGiri Babu Thursday, July 26, 2018 7:29 AM
    Thursday, July 26, 2018 7:28 AM
  • Hi VeeraGiri,

    Thank you for your reply. 

    I can see that this part $vm.StorageProfile.OSDisk.DiskSizeGB = 1023 is related to OS drive. 

    I found this $vm.StorageProfile.DataDisks[0].DiskSizeGB = 1023 and would like to check where I can find that value in square brackets.

    Regards

    Friday, July 27, 2018 5:45 AM
  • $vm.StorageProfile.DataDisks[0].DiskSizeGB is to expand the first data disk attached to the VM, replace the OSDisk object of Storage Profile with Data Disks array and use a numeric index to obtain a reference to first attached data disk.



    Let me know if there are still any additional issues I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here


    Friday, July 27, 2018 8:07 AM
  • Hi,

    Quick question. 

    VM has two unmanaged disks. One for OS and the other one for data.

    How do I resize storage disk?

    Regards

    Friday, July 27, 2018 11:04 PM
  • Please see the screenshot. 

    600 GiB disk Lun 2 is the one I need to extend.

    Saturday, July 28, 2018 4:34 AM
  • To Resize the data disk, I would suggest you to follow the below steps:

    • Stop the vm.
    • Click on the disk name(ex:73ee..).
    • Enter the size of the disk(ex:1000gib) and save.
    • Once the it is done start the vm and login.
    • open a command prompt and type diskpart.
    • At the DISKPART prompt, type list volume. Make note of the volume you want to extend.
    • At the DISKPART prompt, type select volume <volumenumber>. This selects the volume volumenumber that you want to extend into contiguous, empty space on the same disk.
    • At the DISKPART prompt, type extend size=<size>. This extends the selected volume by size in megabytes (MB Example:409600).



    Let me know if there are still any questions I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

    • Proposed as answer by VeeraGiri Babu Saturday, July 28, 2018 8:07 AM
    • Marked as answer by Nightwolf_82 Thursday, August 2, 2018 11:17 AM
    Saturday, July 28, 2018 8:06 AM
  • Hi, 

    I tried this way and Size (GiB) was greyed out. 

    What I did: 

    1) Didn't stop it on Azure Portal VM panel but shut down VM from the VM operating system. 

    2) On Azure Portal I went to Virtual Machines; clicked the required VM; clicked Disks; clicked disk I need to resize.

    Unfortunately, like I said previously the field Size (GiB) was greyed out.  

    Saturday, July 28, 2018 8:26 AM
  • VerraGiri,

    Can I ask you to check if you have this warning message on resizing disks page in Azure. 

    Disks can be resized only when they are unattached or the owner VM is deallocated.

    Saturday, July 28, 2018 8:55 AM
  • Shutdown the VM from portal and then only you can do any modification.

    For more information, suggest you to refer Difference Between the States of Azure Virtual Machines: Stopped and Stopped (Deallocated).

    Let me know if there are still any questions I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here


    • Proposed as answer by VeeraGiri Babu Saturday, July 28, 2018 10:04 AM
    • Edited by VeeraGiri Babu Saturday, July 28, 2018 10:07 AM link missing
    • Marked as answer by Nightwolf_82 Monday, July 30, 2018 2:17 AM
    Saturday, July 28, 2018 10:04 AM
  • Hi VeeraGiri, 

    Thank you for your reply. I think this is what I should try. 

    Just a couple of question before I try it:

    1) When a virtual machine i stopped from Azure Portal is it gracefully shut down first and then stopped (and de-allocated) or it's like powering a VM off without shutting it down properly?

    2) When a VM is stopped and de-allocated its public and private IPs are deleted. Would I be able to re-assign the same IP addressed afterwards?

    Regards 

    Monday, July 30, 2018 2:22 AM
  • VM de-allocation:

    By stopping (deallocating) a VM, you not only stop the VM’s OS, you also free up the hardware and network resources Azure previously provisioned for it (a process called deallocation).

    IP Address:

    Unless you configured static addresses, you also release the internal DIP address, as well as the public VIP address (if no other VMs are using the public VIP, as the VIP is assigned to the cloud service and not directly to the virtual machine). When you restart the VM, it will then pick up a new public VIP (if it is not joining a cloud service that already has one) as well as a new DIP.

    For more information, suggest you to refer Azure Virtual Machines – Stopping versus Stopping (Deallocating).

    Let me know if there are still any additional questions I can help with.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here

    Tuesday, July 31, 2018 7:17 AM
  • Checking in to see if the above answer helped. Let me know if there are still any additional issues I can help with.

    Thursday, August 2, 2018 10:22 AM
  • Job done.

    Disk resized. 

    Thank you very much VeeraGiri for your help. 

    Thursday, August 2, 2018 11:17 AM
  • Glad to know, it helped.

    Friday, August 3, 2018 10:12 AM