0

I have an Ubuntu VM with a separate mounted data disk on a Premium storage account. The data disk is very large and as a result it is costing me more than I would like. I've tried copying the VHD according to the instructions here, but the operation completes immediately and the resulting VHD size is 0 or -1 according to Powershell (Azure portal shows the proper size, however). Regardless, I detached the premium disk and attached the standard disk in its place. This went poorly, resulting in an initial error message that the disk size of -512 bytes was invalid, and subsequent error messages of

Failed to attach/detach existing disk 'datadrive' to the virtual machine 'myservername'. Error: There is already a lease on the storage container holding the blob with URI

where "attach/detach" was dependent on which operation I was performing. I tried deleting the new standard storage account and starting the process over from scratch, but still had no luck. Ultimately I re-attached the existing disk on the premium account and I was able to start the machine successfully once more, but trying to migrate to the standard storage account was a miserable failure.

Is migrating a data disk from a premium storage account down to standard possible? And if so, what are the steps?

joelmdev
  • 111
  • 1
  • 7

3 Answers3

2

Downgrading from Premium to Standard is not available.

Downsizing from P30/P20 to something less is also not available.

Premium disks can only be attached to VMs that support Premium Storage.

Your only solution here is to create another VM with standard storage and copy your files over network, real pain if you have data like databases or cluster.

If the real reason why you have P30 Premium Storage disks is because Those ARM templates love to create 1000GB disks for something as silly as 1 MB database, then try to modify the templates before deploying them.

Noor Khaldi
  • 3,869
  • 3
  • 19
  • 28
  • 1
    so Azure supports going from standard to premium, but not the other way, huh? – joelmdev Oct 25 '16 at 14:12
  • As of June 2017, going from Premium to Standard worked for me. (Managed disks). I was not able to shrink the disk (had to make a new smaller one and xcopy files over.) – JaredThirsk Jun 08 '17 at 06:47
1

Going off of Noor's answer that migrating from Premium to Standard is not supported, I had to take a different, higher level route. Ultimately I had to create and attach a new disk, copy the existing disk's files to the new disk, and remove + delete the original disk. Here are the steps:

  1. Create a new disk on a Standard storage account and attach it to the VM. This is the destination disk.
  2. Format and mount the new disk to the VM
  3. Stop all processes that could modify files on the source disk (ie the orginal disk on the Premium storage account). In my case only Postgres was using this disk, so sudo pkill -u postgres did the trick.
  4. Copy all files from the source disk to the destination disk using cp -a /source/. /destination/.
  5. Unmount the source drive and remove its fstab entry.
  6. Unmount the destination drive and change its mountpoint from /destination to /source
  7. Re-mount the destination drive with the updated mountpoint, spin up the appropriate services, and test.
  8. Once your satisfied that everything works, you can delete the vhd from the Premium storage account.

Additional help for adding and removing disks from Azure Linux VMs can be found here and here. Though one link is for Resource Manager and the other for Classic resource models, you can handle creating and deleting the vhds through the Azure portal and the Linux commands still stand for either model.

joelmdev
  • 111
  • 1
  • 7
  • As of June 2017, going from Premium to Standard worked for me. (Managed disks). I was not able to shrink the disk (had to make a new smaller one and xcopy files over.) – JaredThirsk Jun 08 '17 at 06:47
1

There is a way to avoid the xcopy or robocopy route. I stumbled on it while trying to figure out a way to migrate azure premium managed disks across subscriptions using powershell. The following site goes into the specific detail https://cloudpuzzles.net/2017/05/moving-azure-managed-disks-around/

Basically an alternative way is as follows

  1. In AzureRM goto the VM choose disk and select the main os disk.
  2. Click export and it will provide a sas URL from there follow steps provided in site above to use powershell to copy the managed disk to a storage container blob.
  3. In Azure Storage Explorer I was able to copy paste the disk to another subscription - you can skip this step
  4. Create a new VM and attach the copied VHD to the VM. This can be done using powershell or after creating the new VM using Azure Storage Explorer to rename the new vhd and rename the target vhd to match the new VMs vhd name.
Stephen v
  • 11
  • 1