Skip to main content

Microsoft Azure - Virtual machines with 30 GB disk

In Firstpoint we have been using Azure virtual instances for a while now. If you just started using Azure, you probably will not have the issue that we have been facing, however if you have sized your disk properly.

Big disclaimer: use the procedure on your own risk! I’m not responsible if something breaks! The provided solution is as-is without warranty! Be warned.


Background



When we deployed VMs in Azure, the default OS-disk was deployed as a 30GB disk. Now with Windows Server 2012, that does not leave much for other things. The Azure console (read: web GUI) does not provide any way to expand or shrink beyond the boundaries of your initial sized VHD file. People have then been forced to download the VHD file after having deleted the VM and the "disk". After the file have been downloaded, you have to use a VHD tool to increase the size of the VHD. Then you have to upload the file to Azure again, create a new VHD file based on the newly uploaded file and finally create a new VM which would use the new VHD-file. Time consuming and a lot of work. 

Microsoft have as of April 2013 changed the deployment template to a 127GB boot partition (http://weblogs.asp.net/scottgu/archive/2013/04/16/windows-azure-general-availability-of-infrastructure-as-a-service-iaas.aspx).


Resolution



The solution is based upon this blogpost: http://blog.maartenballiauw.be/post/2013/01/07/Tales-from-the-trenches-resizing-a-Windows-Azure-virtual-disk-the-smooth-way.aspx

Mr Balliauw from the link above has create a utility were you don't need to download/upload the VHD file to increase/shrink it. Pretty sweet stuff. I have downloaded his REPRO on GitHUB (https://github.com/maartenba/WindowsAzureDiskResizer). You will need visual studio to compile it after having resolved all the NuGet packages. 

Off we go then. I have this VM in Azure:


The VM only have one disk of type OS disk. Browse to storage, select your storage account, the container where your VHDs are stored, the VHD-disk file and click the Edit BLOB button on the bottom:




When you click the Edit BLOB button this screen should show:





As you can see the disk size is 110 GB (I have shrinked it from 127GB which is the maximum size on Azure).

Next we have to power down the VM. Do a proper shutdown from the operating system and then a shutdown in the Azure web-console. When the status is updated with "Stopped (Deallocated)" you are ready to proceed. Make sure you select the Deallocated VM and press the Delete button: 





When the delete job finishes, we need to go to the "Disks" tab, select the disk of the deallocated VM and press the Delete button. Please make sure you select "Retain the associated VHD"!!!




Next step is to download the repro from GitHUB, please see the link posted above. Resolve the NuGet packages in Visual Studio and build the solution. 

Open up a new command window and browse to the location of your project. Try and run the console application and it should print the "how-to-use" help content:



Time to gather up some input data for the console application.

First one is easy. Determine the new size of the disk. I will set this to 120GB (remember 127 is the maximum for OS-disks in Azure). Next we have to find the bloburl. Navigate to storage, your storage account, the container for your VHDs. The file listing there should give you the file's URL. Next is the account name and the key. The account name is found under Storage: 





There you will also find the access key "Manage access keys" button on the bottom.

Running the command:



Just in case you are wondering, no that is not my access key or my accountname :-).
Good, everything looks okay. Going back to the Azure console, let's edit the blob and check out the details:



Nice, that saved me some time compared to download of 110GB and then uploading 120GB again :-)

Now we need to create a new disk. Please navigate to Virtual machine in the console and choose new disk:



Give the disk a name, chose the VHD by browsing the container of your VHDs and check the option "VHD contains an operating system":




The disk should appear in the disks list under Virtual Machines. Now you are ready to create a new VM using this new disk as the "template". 

Create a new VM:




Select the newly re-sized disk:




That's is, your VM will be deployed using the "new" disk. 

And then the disclaimer:

Big disclaimer: use the procedure on your own risk! I’m not responsible if something breaks! The provided solution is as-is without warranty! Be warned.

Comments

Post a Comment

Popular posts from this blog

Serialize data with PowerShell

Currently I am working on a big new module. In this module, I need to persist data to disk and reprocess them at some point even if the module/PowerShell session was closed. I needed to serialize objects and save them to disk. It needed to be very efficient to be able to support a high volume of objects. Hence I decided to turn this serializer into a module called HashData. Other Serializing methods In PowerShell we have several possibilities to serialize objects. There are two cmdlets you can use which are built in: Export-CliXml ConvertTo-JSON Both are excellent options if you do not care about the size of the file. In my case I needed something lean and mean in terms of the size on disk for the serialized object. Lets do some tests to compare the different types: (Hashdata.Object.ps1) You might be curious why I do not use the Export-CliXML cmdlet and just use the [System.Management.Automation.PSSerializer]::Serialize static method. The static method will generate t

Toying with audio in powershell

Controlling mute/unmute and the volume on you computer with powershell. Add-Type -TypeDefinition @' using System.Runtime.InteropServices; [Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface IAudioEndpointVolume { // f(), g(), ... are unused COM method slots. Define these if you care int f(); int g(); int h(); int i(); int SetMasterVolumeLevelScalar(float fLevel, System.Guid pguidEventContext); int j(); int GetMasterVolumeLevelScalar(out float pfLevel); int k(); int l(); int m(); int n(); int SetMute([MarshalAs(UnmanagedType.Bool)] bool bMute, System.Guid pguidEventContext); int GetMute(out bool pbMute); } [Guid("D666063F-1587-4E43-81F1-B948E807363F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface IMMDevice { int Activate(ref System.Guid id, int clsCtx, int activationParams, out IAudioEndpointVolume aev); } [Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"), Inte

Creating Menus in Powershell

I have created another Powershell module. This time it is about Console Menus you can use to ease the usage for members of your oranization. It is available on GitHub and published to the PowershellGallery . It is called cliMenu. Puppies This is a Controller module. It uses Write-Host to create a Menu in the console. Some of you may recall that using Write-Host is bad practice. Controller scripts and modules are the exception to this rule. In addition with WMF5 Write-Host writes to the Information stream in Powershell, so it really does not matter anymore. Design goal I have seen to many crappy menus that is a mixture of controller script and business logic. It is in essence a wild west out there, hence my ultimate goal is to create something that makes it as easy as possible to create a menu and change the way it looks. Make it easy to build Menus and change them Make it as "declarative" as possible Menus The module supports multiple Men