How To Resize Linux Virtual Machine OS disk size in Azure Resource Manager

How To: Resize Linux Virtual Machine OS disk Size in Azure Resource Manager

Azure is no doubt the most popular cloud system. A number of virtual machines under an account with as much as disk needed in windows can be created. When I tried the same thing for Linux virtual machine, Azure created a nice and easy to use Linux virtual machine. That virtual machine was equipped with a 32GB OS SSD. In the beginning it worked very well but once the OS disk was full, here comes the problem. IT was a production virtual machine and I was not able to extend the disk without using the command line. To resize Linux Virtual Machine OS disk Size there was a restart required. It was a real pain and I have to bear it.

 

There are many items, you can fall in love. Managing Virtual machines (Windows, Linux, etc..), setting up Key vaults, using active directory and many more items. Setting up virtual machines and services is real easy. There is a wizard available for almost every item offered by Azure. You just need to follow the on screen instructions and you are done in few moments. Once you are done, you can use the service right away. Azure resource manager is making the life of IT admins real easy. They can manage everything under one resource manager so that local data can be shared without any problem.

Resize Linux Virtual Machine OS disk Size

Resize Linux virtual machine OS disk size is not that easy. Many instructions are available on internet but none of them was working for me. I had to create a support ticket and Microsoft support helped me resize the OS disk. There were many hit and trial in the support session but finally I found the under given command which worked.

  1. Login to your Azure account and go to the virtual machine you want to extend the OS disk
  2. Go to disk under the settings of that virtual machine and extend the disk to the level you want.
  3. Login to virtual machine remotely using SSH
  4. run the command fdisk -l to check the disks installed in the virtual machine
  5. in my case it was /dev/sda1 and I had to increase the disk size. remember to increase the disk size in Azure portal.
  6. Issue the command “resize2fs /dev/sda1Resize Linux Virtual Machine OS disk Size

I followed many other instructions like, remove the partition table using fdisk command. recreate the partition table and restart the virtual machine. Unfortunately, none of these methods worked for me. So I used the resize2fs /dev/sda1 command and it worked for me. There was no virtual machine restart required but I restarted just to make sure that it will work in future.

Take the backup before applying these instructions. Better safe than sorry.