Unmount a file system by running a command

更新时间:
复制 MD 格式

Run a command to unmount a NAS file system from a Linux or Windows ECS instance.

Prerequisites

Before you begin, ensure that you have:

  • A File Storage NAS (NAS) file system. For more information, see Create a file system.

  • A mount target. For more information, see Manage mount targets.

  • The file system mounted on the client from which you plan to unmount it. For more information, see Scenarios.

Unmount from a Linux ECS instance

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

  2. Connect to the ECS instance.

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

    Note

    Do not add extra parameters to the umount command unless necessary.

    If the device is busy error appears, a process is still accessing the file system. To identify and stop the process:

    • Install fuser if it is not already present:

      • CentOS, Red Hat Enterprise Linux (RHEL), and Alibaba Cloud Linux: fuser is preinstalled.

      • Ubuntu and Debian: run apt install -y fuser.

    • Run fuser -mv <local directory of the mount target> to identify the process ID accessing the NAS file system.

    • Run kill <pid> to stop the process.

      Note
      • Do not kill kernel processes.

      • If the file system still cannot be unmounted, run the umount -f <Mount directory> or umount -l <Mount directory> command to forcibly unmount the file system. Force unmounting can cause data loss or corruption. Use it only as a last resort.

  4. Optional. Disable automatic mounting.

    If an automatic mount entry for this file system exists in /etc/fstab, remove or comment out the corresponding line to prevent the file system from remounting on startup.

  5. Verify that the file system is unmounted. Run mount -l and confirm the file system no longer appears in the output.

Unmount from a Windows ECS instance

  1. Log on to the ECS console.

  2. Open Command Prompt and run the following command to unmount the file system:

    net use D: /delete

    Replace the drive letter D: with the actual drive letter. Run the net use command to obtain the drive letter of a mount target.

    Note
    • The net use * /delete command will prompt you to confirm the unmounting of each mapped drive one by one.

    • The net use * /delete /y command unmounts all mapped drives without confirmation.

  3. Optional. Disable automatic mounting.

    Delete the automatic mount script or remove the entry in /etc/fstab to prevent the file system from remounting on startup.

    • SMB file system automatic mount script: auto_mount.bat

    • NFS file system automatic mount script: nas_auto.bat

    To also remove the scheduled task, open Task Scheduler, locate the corresponding task, and delete it.

  4. Run the net use command to verify the unmount result. The file system is unmounted if the SMB file system no longer appears in the output.