![如何从该日志中识别哪些 systemd 服务超时?例如。停止 /dev/dm-0 超时](https://linux22.com/image/5562/%E5%A6%82%E4%BD%95%E4%BB%8E%E8%AF%A5%E6%97%A5%E5%BF%97%E4%B8%AD%E8%AF%86%E5%88%AB%E5%93%AA%E4%BA%9B%20systemd%20%E6%9C%8D%E5%8A%A1%E8%B6%85%E6%97%B6%EF%BC%9F%E4%BE%8B%E5%A6%82%E3%80%82%E5%81%9C%E6%AD%A2%20%2Fdev%2Fdm-0%20%E8%B6%85%E6%97%B6.png)
在下面的部分日志中,那些带有and 的dev-disk
行,我如何找出哪个服务(例如)负责它们,以便我可以在 my 中附加一个(如下所示)以确保它首先停止?dev-dm
timed out
timeout
that.service
After=that.service
qubes-core.service
Qubes Dom0 startup setup
[ 3866.707545] systemd[1]: Started Show Plymouth Reboot Screen.
[ 3866.777998] qmemman.systemstate[1620]: mem-set domain 3 to 4194304000
[ 3866.778860] qmemman.systemstate[1620]: mem-set domain 7 to 4194304000
[ 3866.779587] qmemman.systemstate[1620]: mem-set domain 6 to 4194304000
[ 3866.951011] systemd[1]: Stopped Restore /run/initramfs on shutdown.
[ 3871.685359] systemd[1]: Received SIGRTMIN+20 from PID 9952 (plymouthd).
[ 3956.361763] systemd[1]: dev-disk-by\x2did-dm\x2dname\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device: Job dev-disk-by\x2did-dm\x2dname\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device/stop timed out.
[ 3956.362322] systemd[1]: Timed out stopping /dev/disk/by-id/dm-name-luks-9ed952b5-2aa8-4564-b700-fb23f5c9e94b.
[ 3956.362945] systemd[1]: dev-disk-by\x2did-dm\x2dname\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device: Job dev-disk-by\x2did-dm\x2dname\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device/stop failed with result 'timeout'.
[ 3956.363698] systemd[1]: dev-disk-by\x2did-lvm\x2dpv\x2duuid\x2dpxC3ch\x2d0MF0\x2dOzJs\x2dJogd\x2d9rOz\x2dJkSt\x2dCf8G7m.device: Job dev-disk-by\x2did-lvm\x2dpv\x2duuid\x2dpxC3ch\x2d0MF0\x2dOzJs\x2dJogd\x2d9rOz\x2dJkSt\x2dCf8G7m.device/stop timed out.
[ 3956.363702] systemd[1]: Timed out stopping /dev/disk/by-id/lvm-pv-uuid-pxC3ch-0MF0-OzJs-Jogd-9rOz-JkSt-Cf8G7m.
[ 3956.366332] systemd[1]: dev-disk-by\x2did-lvm\x2dpv\x2duuid\x2dpxC3ch\x2d0MF0\x2dOzJs\x2dJogd\x2d9rOz\x2dJkSt\x2dCf8G7m.device: Job dev-disk-by\x2did-lvm\x2dpv\x2duuid\x2dpxC3ch\x2d0MF0\x2dOzJs\x2dJogd\x2d9rOz\x2dJkSt\x2dCf8G7m.device/stop failed with result 'timeout'.
[ 3956.367093] systemd[1]: dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS1\x2d9ed952b52aa84564b700fb23f5c9e94b\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device: Job dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS1\x2d9ed952b52aa84564b700fb23f5c9e94b\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device/stop timed out.
[ 3956.367098] systemd[1]: Timed out stopping /dev/disk/by-id/dm-uuid-CRYPT-LUKS1-9ed952b52aa84564b700fb23f5c9e94b-luks-9ed952b5-2aa8-4564-b700-fb23f5c9e94b.
[ 3956.368768] systemd[1]: dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS1\x2d9ed952b52aa84564b700fb23f5c9e94b\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device: Job dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS1\x2d9ed952b52aa84564b700fb23f5c9e94b\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device/stop failed with result 'timeout'.
[ 3956.368789] systemd[1]: dev-dm\x2d0.device: Job dev-dm\x2d0.device/stop timed out.
[ 3956.368808] systemd[1]: Timed out stopping /dev/dm-0.
[ 3956.372748] systemd[1]: dev-dm\x2d0.device: Job dev-dm\x2d0.device/stop failed with result 'timeout'.
[ 3956.372769] systemd[1]: sys-devices-virtual-block-dm\x2d0.device: Job sys-devices-virtual-block-dm\x2d0.device/stop timed out.
[ 3956.372774] systemd[1]: Timed out stopping /sys/devices/virtual/block/dm-0.
[ 3956.375485] systemd[1]: sys-devices-virtual-block-dm\x2d0.device: Job sys-devices-virtual-block-dm\x2d0.device/stop failed with result 'timeout'.
[ 3956.375509] systemd[1]: session-2.scope: Stopping timed out. Killing.
[ 3956.375570] systemd[1]: session-2.scope: Killing process 3576 (qubes-guid) with signal SIGKILL.
[ 3956.376535] systemd[1]: Stopped Session 2 of user ctor.
[ 3956.381215] systemd[1]: session-2.scope: Unit entered failed state.
[ 3956.381915] systemd[1]: Removed slice User Slice of ctor.
[ 3956.385125] systemd[1]: Stopping Login Service...
[ 3956.389095] systemd[1]: Stopping Permit User Sessions...
[ 3956.393457] systemd[1]: Stopped Permit User Sessions.
[ 3956.396533] systemd[1]: Stopped Start Qubes VM sys-firewall.
[ 3956.399094] systemd[1]: Stopped Start Qubes VM sys-net.
[ 3956.402260] systemd[1]: Removed slice system-qubes\x2dvm.slice.
[ 3956.405398] systemd[1]: Stopping Qubes memory information reporter...
[ 3956.409027] systemd[1]: Stopped Qubes memory information reporter.
[ 3956.413280] systemd[1]: Stopping Qubes Dom0 startup setup...
[ 3956.433905] preshutdown[9971]: Name ID Mem VCPUs State Time(s)
[ 3956.438400] preshutdown[9971]: Domain-0 0 4071 6 r----- 706.6
[ 3956.439730] preshutdown[9971]: sys-net 1 384 2 -b---- 10.7
[ 3956.441032] preshutdown[9971]: sys-net-dm 2 144 1 -b---- 151.6
[ 3956.442332] preshutdown[9971]: sys-firewall 3 3983 2 -b---- 15.0
答案1
您可以使用systemctl show <device>
查看有关处理 *.device 的单元文件的更多详细信息。
例如,在我的 CentOS 7.x 系统上,如果我们查看journalctl -b
某些设备:
$ journalctl -b | grep 'systemd\[1\]: dev-disk-by' | head -3
Sep 03 17:48:57 centos7 systemd[1]: dev-disk-by\x2dpath-pci\x2d0000:00:01.1\x2data\x2d1.0.device changed dead -> plugged
Sep 03 17:48:57 centos7 systemd[1]: dev-disk-by\x2did-ata\x2dVBOX_HARDDISK_VBc5aaf476\x2df419b1f1.device changed dead -> plugged
Sep 03 17:48:57 centos7 systemd[1]: dev-disk-by\x2duuid-013c42ea\x2daa00\x2d4713\x2d926a\x2daca57c0bd552.device changed dead -> plugged
现在,如果我们向 systemd 查询这些文件之一.device
:
$ systemctl show 'dev-disk-by\x2duuid-013c42ea\x2daa00\x2d4713\x2d926a\x2daca57c0bd552.device'
SysFSPath=/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda2
Id=dev-disk-by\x5cx2duuid-013c42ea\x5cx2daa00\x5cx2d4713\x5cx2d926a\x5cx2daca57c0bd552.device
Names=dev-disk-by\x5cx2duuid-013c42ea\x5cx2daa00\x5cx2d4713\x5cx2d926a\x5cx2daca57c0bd552.device
Following=sys-devices-pci0000:00-0000:00:01.1-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device
Description=VBOX_HARDDISK 2
LoadState=loaded
ActiveState=active
SubState=plugged
InactiveExitTimestamp=Mon 2018-09-03 21:48:59 EDT
InactiveExitTimestampMonotonic=4178671
ActiveEnterTimestamp=Mon 2018-09-03 21:48:59 EDT
ActiveEnterTimestampMonotonic=4178671
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=no
CanStop=no
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=yes
IgnoreOnSnapshot=yes
NeedDaemonReload=no
JobTimeoutUSec=1min 30s
JobTimeoutAction=none
ConditionResult=no
AssertResult=no
ConditionTimestampMonotonic=0
AssertTimestampMonotonic=0
Transient=no
笔记:那\x2d
实际上是破折号的 ASCII 代码。
$ printf '\x2d\n'
-
之后=?
在其他服务中设置什么,以便它们在 .device 文件之后启动?为此,您需要使用这个,After=system.device
.您可以像这样查看该设备的状态,尽管它不是很明显:
$ systemctl status system.device
● system.device
Loaded: loaded
Active: inactive (dead)
Sep 03 21:49:52 centos7 systemd[1]: Collecting system.device
笔记:您也可以互换使用systemd.device
。