Microsoft Azure has two types of virtual hard disks (VHDs): unmanaged and managed. When comparing Azure managed vs. unmanaged disks, the biggest difference is that the latter are maintained by the end user in their own storage accounts.
These unmanaged disks are bound by storage account limits, which leads to needing several storage accounts when the deployment has to scale. Managed disks are part of the Azure Managed Disks service. This disk type overcomes the storage account limit obstacle by having Microsoft manage the storage accounts for you. There are a number of other advantages that Azure managed disks have over unmanaged disks. Azure managed disks are recommended by Microsoft to be used with all new Azure deployments, though unmanaged disks are still used by customers in older deployments.
How can you mount VHD files to Azure virtual machines? This article will discuss methods you can use to attach, and mount Azure managed disks to Azure virtual machines (VMs). We will also look at how NetApp’s Cloud Volumes ONTAP (formerly ONTAP Cloud) can be used to provide additional storage solutions for once you mount VHD files to Azure virtual machines.
Quick links to get started right away:
- How to Attach Azure Managed Disks to Azure VMs
- How to Mount an Azure Disk to a Windows VM
- How to Mount Azure Disks to Linux VMs
- Using Powershell and Azure CLI to Attach Disks
- Get More from Azure Disk with NetApp Cloud Volumes ONTAP
How to Attach Azure Managed Disks to Azure VMs
Here is the step-by-step procedure for adding a VHD in Azure to a Windows VM through the Azure Resource Manager (ARM) portal and then mounting the disk to Windows.
Adding New Managed Disks
1. Open up the Azure Resource Manager portal and browse over to the “Virtual Machine” blade.
2. Go to “Settings” and click on “Disks.” On the blade that opens up, click on the “+ Create and attach a new Add data disk” option.
3. Provide details on the disk as follows:
- Name of the disk
- Disk type - choose either Standard HDD, Standard SSD or Premium SSD from the drop down
- Provide the size of the disk
- Choose the encryption type. By default the encryption is done using Platform-managed key. You can also choose customer-managed key if required
- For premium disks , you can choose to enable disk caching to boost performance
Click on save to add the disk.
Add existing disk
1. From the VM settings ->Disks, click on "Attach existing disk".
2. Select an existing disk from the drop down and click on save to attach the disk.
How to Mount an Azure Disk to a Windows VM
In this section we’ll see how to mount an Azure disk to a Windows VM.
1. When you connect to the VM through RDP, open the “Disk Management” console from Server Manager->File and Storage Services->Volumes->Disks. You can see the newly added disks in the console.
2. Right click the disk and click on "New Volume".
3. The New Volume Wizard will open up. Click on Next to start the mounting process.
4. Select the disk to be mounted and click on "Next."
5. When the message comes up for initializing the disk, click on "ok" and then "Next" to proceed.
6. Select the volume size and click on "Next."
7. Select the drive letter and click "Next."
8. Confirm details and click on "Create."
9. Once the process is completed, click on "Close" to complete the process.
Your disk will now be ready to be used.
How to Mount Azure Disks to Linux VMs
The steps for attaching additional data disks from the Azure portal are the same for both Windows and Linux machines, and is covered earlier in the blog. You can follow the steps below to mount an attached Azure disk to a Linux VM.
1. SSH to the Linux VM
2. To list the disks, use this command:
dmesg | grep SCSI
3. In this case, it is the sdc drive that was newly attached. You can view more details on that drive by using this command:
sudo smartctl -d scsi -a -i /dev/sdc
4. Now that we have identified the SCSI disk, let’s format and mount it. Use the fdisk command to partition your disk. In this example, one primary partition encompassing the whole drive has been created:
5. After the partition is created, you'll need to write the file system (in this example ext4):
6. After the file system has been written, assign a directory and mount the device to the directory.
7. Now that we have the drive set up, you can read and write files from it.
Using Powershell and Azure CLI to Attach Disks
For PCs running on Linux or Mac (or even Windows using WSL), you can use the Azure Command Line Interface (CLI) to create and manage Azure resources. Having said that, in this post we’ll show how to connect to Azure CLI through Azure Cloud Shell directly on the Azure portal. Here are some of the commands that you would run to attach disks to an Azure VM.
Managed disks: The following command would add a new 20 GB managed disk named netappman2 to the VM netappmanvm in the resource group netapptests:
az vm disk attach -g netapptests --vm-name netappmanvm - -disk netappman2 --new --size-gb 20
For more command lines, the article behind this link has a full list of Azure CLI commands.
Microsoft Powershell is another programmatic tool that can be used to attach VHDs to virtual machines. Start by logging into the Azure RM account:
The following cmdlets would get the information of the VM netappwintest and attach a managed disk named netappunman3 to it:
$vm = Get-AzVM -Name netappwintest -ResourceGroupName netapptests
$vm = Add-AzVMDataDisk -VM $vm -Name netappunman3 -CreateOption Attach -ManagedDiskId $dataDisk1.Id -Lun 1 Update-AzVM -VM $vm -ResourceGroupName netapptests
Get More from Azure Disk with NetApp Cloud Volumes ONTAP
While Azure Disks and VHDs allow for a single virtual machine to actively make use of a storage allocation, sometimes data needs to be shared between many virtual machines concurrently. This requires the use of NFS or CIFS file share services that client hosts can connect to.
NetApp’s Cloud Volumes ONTAP for Azure provides a comprehensive solution for cloud storage management, which includes the provisioning of cloud-based NAS services. Cloud Volumes ONTAP is built on top of Azure compute and Azure storage resources and can therefore be made readily available to your existing virtual machines.
Here are some of the benefits of using Cloud Volumes ONTAP:
- Multi-protocol support: Cloud Volumes ONTAP can serve out both NFS and CIFS shares, as well as block-level storage allocations over iSCSI. This allows you to centrally manage all of the storage use across your enterprise
- Space efficiencies: Many of the core features in Cloud Volumes ONTAP help to reduce your cloud storage footprint and related costs. These cost-cutting storage efficiencies on Azure include data compression, data compaction, and data deduplication, to name a few. Thin provisioning can be used to “grow-as-you-go” by only allocating storage when it is actually needed
- Snapshots and cloning: Cloud Volumes ONTAP can create instant, space-efficient, point-in-time copies of any storage volume. These snapshots can then be used as a basis for a copy-on-write clone of the data, which can be used, for example, for development or testing
- Enterprise-grade data replication: Using SnapMirror for data replication, Cloud Volumes ONTAP can incrementally synchronize data between any NetApp systems, whether on-premises or in the cloud. This can be a huge win when you need to migrate data from existing in-house systems to Azure, or when creating a DR (disaster recovery) environment
- Easy to use/integrate: OnCommand Cloud Manager provides a modern, web-based user interface for deploying and managing all of your Cloud Volumes ONTAP instances. In addition to this, DevOps users and administrators can make use of the fully-featured RESTful API for integrating Cloud Volumes ONTAP with their data workflows
That’s our rundown for how to mount Azure disks to Azure VMs. Although managed disks have a number of features and functionalities that unmanaged disks just don’t offer, make sure you understand that there are a few gotchas involved with using managed disks. For instance, the pricing for standard managed disks is based on provisioned size: that means you’re paying for disk space you may not wind up using. Using Cloud Volumes ONTAP with Azure, you can wind up saving on the amount you spend on Azure storage. To see for yourself, take a look at our Azure calculator to see what Cloud Volumes ONTAP can do to lower your TCO.
One last note: if you are using standard disks, don’t forget to turn on TRIM on the Windows and Linux VMs after you attach VHD disks. Trim discards unused blocks on the disk and helps save on costs if you create large files and then delete them. You can do this in Windows by running the fsutil command and in Linux by using the fstrim command.