Chinaunix首页 | 论坛 | 博客
  • 博客访问: 402924
  • 博文数量: 49
  • 博客积分: 2562
  • 博客等级: 少校
  • 技术积分: 417
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-03 09:10
个人简介

时不我待。

文章分类

全部博文(49)

文章存档

2024年(1)

2020年(3)

2013年(1)

2012年(5)

2011年(9)

2010年(4)

2009年(9)

2008年(15)

2005年(2)

分类: LINUX

2012-09-13 10:09:12

最近Linux服务器异常,导致文件系统变成只读状态,无法正常卸载,只能强制卸载了,文件系统为/u03,执行命令如下。

点击(此处)折叠或打开

  1. fuser -k -m -v /u03
  2. umount /u03
lsof 的工具也不错

点击(此处)折叠或打开

  1. lsof |grep u03


顺便查了一下fuser的帮助。

点击(此处)折叠或打开

  1. FUSER(1) User Commands FUSER(1)

  2. NAME
  3. fuser - identify processes using files or sockets

  4. SYNOPSIS
  5. fuser [-a|-s|-c] [-4|-6] [-n space ] [-k [-i] [-signal ] ] [-muvf] name
  6. fuser -l
  7. fuser -V

  8. DESCRIPTION
  9. fuser displays the PIDs of processes using the specified files or file systems. In the default display mode,
  10. each file name is followed by a letter denoting the type of access:

  11. c current directory.

  12. e executable being run.

  13. f open file. f is omitted in default display mode.

  14. F open file for writing. F is omitted in default display mode.

  15. r root directory.

  16. m mmap’ed file or shared library.

  17. fuser returns a non-zero return code if none of the specified files is accessed or in case of a fatal error. If
  18. at least one access has been found, fuser returns zero.

  19. In order to look up processes using TCP and UDP sockets, the corresponding name space has to be selected with
  20. the -n option. By default fuser will look in both IPv6 and IPv4 sockets. To change the default, behavior, use
  21. the -4 and -6 options. The socket(s) can be specified by the local and remote port, and the remote address. All
  22. fields are optional, but commas in front of missing fields must be present:

  23. [lcl_port][,[rmt_host][,[rmt_port]]]

  24. Either symbolic or numeric values can be used for IP addresses and port numbers.

  25. fuser outputs only the PIDs to stdout, everything else is sent to stderr.

  26. OPTIONS
  27. -a Show all files specified on the command line. By default, only files that are accessed by at least one
  28. process are shown.

  29. -c Same as -m option, used for POSIX compatibility.

  30. -f Silently ignored, used for POSIX compatibility.

  31. -k Kill processes accessing the file. Unless changed with -signal, SIGKILL is sent. An fuser process never
  32. kills itself, but may kill other fuser processes. The effective user ID of the process executing fuser
  33. is set to its real user ID before attempting to kill.

  34. -i Ask the user for confirmation before killing a process. This option is silently ignored if -k is not
  35. present too.

  36. -l List all known signal names.

  37. -m name specifies a file on a mounted file system or a block device that is mounted. All processes access-
  38. ing files on that file system are listed. If a directory file is specified, it is automatically changed
  39. to name/. to use any file system that might be mounted on that directory.

  40. -n space
  41. Select a different name space. The name spaces file (file names, the default), udp (local UDP ports),
  42. and tcp (local TCP ports) are supported. For ports, either the port number or the symbolic name can be
  43. specified. If there is no ambiguity, the shortcut notation name/Ispace (e.g. 80/tcp ) can be used.

  44. -s Silent operation. -u and -v are ignored in this mode. -a must not be used with -s.

  45. -signal
  46. Use the specified signal instead of SIGKILL when killing processes. Signals can be specified either by
  47. name (e.g. -HUP) or by number (e.g. -1). This option is silently ignored if the -k option is not used.

  48. -u Append the user name of the process owner to each PID.

  49. -v Verbose mode. Processes are shown in a ps-like style. The fields PID, USER and COMMAND are similar to
  50. ps. ACCESS shows how the process accesses the file. If the access is by the kernel (e.g. in the case of
  51. a mount point, a swap file, etc.), kernel is shown instead of the PID.

  52. -V Display version information.

  53. -4 Search only for IPv4 sockets. This option must not be used with the -6 option and only has an effect
  54. with the tcp and udp namespaces.

  55. -6 Search only for IPv6 sockets. This option must not be used with the -4 option and only has an effect
  56. with the tcp and udp namespaces.

  57. - Reset all options and set the signal back to SIGKILL.

  58. FILES
  59. /proc location of the proc file system

  60. EXAMPLES
  61. fuser -km /home kills all processes accessing the file system /home in any way.

  62. if fuser -s /dev/ttyS1; then :; else something; fi invokes something if no other process is using /dev/ttyS1.

  63. fuser telnet/tcp shows all processes at the (local) TELNET port.

  64. RESTRICTIONS
  65. Processes accessing the same file or file system several times in the same way are only shown once.

  66. If the same object is specified several times on the command line, some of those entries may be ignored.

  67. fuser may only be able to gather partial information unless run with privileges. As a consequence, files opened
  68. by processes belonging to other users may not be listed and executables may be classified as mapped only.

  69. Installing fuser SUID root will avoid problems associated with partial information, but may be undesirable for
  70. security and privacy reasons.

  71. udp and tcp name spaces, and UNIX domain sockets can’t be searched with kernels older than 1.3.78.

  72. udp and tcp currently work with IPv6 and IPv4, but the address fields can only be IPv4 addresses.

  73. Accesses by the kernel are only shown with the -v option.

  74. The -k option only works on processes. If the user is the kernel, fuser will print an advice, but take no
  75. action beyond that.

  76. BUGS
  77. fuser -m /dev/sgX will show (or kill with the -k flag) all processes, even if you don’t have that device con-
  78. figured. There may be other devices it does this for too.

  79. fuser cannot report on any processes that it doesn’t have permission to look at the file descriptor table for.
  80. The most common time this problem occurs is when looking for TCP or UDP sockets when running fuser as a non-
  81. root user. In this case fuser will report no access

  82. AUTHORS
  83. Werner Almesberger

  84. Craig Small

  85. SEE ALSO
  86. kill(1), killall(1), lsof(8), ps(1), kill(2).

  87. Linux 2005-11-05 FUSER(1)

阅读(6814) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~