HOW TO CREATE AND ATTACH A DATA DISK TO AN EXISTING WINDOWS VIRTUAL MACHINE
Published: 2024-04-29 12:06:57

**CREATE AND ATTACH A DATA DISK TO AN EXISTING WINDOWS VIRTUAL MACHINE**
In this project, we are going to create and attach a new data disk to an existing  Windows 11 Pro Virtual Machine (VM). Below is a screenshot of Windows 11 Pro VM already created. See how a Windows 11 Pro VM is created. For the purpose of learning, we will first check the existing disks in my Windows 11 Pro VM. To do this, you will click on “File Explorer” as indicated below.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kcn9zetjpwo46chuxywo.png)

The file explorer page will appear, you will then click on “This PC” as shown below to confirm the existing disks
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qt297dmvdkc2y2zs9jhh.png)

The existing disks on the Windows 11 pro VM created are as shown below: 	
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xcao69fhb7g7bw25zkfa.png)

**Disk Roles in Azure**:
Before proceeding to create a new data disk, let me explain disk roles. According to Microsoft Azure, there are three main disk roles in Azure. These are, the OS disk, the data disk, and the temporary disk. These roles map to disks that are attached to your virtual machine.
  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1a00qt1kwdq0wnus0lmx.png)

**OS disk**
Every virtual machine has one attached operating system disk. That OS disk has a pre-installed OS, which was selected when the VM was created. This disk contains the boot volume. Generally, you should only store your OS information on the OS disk, and store all applications, and data on data disks. However, if cost is a concern, you can use the OS disk instead of creating a data disk. It is important to note that OS disk is persistent.

**Data disk**
A data disk is a managed disk that is attached to a virtual machine to store application data, or other data you need to keep. Data disks are registered as (Small Computer System Interface (SCSI) drives and are labeled with a letter that you choose. The size of the virtual machine determines how many data disks you can attach to it and the type of storage you can use to host the disks. Generally, you should use the data disk to store your applications and data, instead of storing them on OS disks. Data disk is also persistent.

**Temporary disk**
Most VMs contain a temporary disk, which is not a managed disk. The temporary disk provides short-term storage for applications and processes, and is intended to only store data such as page files, swap files, or SQL Server tempdb. Data on the temporary disk may be lost during a maintenance event, when you redeploy a VM, or when you stop the VM. During a successful standard reboot of the VM, data on the temporary disk will persist. For more information about VMs without temporary disks, see Azure VM sizes with no local temporary disk. To read more on disk roles, see https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview 



**1.⁠ ⁠Create a new Data Disk**:  To create a new data disk, you will go to the Azure portal (Assuming you already have an account and a subscription, if not you have to create one) and navigate to the virtual machine you want to attach the data disk to. If you are a new user, you have to first create a Windows 11 Pro VM. If you have already created the VM, you can search for the VM name on the search bar, or see it under the Resources you have already created in your Azure. The name I assigned to the VM for the Windows 11 Pro earlier created is “AyWin11VM-1”. Therefore, you will click on your VM as indicated below

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

The Overview page of the Windows 11 Pro VM will displayed as shown below. Then you will click on setting to navigate to the Disk
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4sio729qohrt819oe4j3.png)

Under the Settings section, select Disks. 
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8g0ur4io0llqygosciyw.png)

The disks page will show the OS disk and options to create and attach a new data disk or attach existing data disks. Since we are creating a new data disk to be attached, you will click on “Create and attach a new disk”. 

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

You will then have to configure the disk settings such as giving your disk a name, storage type, and Size (in GB) as indicated below and then click on “Apply” . Then you have successfully created a new data disk.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ytjenseuxqffcvr0eqp4.png)

**2.⁠ ⁠Attach the Data Disk to the Virtual Machine**:
After successfully created a new data disk for your VM on Microsoft Azure, you will need to go back to the Windows 11 pro VM created on your PC to initialize the data disk for use. You will then have to click on the disk management on the status bar for mac users, or right click on the desktop and click on disk management for Windows users. Then click “OK” to Initialise Disk
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njxbe51t92hccqgwh5nd.png)

Then, the disks information will appear as shown below. However, you will only see Disk 0 and Disk 1. Therefore, you will need to scroll down to see Disk 2 and any other Disk available
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8n1la7sdz8mmgzchr5ud.png)

Now we can see disk 2
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chobkmrxkkli8lwrkj4w.png)

You will then right click inside the Disk 2 box and click on “New Simple Volume” to allocate the disk and partition it for use.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwf3quzrvuzy1i1yj25g.png)

**3. Initialize and Format Disk**:
This will take you to the New Simple Volume Wizard which will help you to create a simple volume on your disk. To continue, click “Next”, continue to click “Next” then click “Finish”
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvvjxbtb1co8fvmqhdwc.png)

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

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

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

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

After successfully allocated and partitioning the data disk for use, you will see that the “New Volume disk” has been added to the Disk Management as shown below. 
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6wn44yg7e7sboyobbe6i.png)

To confirm that the new data disk has been created, initialize and attached for use in the VM, you will need to close the disk management, then click on File Explorer, and click on “This PC”
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qr7u4ex5t3v1x94hrlut.png)

Then, you will see that the new data disk you created has been added to the Windows 11 Pro VM as shown below
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36m1o0rf8ikaadloepcu.png)

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

You have now successfully created and attached a new data disk to an existing windows 11 virtual machine