Mounting and unmounting NFS CFS on a single BCC
Once you’ve created a CFS NFS file system, you need to mount it on Baidu Cloud Compute (BCC) to allow shared access across multiple BCC instances. This guide explains how to mount a CFS NFS file system using a Linux BCC instance.
Prerequisites
- The target BCC instance (Linux) has been created for mounting the CFS file system. For BCC creation methods, refer to: Quick Configuration of Linux Cloud Servers.
- An NFS file system has been created with a mount target added. For detailed steps, refer to: Create File System, Add Mount Target.
Mounting steps
Step I: Obtain domain name of a mount target
Once the mount target has been created, you can start using the file system. Click the Manage button in the operation toolbar of the file system list to access the mount target information page, as demonstrated below:

After logging into the virtual machine or container, use the mount target’s domain name to perform file system operations.
Step II: Install NFS client
Most operating systems do not include an NFS client by default, so you will need to manually install the NFS client before mounting the file system.
Log in to Baidu Cloud Compute (BCC) and run the required commands to install the NFS client.
- For CentOS/RHEL OS, run the following command:
1yum install nfs-utils
- For Ubuntu/Debian OS, run the following command:
1apt-get install nfs-common
All the above commands require root privileges to execute.
Step III: Mount NFS protocol file system
Manually mount an NFS file system
It is recommended to use the following command to mount the file system (root permissions required):
1mount -t nfs4 -o minorversion=1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport <Domain name of a mount target>:/ <client local path>
Description:
- <Domain name of a mount target> can be found in the file system’s mount target list (see Step I);
- Path of the CFS file system: By default, it is the root directory of CFS (e.g., /). You can modify it to an existing subdirectory (e.g., /dir0);
- <Client local path> refers to the client’s local path for mounting. It must be an absolute path beginning with / (e.g., /mnt/cfs) and must already exist prior to mounting.
Parameters in the command are explained in the table below (for more parameters, refer to NFS Document):
| Option | Description |
|---|---|
| minorversion | This refers to the minor version number of the mount protocol. The value must be 1, indicating the use of the NFS 4.1 protocol. |
| rsize | Set the maximum byte size of data that a client file read request can receive. If this value is set too small, it will result in decreased read throughput. Recommended value: 1048576. |
| wsize | Set the maximum byte size that a client file write request can send. If this value is set too small, it will result in decreased write throughput. Recommended value: 1048576. |
| hard | The client retry option offers two values: hard and soft, with hard being the default value if unspecified. Under the hard option, the client will retry indefinitely before the server responds, ensuring data integrity. Under the soft option, the client will retry for a period before giving up and then return an error to the client. If this option is enabled, it is recommended to increase the timeo value to reduce the risk of data corruption. Recommended value: hard. |
| timeo | Time that the client waits for a response before retrying an NFS request, in deciseconds (0.1 s). The value should not be lower than 150, that is, 15 seconds. Recommended value: 600. |
| retrans | Count of client retry requests. Exceeding this count will trigger further recovery operations. Recommended value: 2. |
| noresvport | Options for use privileged port numbers: resvport and noresvport, with resvport being the default value. resvport indicates using privileged ports (1-1023), noresvport indicates not using privileged ports (>1023). Non-privileged port numbers have a wider range, which can reduce service unavailability issues caused by port allocation problems. Recommended value: noresvport. |
Automatically mount a NFS file system
Manually mounted file systems will lose their mount information after a system reboot. To enable automatic mounting during system startup, follow the steps below.
Modify /etc/fstab and add the following content (root permission required):
1<Mount target address>:/ <client local path> nfs4 minorversion=1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,_netdev 0 0
Compared to manual mounting, automatic mounting includes an additional parameter _netdev. This parameter requires the OS to attempt mounting the file system only after the network is ready. If this parameter is not specified, the risk of mount failure will increase.
Step IV: View mounted NFS file systems
Use the following command to view mounted file systems:
1cat /proc/mounts
To view the file system capacity information, use the following command:
1df -h
Unmounting steps
- Sign in to the Baidu Cloud Compute (BCC) where the CFS file system is mounted.
- Use the "umount" command to detach the file system.
1umount <target path>
2 ## Among them, <target path> refers to the local path of the CFS file system to be unmounted
- Execute the
mount -lcommand to check the unmounting result. If the mounted CFS file system information is not found in the echo, it means the file system's mount directory has been successfully unmounted.
