DEV Community

Cover image for HOW TO CREATE AND ATTACH A DATA DISK TO AN EXISTING WINDOWS VIRTUAL MACHINE
Ayo Hassan
Ayo Hassan

Posted on

HOW TO CREATE AND ATTACH A DATA DISK TO AN EXISTING WINDOWS VIRTUAL MACHINE

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

The file explorer page will appear, you will then click on “This PC” as shown below to confirm the existing disks

Image description

The existing disks on the Windows 11 pro VM created are as shown below:

Image description

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

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

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

Under the Settings section, select Disks.

Image description

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

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

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

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

Now we can see disk 2

Image description

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

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

Image description

Image description

Image description

Image description

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

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

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

Image description

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

Top comments (0)