什么是tmpfs
tpmfs相关内容
我们用df命令看到的 /run/user/1000 的tmpfs是什么?
1 | tmpfs 49M 0 49M 0% /run/user/0 |
我们来看红帽的解释:
What is the purpose of the /run/user/1000, tmpfs filesystem that appears in df?
问题:
We could see /run/user/1000 filesystem , is this a symptom of any issue?
Why do I see multiple of tmpfs filesystems / partitions in the output of df?
Why do I see a /run/user/$UID directory when the user is not logged in (i.e. does not appear in the output of w or who)?
决议:
The directory /run/user/$UID is used by pam_systemd to store files that previously where put in /tmp.
This is normal and should not cause any issues.
NOTE: since systemd-219.19, /run/user/$UID is mounted as tmpfs.
The manual page of pam_systemd(8) gives more indications on this.
1 | # man pam_systemd |
根源:
From the pam_systemd(8) manual page:
pam_systemd registers user sessions with the systemd login manager systemd-logind.service(8), and hence the systemd control group hierarchy.
On login, this module ensures the following:
If it does not exist yet, the user runtime directory /run/user/\$USER is created and its ownership changed to the user that is logging in. Then, /run/user/$USER is mounted as tmpfs.
The $XDG_SESSION_ID environment variable is initialized. If auditing is available and pam_loginuid.so was run before this module (which is highly recommended), the variable is
initialized from the auditing session id (/proc/self/sessionid). Otherwise, an independent session counter is used.A new systemd scope unit is created for the session. If this is the first concurrent session of the user, an implicit slice below user.slice is automatically created and the
scope placed into it.
On logout, this module ensures the following:
If enabled in logind.conf(5), all processes of the session are terminated. If the last concurrent session of a user ends, the user’s slice unit will be terminated too.
If the last concurrent session of a user ends, the \$XDG_RUNTIME_DIR directory and all its contents are removed, too. Then, /run/user/$USER is unmounted.
If the system was not booted up with systemd as init system, this module does nothing and immediately returns PAM_SUCCESS.
诊断步骤:
The logged in users (a.k.a. users with active logind sessions) can be see with the loginctl command.
1 | [root@node2 ~]# loginctl |
Again with the loginctl command we can see some more details about any user with an active session. This can help identify why the user has an active session (i.e. what processes is the user running).
1 | [root@node2 ~]# loginctl user-status 1000 |
Traditionally the w and who commands have been used to check which users are logged in. However, in RHEL7, loginctl has more reliable data. For example, if a user is connected through sftp, they do not have an terminal connection (no tty or pty/pts). Because of this, the user does not appear in w or who, but they do appear in loginctl and they have a /run/user/$UID directory and an active session. Again, this can be checked with the loginctl commands shown above.
[systemd-208-20/src/login-user.c]
1 | static int user_mkdir_runtime_path(User *u) { |
[systemd-219.19/src/login-user.c]
1 | static int user_mkdir_runtime_path(User *u) { |
devtmpfs
shm
参考连接
https://unix.stackexchange.com/questions/162900/what-is-this-folder-run-user-1000