Skip to content

Commit 60fdfef

Browse files
authored
Update storage-how-to-use-files-linux.md
1 parent d2367ae commit 60fdfef

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

articles/storage/files/storage-how-to-use-files-linux.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ author: khdownie
55
ms.service: azure-file-storage
66
ms.custom: linux-related-content, devx-track-azurecli
77
ms.topic: how-to
8-
ms.date: 01/10/2023
8+
ms.date: 05/13/2024
99
ms.author: kendownie
1010
---
1111

12-
# Mount SMB Azure file share on Linux
12+
# Mount SMB Azure file shares on Linux clients
1313

1414
> [!CAUTION]
1515
> This article references CentOS, a Linux distribution that is nearing End Of Life (EOL) status. Please consider your use and plan accordingly. For more information, see the [CentOS End Of Life guidance](~/articles/virtual-machines/workloads/centos/centos-end-of-life.md).
16-
[Azure Files](storage-files-introduction.md) is Microsoft's easy to use cloud file system. Azure file shares can be mounted in Linux distributions using the [SMB kernel client](https://wiki.samba.org/index.php/LinuxCIFS).
16+
17+
Azure file shares can be mounted in Linux distributions using the [SMB kernel client](https://wiki.samba.org/index.php/LinuxCIFS).
1718

1819
The recommended way to mount an Azure file share on Linux is using SMB 3.1.1. By default, Azure Files requires encryption in transit, which is supported by SMB 3.0+. Azure Files also supports SMB 2.1, which doesn't support encryption in transit, but you can't mount Azure file shares with SMB 2.1 from another Azure region or on-premises for security reasons. Unless your application specifically requires SMB 2.1, use SMB 3.1.1.
1920

@@ -31,21 +32,23 @@ If your Linux distribution isn't listed in the above table, you can check the Li
3132
uname -r
3233
```
3334

34-
> [!Note]
35+
> [!NOTE]
3536
> SMB 2.1 support was added to Linux kernel version 3.7. If you're using a version of the Linux kernel after 3.7, it should support SMB 2.1.
3637
3738
## Applies to
39+
3840
| File share type | SMB | NFS |
3941
|-|:-:|:-:|
4042
| Standard file shares (GPv2), LRS/ZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
4143
| Standard file shares (GPv2), GRS/GZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
4244
| Premium file shares (FileStorage), LRS/ZRS | ![Yes](../media/icons/yes-icon.png) | ![No](../media/icons/no-icon.png) |
4345

4446
## Prerequisites
47+
4548
<a id="smb-client-reqs"></a>
4649

4750
* <a id="install-cifs-utils"></a>**Ensure the cifs-utils package is installed.**
48-
The cifs-utils package can be installed using the package manager on the Linux distribution of your choice.
51+
Install the cifs-utils package using the package manager on the Linux distribution of your choice.
4952

5053

5154
# [Ubuntu](#tab/Ubuntu)
@@ -84,7 +87,7 @@ On other distributions, use the appropriate package manager or [compile from sou
8487

8588
* **The most recent version of the Azure Command Line Interface (CLI).** For more information on how to install the Azure CLI, see [Install the Azure CLI](/cli/azure/install-azure-cli) and select your operating system. If you prefer to use the Azure PowerShell module in PowerShell 6+, you may; however, the instructions in this article are for the Azure CLI.
8689

87-
* **Ensure port 445 is open**: SMB communicates over TCP port 445 - make sure your firewall or ISP isn't blocking TCP port 445 from the client machine. Replace `<your-resource-group>` and `<your-storage-account>` and then run the following script:
90+
* **Ensure port 445 is open**: SMB communicates over TCP port 445 - make sure your firewall or ISP isn't blocking TCP port 445 from the client machine. Replace `<your-resource-group>` and `<your-storage-account>` and then run the following script:
8891

8992
```bash
9093
RESOURCE_GROUP_NAME="<your-resource-group>"
@@ -110,6 +113,7 @@ On other distributions, use the appropriate package manager or [compile from sou
110113
If you're unable to open up port 445 on your corporate network or are blocked from doing so by an ISP, you may use a VPN connection or ExpressRoute to work around port 445. For more information, see [Networking considerations for direct Azure file share access](storage-files-networking-overview.md).
111114
112115
## Mount the Azure file share on-demand with mount
116+
113117
When you mount a file share on a Linux OS, your remote file share is represented as a folder in your local file system. You can mount file shares to anywhere on your system. The following example mounts under the `/media` path. You can change this to your preferred path you want by modifying the `$MNT_ROOT` variable.
114118
115119
Replace `<resource-group-name>`, `<storage-account-name>`, and `<file-share-name>` with the appropriate information for your environment:
@@ -128,7 +132,7 @@ sudo mkdir -p $MNT_PATH
128132
Next, mount the file share using the `mount` command. In the following example, the `$SMB_PATH` command is populated using the fully qualified domain name for the storage account's file endpoint and `$STORAGE_ACCOUNT_KEY` is populated with the storage account key.
129133

130134
# [SMB 3.1.1](#tab/smb311)
131-
> [!Note]
135+
> [!NOTE]
132136
> Starting in Linux kernel version 5.0, SMB 3.1.1 is the default negotiated protocol. If you're using a version of the Linux kernel older than 5.0, specify `vers=3.1.1` in the mount options list.
133137
134138
```azurecli
@@ -188,14 +192,15 @@ You can use `uid`/`gid` or `dir_mode` and `file_mode` in the mount options for t
188192
You can also mount the same Azure file share to multiple mount points if desired. When you're done using the Azure file share, use `sudo umount $mntPath` to unmount the share.
189193
190194
## Automatically mount file shares
195+
191196
When you mount a file share on a Linux OS, your remote file share is represented as a folder in your local file system. You can mount file shares to anywhere on your system. The following example mounts under the `/media` path. You can change this to your preferred path you want by modifying the `$MNT_ROOT` variable.
192197
193198
```bash
194199
MNT_ROOT="/media"
195200
sudo mkdir -p $MNT_ROOT
196201
```
197202
198-
To mount an Azure file share on Linux, use the storage account name as the username of the file share, and the storage account key as the password. Because the storage account credentials may change over time, you should store the credentials for the storage account separately from the mount configuration.
203+
To mount an Azure file share on Linux, use the storage account name as the username of the file share, and the storage account key as the password. Because the storage account credentials might change over time, you should store the credentials for the storage account separately from the mount configuration.
199204
200205
The following example shows how to create a file to store the credentials. Remember to replace `<resource-group-name>` and `<storage-account-name>` with the appropriate information for your environment.
201206
@@ -232,6 +237,7 @@ sudo chmod 600 $SMB_CREDENTIAL_FILE
232237
To automatically mount a file share, you have a choice between using a static mount via the `/etc/fstab` utility or using a dynamic mount via the `autofs` utility.
233238
234239
### Static mount with /etc/fstab
240+
235241
Using the earlier environment, create a folder for your storage account/file share under your mount folder. Replace `<file-share-name>` with the appropriate name of your Azure file share.
236242
237243
```bash
@@ -241,9 +247,9 @@ MNT_PATH="$MNT_ROOT/$STORAGE_ACCOUNT_NAME/$FILE_SHARE_NAME"
241247
sudo mkdir -p $MNT_PATH
242248
```
243249
244-
Finally, create a record in the `/etc/fstab` file for your Azure file share. In the command below, the default 0755 Linux file and folder permissions are used, which means read, write, and execute for the owner (based on the file/directory Linux owner), read and execute for users in owner group, and read and execute for others on the system. You may wish to set alternate `uid` and `gid` or `dir_mode` and `file_mode` permissions on mount as desired. For more information on how to set permissions, see [UNIX numeric notation](https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation) on Wikipedia.
250+
Finally, create a record in the `/etc/fstab` file for your Azure file share. In the command below, the default 0755 Linux file and folder permissions are used, which means read, write, and execute for the owner (based on the file/directory Linux owner), read and execute for users in owner group, and read and execute for others on the system. You might wish to set alternate `uid` and `gid` or `dir_mode` and `file_mode` permissions on mount as desired. For more information on how to set permissions, see [UNIX numeric notation](https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation).
245251
246-
> [!Tip]
252+
> [!TIP]
247253
> If you want Docker containers running .NET Core applications to be able to write to the Azure file share, include **nobrl** in the SMB mount options to avoid sending byte range lock requests to the server.
248254
249255
```bash
@@ -262,10 +268,11 @@ fi
262268
sudo mount -a
263269
```
264270
265-
> [!Note]
271+
> [!NOTE]
266272
> Starting in Linux kernel version 5.0, SMB 3.1.1 is the default negotiated protocol. You can specify alternate protocol versions using the `vers` mount option (protocol versions are `3.1.1`, `3.0`, and `2.1`).
267273
268274
### Dynamically mount with autofs
275+
269276
To dynamically mount a file share with the `autofs` utility, install it using the package manager on the Linux distribution of your choice.
270277
271278
# [Ubuntu](#tab/Ubuntu)
@@ -345,6 +352,7 @@ After you've created the file share snapshot, follow these instructions to mount
345352
If the mount fails, see [Troubleshoot Azure Files connectivity and access issues (SMB)](/troubleshoot/azure/azure-storage/files-troubleshoot-smb-connectivity?toc=/azure/storage/files/toc.json).
346353
347354
## Next steps
355+
348356
See these links for more information about Azure Files:
349357
350358
- [Planning for an Azure Files deployment](storage-files-planning.md)

0 commit comments

Comments
 (0)