You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/storage/files/storage-how-to-use-files-linux.md
+70-70Lines changed: 70 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,18 +84,18 @@ On other distributions, use the appropriate package manager or [compile from sou
84
84
***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:
85
85
86
86
```bash
87
-
resourceGroupName="<your-resource-group>"
88
-
storageAccountName="<your-storage-account>"
87
+
RESOURCE_GROUP_NAME="<your-resource-group>"
88
+
STORAGE_ACCOUNT_NAME="<your-storage-account>"
89
89
90
90
# This command assumes you have logged in with az login
If the connection was successful, you should see something similar to the following output:
@@ -107,75 +107,75 @@ On other distributions, use the appropriate package manager or [compile from sou
107
107
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).
108
108
109
109
## Mount the Azure file share on-demand with mount
110
-
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 `/mount` path. You can change this to your preferred path you want by modifying the `$mntRoot` variable.
110
+
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 `/mount` path. You can change this to your preferred path you want by modifying the `$MNT_ROOT` variable.
111
111
112
112
Replace `<resource-group-name>`, `<storage-account-name>`, and `<file-share-name>` with the appropriate information for your environment:
Next, mount the file share using the `mount` command. In the following example, the `$smbPath` command is populated using the fully qualified domain name for the storage account's file endpoint and `$storageAccountKey` is populated with the storage account key.
125
+
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.
126
126
127
127
# [SMB 3.1.1](#tab/smb311)
128
128
> [!Note]
129
129
> 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.
130
130
131
131
```azurecli
132
132
# This command assumes you have logged in with az login
storageAccountKey=$(az storage account keys list \
174
-
--resource-group $resourceGroupName \
175
-
--account-name $storageAccountName \
173
+
STORAGE_ACCOUNT_KEY=$(az storage account keys list \
174
+
--resource-group $RESOURCE_GROUP_NAME \
175
+
--account-name $STORAGE_ACCOUNT_NAME \
176
176
--query "[0].value" --output tsv | tr -d '"')
177
177
178
-
sudo mount -t cifs $smbPath$mntPath -o vers=2.1,username=$storageAccountName,password=$storageAccountKey,serverino,nosharesock,actimeo=30,mfsymlinks
178
+
sudo mount -t cifs $SMB_PATH$MNT_PATH -o vers=2.1,username=$STORAGE_ACCOUNT_NAME,password=$STORAGE_ACCOUNT_KEY,serverino,nosharesock,actimeo=30,mfsymlinks
179
179
```
180
180
181
181
---
@@ -185,45 +185,45 @@ You can use `uid`/`gid` or `dir_mode` and `file_mode` in the mount options for t
185
185
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.
186
186
187
187
## Automatically mount file shares
188
-
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 `/mount` path. You can change this to your preferred path you want by modifying the `$mntRoot` variable.
188
+
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 `/mount` path. You can change this to your preferred path you want by modifying the `$MNT_ROOT` variable.
189
189
190
190
```bash
191
-
mntRoot="/mount"
192
-
sudo mkdir -p $mntRoot
191
+
MNT_ROOT="/mount"
192
+
sudo mkdir -p $MNT_ROOT
193
193
```
194
194
195
195
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.
196
196
197
197
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.
198
198
199
199
```bash
200
-
resourceGroupName="<resource-group-name>"
201
-
storageAccountName="<storage-account-name>"
200
+
RESOURCE_GROUP_NAME="<resource-group-name>"
201
+
STORAGE_ACCOUNT_NAME="<storage-account-name>"
202
202
203
203
# Create a folder to store the credentials for this storage account and
204
204
# any other that you might set up.
205
-
credentialRoot="/etc/smbcredentials"
205
+
CREDENTIAL_ROOT="/etc/smbcredentials"
206
206
sudo mkdir -p "/etc/smbcredentials"
207
207
208
208
# Get the storage account key for the indicated storage account.
209
209
# You must be logged in with az login and your user identity must have
210
210
# permissions to list the storage account keys for this command to work.
211
-
storageAccountKey=$(az storage account keys list \
212
-
--resource-group $resourceGroupName \
213
-
--account-name $storageAccountName \
211
+
STORAGE_ACCOUNT_KEY=$(az storage account keys list \
212
+
--resource-group $RESOURCE_GROUP_NAME \
213
+
--account-name $STORAGE_ACCOUNT_NAME \
214
214
--query "[0].value" --output tsv | tr -d '"')
215
215
216
216
# Create the credential file for this individual storage account
echo "username=$STORAGE_ACCOUNT_NAME" | sudo tee $SMB_CREDENTIAL_FILE > /dev/null
220
+
echo "password=$STORAGE_ACCOUNT_KEY" | sudo tee -a $SMB_CREDENTIAL_FILE > /dev/null
221
221
else
222
-
echo "The credential file $smbCredentialFile already exists, and was not modified."
222
+
echo "The credential file $SMB_CREDENTIAL_FILE already exists, and was not modified."
223
223
fi
224
224
225
225
# Change permissions on the credential file so only root can read or modify the password file.
226
-
sudo chmod 600 $smbCredentialFile
226
+
sudo chmod 600 $SMB_CREDENTIAL_FILE
227
227
```
228
228
229
229
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.
@@ -232,10 +232,10 @@ To automatically mount a file share, you have a choice between using a static mo
232
232
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.
Finally, create a record in the `/etc/fstab` file foryour 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 usersin 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.
@@ -244,14 +244,14 @@ Finally, create a record in the `/etc/fstab` file for your Azure file share. In
244
244
> 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.
if [ -z"$(grep $smbPath\ $mntPath /etc/fstab)" ];then
254
-
echo"$smbPath$mntPath cifs nofail,credentials=$smbCredentialFile,serverino,nosharesock,actimeo=30"| sudo tee -a /etc/fstab > /dev/null
253
+
if [ -z"$(grep $SMB_PATH\ $MNT_PATH /etc/fstab)" ];then
254
+
echo"$SMB_PATH$MNT_PATH cifs nofail,credentials=$SMB_CREDENTIAL_FILE,serverino,nosharesock,actimeo=30"| sudo tee -a /etc/fstab > /dev/null
255
255
else
256
256
echo"/etc/fstab was not modified to avoid conflicting entries as this Azure file share was already present. You may want to double check /etc/fstab to ensure the configuration is as desired."
0 commit comments