DEV Community

Cover image for Adding Data Disk to a Virtual Machine
Yemisi Oyesainu
Yemisi Oyesainu

Posted on

Adding Data Disk to a Virtual Machine

Creating and deploying Virtual Machines is an essential part of Cloud Computing and as such, it has become one of the major Cloud Administrators' role. However, when Virtual machines are created newly, they only have Operating System Disk. To be able to store application data and any other data or information on the Virtual machine, data disk needs to be added.

Data disks attached to Virtual machines are managed disk. This is because they are created and managed by Cloud Service Providers(CSP). Managed Disks have several benefits compared to unmanaged disks.

First, the management of the disk is simple because you don't have to bother yourself about managing storage accounts, blob containers, or dealing with manual scaling and configuration. The CSP takes care of all these.

Second, reliability is enhanced. Managed disks provide built-in redundancy and high availability. Data are replicated within the same region, ensuring that your data remains intact even if an individual disk or underlying hardware fails. These type of disk provide a reliable and convenient solution for data recovery, ensuring that your data remains protected and recoverable in case of any unforeseen occurrence.

Thirdly, managed disks offer improved performance and low latency by leveraging on the cloud service provider's infrastructure and storage optimization techniques. There is also different disk types with varying performance characteristics, such as Standard HDD, Standard SSD, and Premium SSD, based on your workload requirements, that you can choose from.

Finally, managed disk makes scalability and platform integration easy.

Now we will set out to create a Windows Virtual machine, connect to it, install a web server on it, add a data disk and initialise it for use.
Come on and let's do these together.

Step 1
I will start by logging in to Azure Portal and select Virtual Machine

Image description

Image description

Step 2
Click on 'Create'

Image description

Complete the Project details and Instance details
I will choose to complete them as follows:

Subscription : Azure Pass Sponsorship
Resource Group: UniRg
Virtual Machine Name: Abiksvm
Region: East US
Availability option: Availability zone
Image: Windows Server 2019 Datacenter - x64 Gen 2
Leave other parameters at default

Image description

Image description

Step 3
Complete the details for Administrator account
I will choose my Username as Azureuser and password is Password123*(Note that you can choose any username and password you desire)

Under Select Inbound ports, click on 'HTTP (80)' and 'RDP (3389)'

Image description

Image description

Go to Monitoring and disable Diagnostics

Image description

Click on Review and Create

Image description

Then Click on Create and wait for the deployment to complete

Image description

Image description

Click on 'Go to Resource'

Image description

Step 4
Connect to the Virtual machine
Click on Connect

Image description

Click on 'Download RDP File'

Image description

Open the RDP File downloaded, it will bring up a dialog box for Remote Desktop Connection

Image description

Click Connect

Image description

Enter the Username and Password created under the Administrator Account in Step (3) above to log in to the Virtual machine Abiksvm and click OK

Image description

Image description

Click Yes

Image description

We have connected to the Virtual Machine

Step 5
Install a Web Server role on the Virtual Machine
Type PowerShell into the Search window of the Virtual Machine

Image description

Right click on the Windows PowerShell and then click on Run as Administrator

Image description

When the Terminal is ready, type in this command:
Install-WindowsFeature Web-Server

Image description

Then press Enter on your keyboard and wait for the Installation to complete

Image description

Image description

The Web Server role has been installed. Lets check this out.

Go back to the Overview page of the Virtual machine Abiksvm on the Azure portal and copy the IP Address of the VM

Image description

Paste the IP Address in your browser and press Enter on your keyboard

Image description

Image description

That's it! A Windows Server has been installed.

Step 6
Add Data Disk to Virtual Machine Abiksvm
On the VM, Click on 'Disks' and then, click on 'Create and attach a new disk'

Image description

Give the disk a name. I will name it datadisk and change the size to 10GB

Image description

Click on 'Save'

Image description

Image description

The Data disk has been created

Step 7
Initialise the Data disk
Go back to the VM we connected to earlier and type 'disk management' in the search window

Image description

Click on 'Create and format hard disk partitions'

Image description

Image description

Click OK

Image description

Scroll down to Disk 2 and Right click on 'New Simple Volume'

Image description

Image description

Click Next

Image description

Click Next

Image description

Click Next

Image description

Give the Volume label a name and click next. I will give it the same name I used on Azure Portal, datadisk

Image description

Image description

Click on Finish

Image description

The Data disk has been successfully initialised and ready for use.

Trust you find this useful. Please let's have your comments.

Top comments (0)