05 Feb

Extend-Resize Microsoft Linux Azure Data Disk & OS Disk

Extend-Resize Microsoft Linux Azure Data Disk & OS Disk

To extend-resize Microsoft Linux Azure Data Disk & OS Disk,  the Powershell method can be used for both Classic and ARM models. By default, the OS disk will be 30 GB for Virtual Machines, which may not be sufficient as the ore data is started to get saved into the OS drive.

PLEASE MAKE SURE THAT, YOU ARE HAVING A VALID BACKUP AVAIALABLE FOR YOUR VIRTUAL MACHINE BEFORE EXECUTING THE BELOW STEPS

Extend Data Disk using Powershell – Classic Mode

To extend a Data disk in an Azure Virtual Machine in Classic Mode, we need to perform the below steps,

  1. Open the Windows Powershell ISE and execute the below script

Extend Data Disk using powershell – ARM Mode

To extend a Data disk in an Azure Virtual Machine in ARM Mode, we need to perform the below steps,

  1. Open the Windows Powershell ISE and execute the below script

Extend OS Disk using Powershell – Classic Mode

To extend a OS disk in an Azure Classic Mode Virtual Machine, we need to perform the below steps,

Open the Windows Powershell ISE and execute the below script

Extend OS Disk using Powershell – ARM Mode

To extend a OS disk in an Azure ARM mode Virtual Machine, we need to perform the below steps,

Open the Windows Powershell ISE and execute the below script

Extend the File System Volume Size of Linux VM

Login to your Azure VM using SSH via putty or terminal

By default, in Azure the linux virtual machines will have an OS disk of size 30GB. To resize the OS disk(root drive), please execute the below command

1) Run the command,

Extend-Resize Microsoft Linux Azure Data Disk & OS Disk2) Press the letter ‘u’ to change the units to sectors.

Extend-Resize Microsoft Linux Azure Data Disk & OS Disk3) Now type the letter ‘p’ to list the partition infomormation. Note the starting sector (e.g. 2048).

Extend-Resize Microsoft Linux Azure Data Disk & OS Disk4) Now we can proceed with deleting the partition table. From the fdisk window, delete the partition.  Press the letter ‘d’ and then select the partition by entering the partition number. By default, it will choose the number  1(Assuming you are modifying OS drive).

In reality, you are not deleting the DATA, but rather modifying the partition table

Extend-Resize Microsoft Linux Azure Data Disk & OS Disk5) Now we need to create a new partition. To create a new partition press the letter ‘n’.

6) Type the letter ‘p’ to create a primary partition.

7) Now you enter the partition number. Type 1 to create the first partition (or another partition number, if required). Use the same starting sector from step 3 and enter a end sector value of your wish or just accept the default end sector value to select the entire disk.

Extend-Resize Microsoft Linux Azure Data Disk & OS Disk8) Type the letter ‘p’ to to ensure all settings are correct. It will print the values to screen.

9)  To save your changes and write to the disc, press ‘w’.

Note : You may get a warning that says:

WARNING: Re-reading the partition table failed with error 16: Device or resource busy. 

Ignore the message, since it is not critical

10) Reboot the vitual machine using by typing the command,

11) Once the VM is up and running, login to your Azure VM using SSH and type “sudo resize2fs /dev/sdaX” to resize the filesystem for CentOS/RHEL 6.x (where X is the partition number you created in step 7. In CentOS/RHEL 7.x the command is “xfs_growfs -d /dev/sdaX”. This may take some time to complete.

Extend-Resize Microsoft Linux Azure Data Disk & OS Disk12) Verify the new size with df -h

Leave a Reply

Your email address will not be published. Required fields are marked *

three × one =