If you want Linux cloud computers that reside in the same office network to share files with each other, you must mount a File Storage NAS file system to the office network. Then, you can use the NAS file system as a normal directory for access and use. This topic describes how to mount a NAS file system that uses the Server Message Block (SMB) protocol on a Linux cloud computer.
Background information
Elastic Desktop Service (EDS) supports NAS file systems. You can mount NAS file systems on cloud computers to share files, store logs, and back up data among the cloud computers.
By default, when you create a NAS file system in the EDS console, a General-purpose NAS file system is created, and the SMB protocol is used. For more information about General-purpose NAS file systems, see General-purpose NAS file systes.
Billing
You are charged when you use a General-purpose NAS file system. The billable items of a NAS file system include the storage specifications, storage size (the peak size per hour), and storage duration. For more information about the billing, see Billing of General-purpose NAS file systems.
Procedure
When you manually mount a NAS file system on a Linux cloud computer, you can mount the file system as a convenience user or an enterprise Active Directory (AD) user. The following section uses Linux Ubuntu as an example to describe how to mount a NAS file system. The actual commands that you run vary based on the OS that your cloud computer uses. For more information about the commands for different Linux distributions, see Mount an SMB file system on a Linux ECS instance.
Mount a NAS file system as a convenience user
If a Linux cloud computer resides in a convenience office network whose NAS file system does not have SMB Access Control List (ACL) feature enabled, you can mount the NAS file system as a convenience user to the office network.
Note When you mount a NAS file system on a Linux cloud computer as a convenience user, the file system is anonymously mounted.
Create a NAS file system. For more information, see the "Step 1: Create a NAS file system" section of the Mount a NAS file system on a Windows cloud computer topic.
Obtain the domain name of a mount target.
On the NAS File Systems page in the EDS console, find the NAS file system that you want to mount and record the domain name of a mount target of the file system in the Mount Target Domain column.
Mount the NAS file system on a Linux cloud computer.
Connect to the cloud computer and open Terminal on the cloud computer.
Run the following commands in sequence to install the Common Internet File System (CIFS) client by using the apt-get tool.
sudo apt update
sudo apt-get install cifs-utils
Run the id
command to view the values of uid and gid.
Run the following command to mount the NAS file system to the specified directory on the cloud computer:
sudo mount -t cifs //<Domain name of the mount target>/myshare <Mount directory> -o <Mount options>
In the following sample command, 0bb254adc3-x****.cn-hangzhou.nas.aliyuncs.com
is used as a sample domain name, /mnt
is used as a sample directory, and the uid and gid values returned in the previous step are used. Replace the preceding values with actual values based on your business scenario.
sudo mount -t cifs //0bb254adc3-x****.cn-hangzhou.nas.aliyuncs.com/myshare /mnt -o vers=2.1,guest,uid=1677****,gid=1677****,dir_mode=0755,file_mode=0755,mfsymlinks,cache=strict,rsize=1048576,wsize=1048576
Major fields in the command
Field | Description |
Domain name of the mount target | When you create a NAS file system, the system generates the domain name of the mount target in which the file system is located. The actual domain name shall prevail. |
myshare | The name of the directory of the NAS file system that uses the SMB protocol to share files cannot be changed. |
Mount directory | The directory to which you want to mount the NAS file system. Example:/mnt. |
Mount options | Specifies the required mount options by adding the -o parameter in the mount command: vers: specifies the version of the SMB protocol. Only SMB 2.0 or later is supported. guest: specifies the identity that you want to use to mount the NAS file system. You must use the guest identity that is authenticated based on the New Technology LAN Manager (NTLM) protocol. rsize: specifies the maximum size of a data packet that can be read. In most cases, this option is set to 1048576 bytes, which is equal to 1 MB. wsize: specifies the maximum size of a data packet that can be written. In most cases, this option is set to 1048576 bytes, which is equal to 1 MB.
Specifies the following mount options by adding the -o parameter: uid: specifies the user to which the files in the file system belong after the file system is mounted. If you do not specify a value, 0 is used. gid: specifies the user group to which the files in the file system belong after a successful mount. If you do not specify a value, 0 is used. dir_mode: specifies the read, write, and execute permissions that you want to grant to users on the specified directories. The value must start with 0. Examples: 0755, 0644. If you do not specify a value, 0755 is used. file_mode: specifies the read, write, and execute permissions that you want to grant to users on files. The value must start with 0. Examples: 0755, 0644. If you do not specify a value, 0755 is used. mfsymlinks: specifies whether symbol links are supported. cache: If you set this option to strict, caching is enabled for the SMB client. Default value: strict. If you set this option to none, caching is disabled for the SMB client.
atime|relatime: If the file access time does not affect your business, we recommend that you do not use the atime option. By default, the relatime option is used.
Note An authorized administrator of the Linux Elastic Compute Service (ECS) instance has full control over the SMB file system. If you want to view the details of a mount target, run the mount | grep cifs command. We recommend that you use a Linux distribution whose kernel version is later than 3.10.0-514. If you use a Linux distribution whose kernel version is 3.7 or earlier, set the cache option to strict. You can run the uname -a command to view the kernel version.
|
Run the mount -l
command to view the mount result.
If a command output similar to the following example appears, the file system is mounted.
(Optional) After the file system is mounted, you can run the df -h
command to view the storage capacity of the file system.
Mount a NAS file system as an AD user
If your Linux cloud computers reside in an AD office network, you can perform the operations in either of the following sections based on whether the SMB ACL feature is enabled for the NAS file system in the office network.
Mount a NAS file system for which SMB ACL is disabled
Create a NAS file system. For more information, see the "Step 1: Create a NAS file system" section of the Mount a NAS file system on a Windows cloud computer topic.
Obtain the domain name of a mount target.
On the NAS File Systems page in the EDS console, find the NAS file system that you want to mount and record the domain name of a mount target of the file system in the Mount Target Domain column.
Mount the NAS file system on a Linux cloud computer.
Connect to the cloud computer and open Terminal on the cloud computer.
Run the following commands in sequence to install the CIFS client by using the apt-get tool.
sudo apt update
sudo apt-get install keyutils cifs-utils
Run the id
command to view the values of uid and gid.
Run the following commands to mount the NAS file system to the specified directory on the cloud computer:
Command syntax:
sudo mount -t cifs //<Domain name of the mount target>/myshare <Mount directory> -o <Mount options>
In the following sample command, 0bb254adc3-x****.cn-beijing.nas.aliyuncs.com
is used as a domain name, /mnt
is used as a directory, and the uid and gid values returned in the previous step are used. Replace the preceding values with actual values based on your business scenario.
sudo mount -t cifs //0bb254adc3-x****.cn-beijing.nas.aliyuncs.com/myshare /mnt -o vers=2.0,guest,uid=1677****,gid=1677****,dir_mode=0755,file_mode=0755,mfsymlinks,cache=strict,rsize=1048576,wsize=1048576
Run the mount -l
command to view the mount result.
If a command output similar to the following example appears, the file system is mounted.
(Optional) After the file system is mounted, you can run the df -h
command to view the storage capacity of the file system.
Mount a NAS file system for which SMB ACL is enabled
Create a NAS file system. For more information, see the "Step 1: Create a NAS file system" section of the Mount a NAS file system on a Windows cloud computer topic.
Obtain the domain name of a mount target.
On the NAS File Systems page, find the NAS file system that you want to mount and record the domain name of a mount target of the file system in the Mount Target Domain column.
Create a keytab file. For more information, see the "Step 1: Create a keytab file" section of the Join the mount target of an SMB file system to an AD domain topic.
Enable SMB ACL and upload the keytab file.
On the NAS File Systems page, find the required NAS file system and click Manage in the Actions column.
In the left-side navigation pane of the NAS console, choose File System List > Access Control.
Set the SMB ACL parameter to On and upload the keytab file. For more information about how to upload a keytab file, see the "Step 2: Upload the keytab file" section of the Join the mount target of an SMB file system to an AD domain topic.
Mount the NAS file system on a Linux cloud computer.
Connect to the cloud computer and open Terminal on the cloud computer.
Run the following commands in sequence to install the CIFS client by using the apt-get tool.
sudo apt update
sudo apt-get install keyutils cifs-utils
Run the id
command to view the values of cruid, uid, and gid.
Run the following commands to mount the NAS file system to the specified directory on the cloud computer:
Command syntax:
sudo mount -t cifs //<Domain name of the mount target>/myshare <Mount directory> -o <Mount options>
In the following sample command, 0bb254adc3-x****.cn-beijing.nas.aliyuncs.com
is used as a domain name, /mnt
is used as a directory, and the cruid, uid and gid values returned in the previous step are used. Replace the preceding values with actual values based on your business scenario.
sudo mount -t cifs //0bb254adc3-x****.cn-beijing.nas.aliyuncs.com/myshare /mnt -o vers=3.0,sec=krb5,cruid=1677****,uid=1677****,gid=1677****
Important If the Enable in-transit encryption parameter is set to Yes for the SMB ACL option, the SMB protocol is enabled for the NAS file system. In this case, the vers
field in the command must be 3.0. In this case, the mount option in the mount command is vers=3.0
.
Run the mount -l
command to view the mount result.
If a command output similar to the following example appears, the file system is mounted.
(Optional) After the file system is mounted, you can run the df -h
command to view the storage capacity of the file system.
What to do next
Important When you restart the Linux cloud computer on which a NAS file system is mounted, the mount information about the file system may be lost. To prevent this issue, you can modify the /etc/fstab
configuration file on the Linux cloud computer to enable automatic mounting at startup for the file system.
Run the following command to enable automatic mounting when the cloud computer is started:
In your actual business scenarios, replace the domain name of the mount target with the actual value.
//<Domain name of the mount target>/myshare /mnt cifs vers=3,guest,uid=0,gid=0,dir_mode=0755,file_mode=0755,mfsymlinks,cache=strict,rsize=1048576,wsize=1048576 0 0
Note For more information about the fields in the command, see the Major fields in the command table in this topic. The following table describes the meanings of 0
in the command.
Position | Description |
The first 0 that follows the wsize value | Specifies whether to back up a NAS file system by running the dump command. If the value is not 0, the file system is backed up. For a NAS file system, the default value is 0. |
The second 0 that follows the wsize value | Specifies the order in which the fsck command checks a file system at startup. For a NAS file system, the default value is 0, indicating that the fsck command is not run at startup. |