All Products
Search
Document Center

File Storage NAS:Unmount a file system by running a command

Last Updated:Nov 01, 2024

This topic describes how to unmount a file system that was previously mounted on a directory by running a command.

Prerequisites

Unmount a file system from a Linux ECS instance

  1. Log on to the Elastic Compute Service (ECS) console.

  2. Connect to the ECS instance from a remote host.

  3. Run the umount /mnt command to unmount a Network File System (NFS) file system. Replace the /mnt directory with the actual mount directory.

    Note

    We 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.

      Note
      • If 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> or umount -l <Mount directory> command to forcibly unmount the file system.

  4. 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.

  5. 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

  1. Log on to the ECS console.

  2. 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.

    Note
    • You 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.

  3. 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

  4. 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.