How linux uninstalls mounted files

Keywords: lsof Linux network Redis

*** Documents can not be uninstalled

[root@gfsd1 mnt]# umount 20170228_Mustang_V5R1_SP1/   
umount: /mnt/20170228_Mustang_V5R1_SP1: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@gfsd1 mnt]#

Solution

*** Find the processes and commands that use this file, and the specific operation code:

[root@gfsd1 mnt]# lsof |grep /mnt/20170228_Mustang_V5R1_SP1/
start.sh    5817                  root  cwd       DIR               0,38      4096 562949953463862 /mnt/20170228_Mustang_V5R1_SP1/81-moboss/nms/nms_webserver/rel/nms_webserver
start.sh    5817                  root  255r      REG               0,38       390 281474977094086 /mnt/20170228_Mustang_V5R1_SP1/81-moboss/nms/nms_webserver/start.sh

*** Executing ps can find commands to execute this process

[root@gfsd1 mnt]# ps -ef|grep 5817
root       5817   4134  0 19:06 pts/20   00:00:00 /bin/sh ./start.sh
root       6235   5817  0 19:06 pts/20   00:00:01 [beam.smp] <defunct>
root      71875   4134  0 19:18 pts/20   00:00:00 grep --color=auto 5817

*** Force the termination of irrelevant orders

[root@gfsd1 mnt]# kill -9 5817

lsof introduction

lsof (list open files) is a tool for listing open files for the current system. In linux environment, everything exists in the form of files, through which not only conventional data can be accessed, but also network connections and hardware can be accessed. So such as TCP and UDP sockets. In the background, the system assigns a file descriptor to the application, regardless of the nature of the file, which is the application and the underlying operating system. Interaction between them provides a common interface. Because the list of descriptors for the application open file provides a lot of information about the application itself, the It would be helpful for the lsof tool to be able to view this list for system monitoring and troubleshooting.

Use of lsof
The open files of the system can be displayed by inputting lsof under the terminal. Because lsof needs to access the core memory and various files, it must run as root user in order to fully function.

[root@localhost redis-3.0.5]# lsof
COMMAND     PID      USER   FD      TYPE             DEVICE  SIZE/OFF              NODE NAME
init          1      root  cwd       DIR              253,0      4096                 2 /
init          1      root  rtd       DIR              253,0      4096                 2 /
init          1      root  txt       REG              253,0    150352            131100 /sbin/init
init          1      root  mem       REG              253,0     65960           1048641 /lib64/libnss_files-2.12.so
init          1      root  mem       REG              253,0   1928936           1049950 /lib64/libc-2.12.so
init          1      root  mem       REG              253,0     93320           1048644 /lib64/libgcc_s-4.4.7-20120601.so.1
init          1      root  mem       REG              253,0     47168           1049956 /lib64/librt-2.12.so
init          1      root  mem       REG              253,0    145936           1049951 /lib64/libpthread-2.12.so
init          1      root  mem       REG              253,0    268232           1048618 /lib64/libdbus-1.so.3.4.0
init          1      root  mem       REG              253,0     39896           1048705 /lib64/libnih-dbus.so.1.0.0
init          1      root  mem       REG              253,0    101920           1048707 /lib64/libnih.so.1.0.0
init          1      root  mem       REG              253,0    157072           1048623 /lib64/ld-2.12.so

Each line shows an open file. If no conditions are specified, all files opened by all processes will be displayed by default. The meaning of lsof output column information is as follows:

Identification Effect
COMMAND Name of process
PID Identifier of process
USER Process owner
FD File descriptor, the application recognizes the file through the file descriptor.
TYPE File types, such as DIR, REG, etc.
DEVICE Specify the name of the disk
SIZE File size
NODE Index node
NAME The exact name of the open file

Posted by jbruns on Sat, 20 Apr 2019 12:15:34 -0700