HOW TO ADD A DATA DISK TO A VIRTUAL MACHINE
Tags: vm, dataengineering, disk, azure
Published: 2024-04-14 19:48:48

As we all know, storage plays a vital role in a virtual machine as we need to store necessary data and as we know OS disk will not be enough and we may need extra storage to store the data. So let us see how can we attach the data disk to a VM. We already know what a data disk is. If you don't know, please go through this article, where I have explained all the basics about the Azure virtual machine.

We will learn how to create and attach a data disk to a virtual machine. Furthermore, we will also remotely access the Windows virtual machine and initialize our data disk for use.
It is important to know that there is a difference between an (operating system) OS disk and a data disk
 Azure documentation explains that every virtual machine is equipped with a single (operating system) OS disk that is directly attached to it. This disk comes with a pre-installed operating system that was chosen during the creation of the virtual machine. It serves as the primary storage for the boot volume, essential for initiating the system.
While data disk is a managed disk that is attached to a virtual machine to store application data or other data you need to keep.

Let's say I have a VM named EMMAMAGDemoVM that I have already created (please refer to this [article](https://dev.to/emmamag/step-by-step-how-to-create-and-connect-a-windows-11-pro-azure-virtual-machine-1jb2) to learn about creating a virtual machine on Azure) and I want to attach an extra data disk to this VM to storage.

**Let's Get Started........**

a)The first step is to create our Windows 11 virtual machine

b)Once you've created your virtual machine click on it.

c) On the left sidebar click on "Disks".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r925ruf6zq17gyno2exs.png)

e) Once you click on it, scroll down and click on Create and attach a new disk.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yr1sp6ecm8t3pbu4k0u8.png)

f)Give your new disk a name, increase the size and leave the other information as default.

g)Click on Apply as shown below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ftbxln976ybjiddftyp6.png)

h)You can see that the (operating system) OS disk and data disk are two different disks.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4w4gqj89cm9yj5o7mvdd.png)

Connect to your virtual machine and download the RDP file once you've downloaded follow the prompt, input your username and password.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1wau3apmkktfow0za1u.png)

Now that you have been able to gain remote access to your Windows Desktop, right-click on the Windows icon and click on Disk Management.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xq8biy60242ozym5lc8w.png)

Right click on the disk 2 below.

From the drop-down click on "new simple volume".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/736t7f7ek3l1gfr6l3t2.png)

To continue click next on the new simple volume wizard.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qu81knaa4pihpt93o3r8.png)

Click "Next" on the specify volume size.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ovyl2unjce8caovmy3f8.png)

Also click "Next" on the Format Partition

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocdzlrmu1uyqcdg6vtk4.png)
To close the wizard click "finish"

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v78r1gw59ctinc65ltl6.png)

In the new volume highlighted Red, you can see that our new volume has been initialized.

Click on your new data disk highlighted Orange.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rikjhucckpe0tl0kt7sx.png)

As shown below, our new data disk is available and ready for use.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0r8ipai8ibogns07humx.png)