Mount an Azure File Share on a Linux VM

Use Case: This article provides an example of how to mount and unmount an Azure Storage account File Share on a Linux VM.

Mount an Azure Storage File Share on a Linux VM

Step 1: Install Required Packages

First, ensure that your Linux VM has the necessary packages installed to support CIFS (Common Internet File System).

sudo apt-get update

sudo apt-get install cifs-utils -y

For Red Hat-based distributions, use:

sudo yum install cifs-utils -y

Step 2: Create a Directory for Mounting

Create a directory where you want to mount the Azure File Share.

sudo mkdir /mnt/azurefileshare

You can replace /mnt/azurefileshare with any directory of your choice.

Step 3: Mount the Azure File Share

Use the mount command to mount the Azure File Share to the directory created.

sudo mount -t cifs //<storage-account-name>.file.core.windows.net/<file-share-name> /mnt/azurefileshare -o vers=3.0,username=<storage-account-name>,password=<storage-account-key>,dir_mode=0777,file_mode=0777,serverino
  • Replace <storage-account-name> with your Azure Storage account name.
  • Replace <file-share-name> with the name of your Azure File Share.
  • Replace <storage-account-key> with your storage account key.
Step 4: Verify the Mount

Check if the Azure File Share is successfully mounted.

df -h | grep /mnt/azurefileshare

This command should show the mounted file share.

Step 5: Automount on Reboot 

If you want the Azure File Share to be mounted automatically on system reboot, add the following line to your /etc/fstab file:

Edit the /etc/fstab file using a text editor like nano or vi:

sudo nano /etc/fstab 

sudo vi /etc/fstab 

Add the below line to the end of the file, save, and exit.

//<storage-account-name>.file.core.windows.net/<file-share-name> /mnt/azurefileshare cifs vers=3.0,username=<storage-account-name>,password=<storage-account-key>,dir_mode=0777,file_mode=0777,serverino 0 0

Unmounting the File Share on a Linux VM

If you need to unmount the Azure File Share:

sudo umount /mnt/azurefileshare