How to mount file and block storage to Windows

Case #

This article provides guidance on how to mount file and block storage to Windows. There are various cases and scenarios in which you have a file-based, block-based or object-based storage system and you create file shares or block storage LUNs in it, which you then need to mount to a Windows machine. There various file-based storage protocols available, such as NFS and CIFS/SMB. There are also various block-based storage protocols available such as iSCSI, FCoE and FC. In the case of public clouds (for example Microsoft Azure Storage) and in the world of containers, most storage systems utilize object-based storage. Examples of container object-based storage include Ceph and GlusterFS as well as Azure blob storage and Amazon S3 storage. A good comparison of object storage vs block storage can be found at: https://phoenixnap.com/blog/object-storage-vs-block-storage.

The article provides high level guidance and command line templates on how to mount file and block storage to Windows, in the form of mapped network drives or network disks.

Solution #

File storage #

CIFS/SMB #

For CIFS/SMB, Windows have native client support, so all you need to do to mount an SMB/CIFS share is run the following command in elevated command prompt or Powershell, to create a mapped network drive.

#Create mapped network drive
#Provide credentials if needed or omit the /user: parameter and password for anonymous access
net use M: \\hostname\sharename /PERSISTENT:YES /user:domain\username thisisthepass

#Remove mapped network drive
net use  M: /delete

Always ensure that the latest version of the SMB/CIFS protocol is configured on both the server and client machines.

NFS #

For NFS, you need to install the NFS client on the Windows machine first. Go to Windows Programs and Features and click on “Turn Windows features on or off”. Check the “Client for NFS” checkbox and click OK.

How to mount file and block storage to Windows

Or in the case of a Windows Server machine, install the “client for NFS” feature.

After the NFS client is enabled, you should be ready to proceed with following steps.

# Create a mapped network drive as NFS share
mount -o anon \\[server IP address]\mnt\[mount path name] Z:

#The above command will only grant the anonymous user with read access to the NFS share

You show now be able to manage the NFS share by using the command line.

The mount command will also provide details about the NFS mount.

If you need to assign write access to your anonymous user, you need to change the AnonymousGid and AnonymousUid entries with proper values from the NFS server and reboot your Windows NFS client.

Azure Files #

Make use of the following Powershell script to mount an Azure File share to your Windows machine.

$connectTestResult = Test-NetConnection -ComputerName [storageaccountname].file.core.windows.net -Port 445
if ($connectTestResult.TcpTestSucceeded) {
    # Save the password so the drive will persist on reboot
    cmd.exe /C "cmdkey /add:`"[storageaccountname].file.core.windows.net`" /user:`"localhost\[storageaccountname]`" /pass:`"[storageaccountkeyhere]`""
    # Mount the drive
    New-PSDrive -Name Z -PSProvider FileSystem -Root "\\[storageaccountname].file.core.windows.net\test" -Persist
} else {
    Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
}

#Now you may need to run below command again
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\[storageaccountname].file.core.windows.net\test" -Persist

The permissions levels are granted from the configuration of the Azure Storage Account key. If you need to use Azure AD DS or AD DS for customizing permissions to the Azure Files share, further configuration is required on the Azure side. In that case, a different script should be used for mounting the Azure Files share.

Block storage #

iSCSI and FCoE #

For iSCSI targets, you need to setup the Windows iSCSI initiator. The the target storage volume (LUN) should be shown on the Windows machine as a local physical hard disk.

To setup your iSCSI target with the Windows iSCSI initiator, follow the steps below.

  • Launch the iSCSI initiator at Control Panel > Tools.
  • On the iSCSI Initiator Properties page, click Targets.
  • Enter the IP address of the target iSCSI storage system and then click Quick Connect.