DEV Community

Cover image for How to Add a Data Disk to a Virtual Machine in Microsoft Azure using the Azure Portal
Ibrahim Bio Abubakar
Ibrahim Bio Abubakar

Posted on

How to Add a Data Disk to a Virtual Machine in Microsoft Azure using the Azure Portal

Introduction

In Microsoft Azure, virtual machines (VMs) often require additional storage beyond their default Operating System (OS) disk. Adding a data disk allows you to expand storage capacity for applications, databases, or file storage. This guide walks you through the process of adding a managed data disk to an Azure VM using the Azure Portal.

To add a data disk to a VM in Microsoft Azure using the Azure Portal, follow these steps:

Step 1: Navigate to the Virtual Machine

  • Log in to the Azure Portal.
  • Select the VM to which you want to add a data disk.

For this example, I created and selected a VM called "DataDiskVM1".

VM

Step 2: Add a Data Disk

  • In the VM's menu, under the "Settings" section, click on "Disks".

Setting + Disk

  • In the "Data disks" section, click on "+ Create and attach a new disk".

Cre8 Disk

Step 3: Configure the Data Disk

  • A new row appears with an empty disk.
  • In the "Create a managed disk" blade:
    • Enter a name for the disk (I used DataDisk1 for this example).
    • Select the Storage type (Standard HDD, Standard SSD, or Premium SSD) - I used the Premium SSD.
    • Choose a Disk Size (e.g., 11 GiB or more).
    • Click Apply.

disk

We have successfully created and added a new data disk to the VM. The next step is to initialize and format the disk in the VM.

Step 4: Initialize and Format the Disk in the VM

  • Connect to the VM using Remote Desktop (Windows VM) or SSH (Linux VM).
    • If you use an iOS PC, download the "Windows App", formerly Windows Remote Desktop from the App Store. Windows users can easily connect to a VM with a Windows image OS.
  • Search and open Disk Management (Windows) or use lsblk and mkfs commands (Linux) to initialize, partition, and format the disk.

disk M

  • Select Ok to initialize the Data Disk.

init

  • After initializing the disk, it should appear as an unallocated disk as shown below. At this stage, we need to format the disk to have a healthy disk we can use in the VM.

Unallocated disk

Take the following steps to format the disk:

  • Right-click on the disk and select "New Simple Volume"

select

  • Select the "format this volume with the following settings", leaving all default settings. However, you can either leave the default name of the disk or rename it. I renamed mine to "DataDisk (Main)"

    • Select "Next" to continue.

Rename Disk

  • At this stage, you're expected to "review + finish" the formatting process of the newly added disk to the VM

final review.

  • Now we have our healthy disk, DataDisk (Main), ready for use.

cre8d Disk

  • To view the disk in the VM, right-click on the DataDisk(Main) to open it.

Open Disk

  • There you go, this is what the newly created Disk looks like in the VM.

done

Conclusion
We have successfully added a data disk to the Azure VM. This additional storage can now be used for application data, logs, or any other purpose.

Top comments (0)