Linux how to use the umount command to force the file system to be unmounted

  
                

For a file system mounted on a Linux system, it is usually impossible to uninstall. You can forcefully uninstall it by using the command. The following small series introduces you to how to use the umount command to force the file system to be unmounted.

umount command

solution linked to the file system. Umount [-ahnrvV][-t "File System Type"][File System]

umount removes the file system currently hanging in the Linux directory.

There is a problem with the online nfs access, causing the /data1 directory ls to fail to output and need to be uninstalled. However, when the directory is directly unloaded, the directory is being occupied by other processes and cannot be directly umount. Here, the uuser is unloaded in conjunction with the fuser.

1. Direct Uninstall

[root@localhost /]# umount /data1/img

umount: /data1/img: device is busy

Umount: /data1/img: device is busy

2. The prompt is occupied, use forced uninstallation

[root@localhost /]# umount -f /data1/img

umount2: Device or resource busy

umount: /data1/img: device is busy

umount2: Device or resource busy

umount: /data1/img: device is Busy

Note: When using the -f parameter for forced unloading, it is generally recommended to wait for a while and then perform the following operations. In some cases, it takes 1-2 minutes to process.

3, using umount -f, the problem remains. Use the fuser command to first confirm that those processes are occupying the directory

[root@localhost /]# fuser -cu /data1/img

/data1/img: 1757c(mysql)

The above view shows that the process starting from the mysql user with pid 1757 is occupying this directory.

4, confirm that the process started by mysql can be killed, you can directly use the k parameter of the fuser to kill (you can also manually stop the 1757 process and then uninstall)

[root@localhost /] # fuser -ck /data1/img

/data1/img: 1757c

Note: Here k is the meaning of kill, please be careful to use this parameter before confirming.

In addition, when umount is abnormal, lsof is often used to specify which process the file is occupied by.

The above is the way to use Linux to use the umount command to force the file system to be unloaded, even if the prompt is occupied. Can be uninstalled by command.

Copyright © Windows knowledge All Rights Reserved