DEV Community

Cover image for How to Add a Data Disk to a VM
Samuel Ojo
Samuel Ojo

Posted on

How to Add a Data Disk to a VM

Introduction
When working with Azure Virtual Machines (VMs), you may need additional storage for application data, logs, or backups. Instead of resizing the OS disk, the best practice is to attach a data disk. This guide walks you through adding a data disk to an Azure VM using the Azure Portal and configuring it at the operating system level.

Key Terms & Definitions
Azure Virtual Machine (VM):
A scalable computing resource in Microsoft Azure that runs Windows or Linux operating systems, allowing you to deploy applications and workloads in the cloud.

Data Disk:
An additional disk attached to a VM for storing application data, logs, or backups. Unlike the OS disk, data disks are used for flexible storage expansion.

Managed Disk:
An Azure-managed storage resource that simplifies disk management by handling storage accounts and replication automatically.

Encryption:
A security feature that protects data on disks by converting it into a secure format that can only be accessed with proper keys.

Azure Portal:
A web-based interface for managing Azure resources, including VMs, disks, networking, and security settings.

Prerequisites
Before you begin:

  • You have an existing Azure VM (Linux or Windows).
  • You have Contributor or higher permissions in your Azure subscription.
  • Basic familiarity with Azure Portal navigation.

Create virtual machine
1.Navigate to https://portal.azure.com.- Sign in with your Azure account credentials.
Enter virtual machines in the search box.

2.Under Services, select Virtual machines.

3.In the Basics tab, under Project details, make sure the correct subscription is selected and then choose or Create new resource group. Mine is winserver10rg.

Create new resource group

4.Under Instance details, enter winserver10Vm for the Virtual machine name, and choose choose Windows 10 Enterprise, version 22H2 - x64 Gen2 for the Image. The default size and pricing is only shown as an example. Size availability and pricing are dependent on your region and subscription.

Windows 10 Enterprise

5.Under Administrator account, select password.
6.In Username enter azureuser.
7.Enter password and confirm password.

Administrator account

8.Under Inbound port rules > Public inbound ports, choose Allow selected ports and then select HTTP (80) and RFDP(3389) from the drop-down.

Inbound port rules > Public inbound ports<br>

9.Navigate to Monitoring tab > Diagnostics > select Disable.

Monitoring Diagnostics snd select Disable

Navigate to Tags tab. Create Tag (Name **and **value). Then select the Review + create button at the bottom of the page

Create Tag

10.On the Create a virtual machine page, you can see the details about the VM you are about to create. When you are ready, select Create.

Create a virtual machine

11.When the deployment is finished, select Go to resource

Go to resource

12.On the page for your new VM, select the public IP address and copy it to your clipboard.

Public IP

13.Increase the Idle timeout (minutes) to 30.

Idle timeout

Step 2: Create data disk

  • Click on the virtual machine created to go to its overview page
  • On the overview go to settings
  • Click settings, then select disks
  • On Data disks page, click on + create and attach new disk
  • On the LUN: That is to assign a new identifier to the newly created disk.
  • choose disk name, storage type, and size, then click on apply

disk name

Create disk

Step 3: Initialize and Format the Data Disk

  • Connect to virtual machine
  • Click on connect virtual machine

connect virtual machine

  • Click on download RDP file
  • Connect to the VM: Use Remote Desktop (RDP) to connect to your Windows VM.

download RDP file

Login with username & password

Connect to VM

Connect to VM

  • On the virtual machine search bar, search Disk Management Click on create and format hard disk partitions.
  • Click on OK to initialize the new disk

initialize the new disk

  • Scroll down to new disk created (disk 1). (notice that the disk is showing unallocated)

Second disk created

  • Right-click on the unallocated space of the new disk. Select New Simple Volume.

New Simple Volume

Follow the wizard to assign a drive letter and format the disk

  • On the welcome to the new simple volume wizard: Click Next
    welcome to the new simple volume wizard

  • On the specify volume size use the default and click on next (i.e. if you do not wish to modify the volume of the disk)

specify volume size

  • On the assign drive path click on next

assign drive path

  • On the format partition give it a name on the volume label and click on next.

Partition Name

  • Now Click on Finish to complete the process

Click finish

  • Notice that the disk new disk is now showing Healthy and no longer unallocated.

Healthy Status

Conclusion
Adding a data disk to your Azure VM is a simple yet powerful way to scale storage without impacting your OS disk. Whether you’re hosting databases, storing logs, or managing large files, this approach ensures flexibility and performance.

Thanks for reading, see you in the next one

Top comments (0)