背景故事
我跟着这个答案是关于如何启用休眠模式两个月前,它就成功了。正如我在如何在休眠后恢复 Ubuntu 18.04第一次安装时成功了,但重新安装后就不行了。
异种善意地指出ubuntu wiki 上一般有用的文章。
恢复时死机、空白或黑屏 在某些情况下,计算机可以正常休眠,并恢复无问题,但唤醒时屏幕会变黑。换句话说,计算机运行正常,但显示屏似乎死机了。
他们建议添加 模式设置在 。
GRUB_CMDLINE_LINUX_DEFAULT
/etc/default/grub
休眠功能有效。有时笔记本电脑会自动唤醒,但联想已在最新的 BIOS 和固件更新中解决了此类问题。
然后我意识到我声音问题.我第一次发现一个修复程序反过来破坏了我的亮度键然后当我发现声音和亮度键在全新安装的情况下完美地工作时,我撤消了它。nomodeset 是罪魁祸首。
所以现在我又回到了冬眠的起点。或者,你会这么认为。但实际上,我的情况比以前更糟:如何在休眠后恢复 Ubuntu似乎休眠部分起作用了,而恢复部分却没有。
问题陈述
当我跑步sudo systemctl hibernate
或sudo pm-hibernate
笔记本电脑关机时。合上盖子并重新打开确实会重新启动,但就像重新启动一样,它会将我带到 grub 菜单,而不是像以前一样恢复我的会话。
测试
内核网站指出可以使用此代码片段调试休眠问题
# echo devices > /sys/power/pm_test # echo platform > /sys/power/disk # echo disk > /sys/power/state
使用其中一个选项
冰箱
测试进程冻结
设备
测试进程冻结和设备暂停
平台
测试进程冻结、设备挂起以及平台全局控制方法 [1]
处理器
测试进程的冻结、设备的暂停、平台全局控制方法 [1] 以及非启动 CPU 的禁用
核
测试进程的冻结、设备的暂停、平台全局控制方法[1]、非启动 CPU 的禁用以及平台/系统设备的暂停
[1] (1, 2, 3) 平台全局控制方法仅在 ACPI 系统上可用,并且仅在休眠模式设置为“平台”时进行测试
他们说这只适用于编译的内核,CONFIG_PM_DEBUG
但我认为对我来说情况确实如此,因为该文件/sys/power/pm_test
存在。
root@motorbrot:~# echo freezer > /sys/power/pm_test
root@motorbrot:~# echo disk > /sys/power/state
## results in a short freeze of the laptop
root@motorbrot:~# echo devices > /sys/power/pm_test
root@motorbrot:~# echo disk > /sys/power/state
## results in a black screen for a few seconds. Power Button LED stays on. Then screen turns back on.
root@motorbrot:~# echo platform > /sys/power/pm_test
root@motorbrot:~# echo disk > /sys/power/state
## takes longer than before until the screen turns dark, otherwise the same behaviour as with the "devices" test.
root@motorbrot:~# echo processors > /sys/power/pm_test
root@motorbrot:~# echo disk > /sys/power/state
## nothing noticeably different to the previous two tests
root@motorbrot:~# echo core > /sys/power/pm_test
root@motorbrot:~# echo disk > /sys/power/state
## Again nothing new. The screen turns dark, takes a moment, turns on again.
我将这些结果解释为“所有测试成功”。
但是,有一个日志文件/var/crash/susres.2020-06-08_17:46:27.952596.crash
。它要么来自我上次实际运行休眠模式的时间,要么来自“设备”测试。它以
ProblemType: KernelOops
Annotation: This occurred during a previous hibernation, and prevented the system from resuming properly.
Architecture: amd64
Date: Mon Jun 8 17:46:27 2020
DistroRelease: Ubuntu 18.04
ExecutablePath: /usr/share/apport/apportcheckresume
ExecutableTimestamp: 1589407934
Failure: hibernate/resume
InterpreterPath: /usr/bin/python3.6
Package: linux-image-5.3.0-53-generic 5.3.0-53.47~18.04.1
引领
看起来不错。最后一个问题,既然它能正常工作了,那么休眠时电源按钮 LED 灯表示什么?完全关闭?变暗?“呼吸”?– xenoid 3 月 19 日 20:07
@xenoid 它闪烁两次短灯、一次长灯、三次短灯,然后像其他灯一样保持熄灭状态(除了“我正在充电!”指示灯)– lucidbrot 3 月 19 日 21:07
上次我询问休眠问题时引用的这句话不再适用。目前,电源按钮 LED 在 后会亮一会儿systemctl hibernate
,闪烁两次,然后亮一会儿,然后像关机后一样熄灭。
有systemctl suspend
工作嗎?
当我这样做时,systemctl suspend
电源按钮 LED 进入呼吸模式,屏幕变暗。触摸触控板或单击或打字不会引起任何反应。
关闭并重新打开盖子有效:显示屏重新打开并显示登录屏幕。
系统信息
当我开始写这个问题的时候,我正在
root@motorbrot:~# uname -a
Linux motorbrot 5.3.0-53-generic #47~18.04.1-Ubuntu SMP Thu May 7 13:10:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@motorbrot:~# swapon --show
NAME TYPE SIZE USED PRIO
/dev/nvme0n1p6 partition 18.6G 0B -2
我已经升级到5.3.0-59
内核,但行为仍然是一样的。
/etc/fstab
和朋友
也许这有帮助?
generic@motorbrot:~$ blkid
/dev/nvme0n1p1: LABEL="Recovery" UUID="885E1DE35E1DCAB8" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="2aac3226-cbc2-46d4-9bd4-5ce4695533fc"
/dev/nvme0n1p2: UUID="C21E-C17B" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="beb37963-eae9-4a51-a29e-8850fd392a7f"
/dev/nvme0n1p5: UUID="81e29369-ff69-4424-858c-3489283588d7" TYPE="ext2" PARTUUID="f68aad7f-bfc7-404d-b64b-072ee19d56dd"
/dev/nvme0n1p6: UUID="1ba104f0-35be-42f7-bf71-65e43f6fbcc3" TYPE="swsuspend" PARTUUID="1a651275-5ad0-4ead-9bdf-66e5e9a28b85"
/dev/nvme0n1p7: UUID="d2a1f26d-4442-4eae-9a62-2c176268208d" TYPE="ext2" PARTUUID="d296b2e6-2f0e-4393-9b54-6ed0d11f22ac"
/dev/nvme0n1p8: UUID="003fdbc2-f3fe-4e5d-a945-c2568048589a" TYPE="ext4" PARTUUID="503fddfe-0898-4ed1-a43e-1866a29abd8f"
/dev/nvme0n1p9: LABEL="aquarium" UUID="13317063534776643493" UUID_SUB="8783866549508142042" TYPE="zfs_member" PARTUUID="9bdfdcf4-f586-4603-90fb-a51ed366de3e"
/dev/nvme0n1p10: LABEL="tank" UUID="2491194531467516534" UUID_SUB="922708726245396109" TYPE="zfs_member" PARTUUID="77970109-18ef-4ebd-b49d-6ae04c88aeaa"
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/nvme0n1p8 during installation
# but that was before I moved it over to zfs
#UUID=003fdbc2-f3fe-4e5d-a945-c2568048589a / ext4 errors=remount-ro 0 1
# I haven't specified the zfs volume yet because I'm not sure I'd need it... in fact I don't need it, as proven by usage.
#
# /boot is its own partition distinct from /boot/efi, but for some reason it was not set up correctly, it seems. Trying to fix that now with the following line:
UUID=81e29369-ff69-4424-858c-3489283588d7 /boot ext2 defaults 0 2
# /boot/efi was on /dev/nvme0n1p2 during installation
UUID=C21E-C17B /boot/efi vfat umask=0077 0 1
# Use swap partition instead of swap file
#/swapfile none swap sw 0 0
UUID=1ba104f0-35be-42f7-bf71-65e43f6fbcc3 none swap sw 0 0
我有一个自定义的 grub 菜单项,因为update-grub
使用加密的 zfs 分区生成它失败(这是一个不同的问题,似乎是 update-grub 脚本的一个错误,而不是我当前的问题)。
#/etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Encryptioned Magic 18.04" --id encryptioned-magic-id {
setparams 'Ubuntu'
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
# not needed. because grub has already set its root correctly to that partition(hd0,gpt5).
# but also not harmful.
# Find the /boot partition
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 81e29369-ff69-4424-858c-3489283588d7
else
search --no-floppy --fs-uuid --set=root 81e29369-ff69-4424-858c-3489283588d7
fi
# The relevant part
# nomodeset was for (hopefully) fixing hibernation startup problems where screen stayed black, but I removed it again since it caused sound and brightness problems.
# resume=SWAP-PARTITION-UUID-AS-PER-lsblk is for restoring from swap space after hibernation
# acpi_backlight=video fixed my screen brightness keys, but no longer needed since I removed nomodeset
linux /vmlinuz-5.3.0-59-generic root=ZFS=tank/ds1/u18 ro resume=1ba104f0-35be-42f7-bf71-65e43f6fbcc3
initrd /initrd.img-5.3.0-59-generic
}
地方政府政策工具包
根据建议关于如何启用休眠模式的答案
#/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes
[Enable hibernate to be run via cron]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultAny=yes
输出自update-initramfs -u -k all
generic@motorbrot:~$ sudo update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-5.3.0-59-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p6
I: (UUID=1ba104f0-35be-42f7-bf71-65e43f6fbcc3)
I: Set the RESUME variable to override this.
update-initramfs: Generating /boot/initrd.img-5.3.0-53-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p6
I: (UUID=1ba104f0-35be-42f7-bf71-65e43f6fbcc3)
I: Set the RESUME variable to override this.
update-initramfs: Generating /boot/initrd.img-5.3.0-51-generic
I: The initramfs will attempt to resume from /dev/nvme0n1p6
I: (UUID=1ba104f0-35be-42f7-bf71-65e43f6fbcc3)
I: Set the RESUME variable to override this.
输出自update-grub
该device-mapper
问题(如前所述)可能是由于我使用了加密的 zfs 根,并且我通过使用自定义 grub 条目来规避该问题。
generic@motorbrot:~$ sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found theme: /boot/grub/themes/poly-dark/theme.txt
Found linux image: /boot/vmlinuz-5.3.0-59-generic
Found initrd image: /boot/initrd.img-5.3.0-59-generic
Found linux image: /boot/vmlinuz-5.3.0-53-generic
Found initrd image: /boot/initrd.img-5.3.0-53-generic
Found linux image: /boot/vmlinuz-5.3.0-51-generic
Found initrd image: /boot/initrd.img-5.3.0-51-generic
Found linux image: /boot/vmlinuz-4.15.0-101-generic
Found initrd image: /boot/initrd.img-4.15.0-101-generic
device-mapper: reload ioctl on osprober-linux-nvme0n1p10 failed: Device or resource busy
Command failed
Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi
Found Ubuntu 18.04.4 LTS (18.04) on /dev/nvme0n1p8
Adding boot menu entry for EFI firmware configuration
done
问题
我该如何修复这个问题或者如何找出问题所在?最终目标是能够将内存写入交换分区并在休眠后恢复到原来的位置。
编辑(7月14日 - 发布此问题一个月后)
现在正在工作:
systemctl hibernate
从没有 nomodeset 的正在运行的系统到没有 nomodeset 的重新启动的系统都可以正常工作。systemctl hibernate
从没有 nomodeset 的正在运行的系统到有 nomodeset 的重新启动的系统都能正常工作。- 声音和亮度键在两种情况下均可起作用。
我希望这个问题在内核更新中得到修复。我当前的系统信息是
$ uname -a
Linux motorbrot 5.3.0-62-generic #56~18.04.1-Ubuntu SMP Wed Jun 24 16:17:03 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
问题依然存在它是怎样被修复的?如果再次发生该如何处理?