由於 systemd 設備啟動作業超時導致的啟動延遲
問題描述
我終於解決了我的系統啟動速度比它應該慢的問題。我的第一步是查看啟動日誌,它顯示了設備超時的啟動作業,然後直接導致引用為cr_usb-General_USB_Flash_Disk的設備的加密設置失敗。我不確定這兩者是否有聯繫。
Starting Switch Root... [ ^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] (1 of 3) A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (19s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] (1 of 3) A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (20s / 1min 30$ ^[[K[^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] (2 of 3) A start job is running for Cryptography Setup for cr_sda2 (14s / no limit) ^[[K[^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] (2 of 3) A start job is running for Cryptography Setup for cr_sda2 (15s / no limit) ^[[K[^[[0m^[[0;31m* ^[[0m] (2 of 3) A start job is running for Cryptography Setup for cr_sda2 (15s / no limit) ^[[K[^[[0;32m OK ^[[0m] Found device /dev/disk/by-uuid/3f9a66f0-dea7-4d5d-a200-bd1033718af8. [^[[0;32m OK ^[[0m] Started Cryptography Setup for cr_sda2. Starting File System Check on /dev/disk/by-uuid/3f9a66f0-dea7-4d5d-a200-bd1033718af8... [^[[0;32m OK ^[[0m] Started File System Check on /dev/disk/by-uuid/3f9a66f0-dea7-4d5d-a200-bd1033718af8. Mounting /home... [^[[0;32m OK ^[[0m] Mounted /home. [^[[0;32m OK ^[[0m] Reached target Local File Systems. Starting Restore /run/initramfs on shutdown... Starting Create Volatile Files and Directories... Starting Tell Plymouth To Write Out Runtime Data... [^[[0;32m OK ^[[0m] Started Tell Plymouth To Write Out Runtime Data. [^[[0;32m OK ^[[0m] Started Restore /run/initramfs on shutdown. [^[[0;32m OK ^[[0m] Started Create Volatile Files and Directories. Starting Security Auditing Service... [^[[0;32m OK ^[[0m] Started Security Auditing Service. Starting Update UTMP about System Boot/Shutdown... [^[[0;32m OK ^[[0m] Started Update UTMP about System Boot/Shutdown. ^[[K[ ^[[0;31m*^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 22s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 23s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m*^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 23s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 24s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 24s / 1min 30s) ^[[K[^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 25s / 1min 30s) ^[[K[^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 25s / 1min 30s) ^[[K[^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 26s / 1min 30s) ^[[K[^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 26s / 1min 30s) ^[[K[^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 27s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 27s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m* ^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 28s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m^[[0;31m*^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 28s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 29s / 1min 30s) ^[[K[ ^[[0;31m*^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 29s / 1min 30s) ^[[K[ ^[[0;31m*^[[0;1;31m*^[[0m] A start job is running for dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device (1min 30s / 1min 30s) ^[[K[^[[0;1;31m TIME ^[[0m] Timed out waiting for device dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device. [^[[0;1;33mDEPEND^[[0m] Dependency failed for Cryptography Setup for cr_usb-General_USB_Flash_Disk_0349315060001623-0:0-part2. [^[[0;1;33mDEPEND^[[0m] Dependency failed for Encrypted Volumes. [^[[0;32m OK ^[[0m] Reached target System Initialization.
這特別奇怪,因為我的系統沒有連接 USB 驅動器。
我在 systemd 中找到了相應的設備服務(pastebin 連結,請參見第 67 行),但是我無法確定該設備到底是什麼或為什麼會出現。
原來不祥的 USB 設備在**/etc/crypttab中有一個條目**
cr_sda2 UUID=7f99168c-4972-468b-900f-fb5bbfb90e66 cr_usb-General_USB_Flash_Disk_0349315060001623-0:0-part2 UUID=00a69115-956d-41b3-83
問題
如何確定這是什麼設備?
可以從啟動中安全地刪除它嗎?如果可以,如何?
類似問題
在研究這個時,我遇到了幾篇描述類似症狀但顯然有不同原因的文章。其中的範例是此部落格條目和Superuser SE 上的此問題,兩者都將此問題跟踪到 fstab 中的錯誤交換分區/條目。然而,引導日誌的摘錄讓我相信這些與我的特定問題無關。
系統資訊
一般資訊
我正在執行連接了 HDD (sda)、SSD (sdb) 和 sd 卡 (mmcblk0) 的 OpenSUSE Leap 15。
blkid
/dev/sda1: UUID="7b4cf082-a27d-458a-b92b-bc4eb3f81dc5" TYPE="ext4" PARTUUID="b9b6e898-306d-4834-bc40-b06a0b05c255" /dev/sda2: UUID="7f99168c-4972-468b-900f-fb5bbfb90e66" TYPE="crypto_LUKS" PARTUUID="eda06af5-b65d-4a41-88f3-76c884eda694" /dev/sda3: UUID="35de195e-c983-4f53-9ef2-f3e9f42539e7" TYPE="swap" PARTUUID="15489cc9-d2c6-4446-b7fc-0efdb26c3dfe" /dev/sdb1: UUID="3DC1-430C" TYPE="vfat" PARTUUID="7093ce52-e282-45ef-a09a-b19eb54a268e" /dev/sdb3: UUID="1f987306-6da7-4393-b1cb-eb9c541da80c" TYPE="ext4" PARTUUID="96e413c8-1b55-4383-87f1-5c2094c27b47" /dev/mmcblk0p1: UUID="77FB-45CC" TYPE="vfat" PARTUUID="09b07cfe-1f9b-40e9-aa52-27892b6971ff" /dev/mapper/cr_sda2: UUID="3f9a66f0-dea7-4d5d-a200-bd1033718af8" TYPE="ext4" /dev/mmcblk0: PTUUID="21d3220a-de4c-4f1c-9abc-e57d62434b4e" PTTYPE="gpt"
/etc/fstab
UUID=7b4cf082-a27d-458a-b92b-bc4eb3f81dc5 / ext4 acl,user_xattr 0 1 UUID=35de195e-c983-4f53-9ef2-f3e9f42539e7 swap swap defaults 0 0 UUID=1f987306-6da7-4393-b1cb-eb9c541da80c /boot ext4 data=ordered,acl,user_xattr 0 2 UUID=3f9a66f0-dea7-4d5d-a200-bd1033718af8 /home ext4 data=ordered,acl,user_xattr 0 2 UUID=3DC1-430C /boot/efi vfat defaults 0 0
ls -l /dev/disk/by-uuid
total 0 lrwxrwxrwx 1 root root 10 Nov 29 08:59 1f987306-6da7-4393-b1cb-eb9c541da80c -> ../../sdb3 lrwxrwxrwx 1 root root 10 Nov 29 08:59 35de195e-c983-4f53-9ef2-f3e9f42539e7 -> ../../sda3 lrwxrwxrwx 1 root root 10 Nov 29 08:59 3DC1-430C -> ../../sdb1 lrwxrwxrwx 1 root root 10 Nov 29 08:25 3f9a66f0-dea7-4d5d-a200-bd1033718af8 -> ../../dm-0 lrwxrwxrwx 1 root root 15 Nov 29 08:59 77FB-45CC -> ../../mmcblk0p1 lrwxrwxrwx 1 root root 10 Nov 29 08:59 7b4cf082-a27d-458a-b92b-bc4eb3f81dc5 -> ../../sda1 lrwxrwxrwx 1 root root 10 Nov 29 08:59 7f99168c-4972-468b-900f-fb5bbfb90e66 -> ../../sda2
- 如何確定這是什麼設備?
您可以通過將其與塊設備列表及其 UUID 進行比較來仔細檢查此設備是否存在。您已經用來列出它們的命令很好。設備邏輯由內部
udev
使用blkid
。
- 可以從啟動中安全地刪除它嗎?如果可以,如何?
您可以創建該行的備份副本,
crypttab
然後刪除該行,或者#
在該行的開頭添加一個以將其註釋掉。(我喜歡使用 etckeeper,就像在 /etc 中為各個配置文件設置“系統還原點”一樣 :-)。你必須知道如何使用版本控制系統)。
在研究這個時,我遇到了幾篇描述類似症狀但顯然有不同原因的文章。其中的範例是此部落格條目和 Superuser SE 上的此問題,兩者都將此問題跟踪到 fstab 中的錯誤交換分區/條目。然而,引導日誌的摘錄讓我相信這些與我的特定問題無關。
公平的。這是一個非常密切相關的問題。您有一個列為啟動過程所需的設備。因此,您的引導等待找到它。超時後,設備被認為失敗。
(根據我的文件,啟動過程也應該需要這個設備,這意味著失敗或超時將啟動到
emergency.target
shell,而不是default.target
)。 甚至支持與修改此行為crypttab
相同的命名選項: 、和.fstab``noauto``nofail``x-systemd.device-timeout=...
對於
fstab
條目,systemd 生成.mount
和.swap
單位。對於crypttab
條目,它只生成一個模板.service
單元的實例,systemd-cryptsetup@.service
.該
.device
單元出現在 systemd 中是因為它需要一些東西來表示它正在等待匹配的設備。這是預期的行為。引導日誌,顯示設備超時的啟動作業,然後直接導致引用為 cr_usb-General_USB_Flash_Disk 的設備的加密設置失敗。我不確定這兩者是否有聯繫。
他們是。超時設備的 UUID 與 crypttab 列出的屬於此 USB 快閃記憶體盤的 UUID 相同。編輯:啊,你的意思是啟動緩慢。是的,一點沒錯。
[ TIME ] Timed out waiting for device dev-disk-by\x2duuid-00a69115\x2d956d\x2d41b3\x2d830c\x2d9a3878087d41.device. [DEPEND] Dependency failed for Cryptography Setup for cr_usb-General_USB_Flash_Disk_0349315060001623-0:0-part2.
/etc/crypttab
cr_sda2 UUID=7f99168c-4972-468b-900f-fb5bbfb90e66
cr_usb-General_USB_Flash_Disk_0349315060001623-0:0-part2 UUID=00a69115-956d-41b3-83