This topic describes how to unmount a file system that was previously mounted on a directory by running a command.
Prerequisites
A File Storage NAS (NAS) file system is created. For more information, see Create a file system.
A mount target is created. For more information, see Manage mount targets.
The NAS file system is mounted. For more information, see Scenarios.
Unmount a file system from a Linux ECS instance
Log on to the Elastic Compute Service (ECS) console.
Connect to the ECS instance from a remote host.
Run the
umount /mnt
command to unmount a Network File System (NFS) file system. Replace the /mnt directory with the actual mount directory.NoteWe recommend that you do not specify other parameters in the unmount command or change the default values of these parameters.
When you unmount the file system, the error message
device is busy
may be prompted. In this case, you must perform the following steps to terminate the process that is accessing the file system:Install fuser.
For an ECS instance that runs CentOS, Red Hat Enterprise Linux (RHEL), or Alibaba Cloud Linux, fuser is preinstalled.
For an ECS instance that runs Ubuntu or Debian, run the
apt install -y fuser
command to install fuser.
Run the
fuser -mv <Local directory of the mount target>
command to view the ID of the process that is accessing the NAS file system.Run the
kill <pid>
command to terminate the process.NoteIf the process is a kernel process, skip this step.
If the file system still cannot be unmounted after the process is terminated, you can run the
umount -f <Mount directory>
orumount -l <Mount directory>
command to forcibly unmount the file system.
Optional. Disable automatic mounting of the file system at startup.
If you configure an automatic mount script for an NFS or Server Message Block (SMB) file system and you need to restart the ECS instance, you must delete or modify the /etc/fstab configuration file to disable automatic mounting of the file system at startup.
Run the
mount -l
command to view the unmount result.If the NAS file system is not displayed in the command output, the file system is unmounted.
Unmount a file system from a Windows ECS instance
Log on to the ECS console.
Open the Command Prompt and run the following command to unmount the file system:
net use D: /delete
Replace the drive letter D: in the preceding command with the actual drive letter. You can run the
net use
command to obtain the drive letter of a mount target.NoteYou can run the net use * /delete command to unmount each available file system one by one on Windows.
You can run the net use * /delete /y command to unmount all the available file systems without any confirmation on Windows.
Optional. Disable automatic mounting of the file system at startup.
If you configure an automatic mount script for an NFS or SMB file system and you need to restart the ECS instance, you must delete or modify the automatic mount script to disable automatic mounting of the file system at startup.
Automatic mount script for an SMB file system: auto_mount.bat
Automatic mount script for an NFS file system: nas_auto.bat
Run the
net use
command to view the unmount result.If the SMB file system is not displayed in the command output, the file system is unmounted.