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.
Let's say I have a VM named demovm that I have already created (please refer to this article to learn about creating a virtual machine on azure ) and I want to attach an extra data disk to this VM to storage.
So I will go to the Azure portal and select the virtual machine and now I can see a list of my VMs. So click on VM and you will be presented with an overview screen.Click on disk and you will see this screen.
Now click on create and attach a news disk. As I said you can create a disk and attach it later so in this case, you may attach existing disk and please note that disks are always a sperate entity and you're charged based on the usage. If you have attached any disk then it will also appear here.
Now fill in the details and we are going to see what are one by one.
A LUN stands for Logical Unit Number and it is a number that is used to identify a specific storage device. This means each storage device has a unique number which is used to identify the device on Azure.
Name is the name of your disk and Type is the type of your disk I have selected the standard just because of price perspective and this is a demo so. if your virtual machine is handling a heavy load and needs faster IO then I recommend you to go for the premium disk.
It is input-output operations per second or this is the capability of a disk to operform input and output operations per second. Now click on save and give it a few seconds and it will be attached. Once the disk is attached you will also see a notification saying that the virtual machine is updated.
Now go to overview and click on connect and download the RDP file. Open your RDP file and enter credentials. If you're on Windows you may use remote desktop or if you're on Linux and using Ubuntu then you can use remina. Now enter your credentials and then you will be connected to your windows server VM.
Once you're logged in go to server dashboard or you will see it when you're logged in and then click on file and storage service. This will take you to disks and storage screen where you can see all the disk and storage devices attached to the VM.
Once you're there, click on Disk.
You will see another disk attached and then right-click and click on initialize. After that right-click again and click on New Volume then follow the wizard, fill in the details and click on next.
Once you're done go to file explorer and you will see the newly attached disk ready to use.
Actually there is another way of creating and attaching the disk to a virtual machine. You can create a disk and attach it yourself when you're creating the virtual machine. Go to the disk tab when you're creating the virtual machine and click on create and attach a new disk.
Then enter the name and the size and leave everything as it is. If you want to change the size then click on change size and choose your size.
Now when the deployment of the machine is finished it will be attached to the machine.
If you want to learn more on disk then please do follow this link.
In this article, we learned how to create and attach the disk to an existing machine. Thank you for reading.