La commande 'fuser' vous permet de lister les processus liés à un système de fichiers.
Cela donne ainsi une explication sur ce qui peut empêcher le démontage d'un volume logique.
Lorsque l'on passe l'option '-k', on demande alors au programme d'interrompre ces processus pour libérer le système de fichiers.
Un exemple :
# fuser /dev/hd4
/dev/hd4: 1c 720986c 3932228c 3997850r 4128922r 4391004c 4456670c 4849838c 5046304r 5112020c 5439698c 5505030r 5636288r 5767364r 5832900r 6029526r 6160444r 6619350c 6684712r 6881494r 6947062r 7012570r 7077932c 7405794r 7602194r 7667774c 27263072r 51773684r 58392604r 63373528c 44171726c 52625826c 55050574r
Il faut retirer la lettre en fin de chaque chaine pour obtenir le numéro de processus récupérable ensuite avec 'ps -ef'.
La documentation officielle V7.1 est donnée ci-dessous.
fuser Command
Purpose
Identifies processes using a file or file structure.
Syntax
fuser [[-c | -f ][-x ] |-d ] [ -k | -K { SignalNumber | SignalName }] [ -u ] [ -V ]File ...
Description
The fuser command lists the process numbers of local processes that use the local or remote files specified by the File parameter. For block special devices,
the command lists the processes that use any file on that device.
Each process number is followed by a letter indicating how the process uses the file:
Item
Description
c
Uses the file as the current directory.
e
Uses the file as a program's executable object.
r
Uses the file as the root directory.
s
Uses the file as a shared library (or other loadable object).
The process numbers are written to standard output in a line with spaces between process numbers. A new line character is written to standard error after the
last output for each file operand. All other output is written to standard error.
The fuser command will not detect processes that have mmap regions where that associated file descriptor has since been closed. Also, processes using FIFOs
(named pipes) will not be detected until the FIFO is fully opened. For example, a process waiting for an open system call to complete will not be seen by the
fuser command.
Flags
Item
Description
-c
Reports on any open files in the file system containing File.
-d
Reports on any open files which have been unlinked (deleted) from the file system containing File. When used in conjunction with the -V flag, it also
reports the inode number and size of the deleted file.
-f
Reports on open instances of File only.
-K SignalNumber | SignalName
Sends the specified signal to each local process. Only the root user can kill a process of another user. Signal can be specified as either a SignalName,
such as KILL for the SIGKILL signal or a SignalNumber, such as 9. Valid values for SignalName are those which are displayed by the kill -l command.
-k
Sends the SIGKILL signal to each local process. Only the root user can kill a process of another user.
Note: fuser -k or -K might not be able to detect and kill new processes that are created immediately after the program starts to run.
-u
Provides the login name for local processes in parentheses after the process number.
-V
Provides verbose output.
-x
Used in conjunction with -c or -f, reports on executable and loadable objects in addition to the standard fuser output.
Security
Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more
information about authorizations and privileges, see Privileged Command Database in AIX Version 7.1 Security. For a list of privileges and the authorizations
associated with this command, see the lssecattr command or the getcmdattr subcommand.
Examples
1 To list the process numbers of local processes using the /etc/passwd file, enter:
fuser /etc/passwd
2 To list the process numbers and user login names of processes using the /etc/filesystems file, enter:
fuser -u /etc/filesystems
3 To terminate all of the processes using a given file system, enter:
fuser -k -x -u -c /dev/hd1
or
fuser -kxuc /home
Either command lists the process number and user name, and then terminates each process that is using the /dev/hd1 (/home) file system. Only the root user
can terminate processes that belong to another user. You might want to use this command if you are trying to unmount the /dev/hd1 file system and a
process that is accessing the /dev/hd1 file system prevents this.
4 To list all processes that are using a file which has been deleted from a given file system, enter:
fuser -d /usr
Files
Item
Description
/dev/kmem
Used for the system image.
/dev/mem
Also used for the system image.