rub*_*bik 9 linux hibernate systemd
使用 休眠后systemctl hibernate,系统会像关机一样正常启动。我在内核行中有resume参数,在mkinitcpio.conf中有resume钩子
这些是相关的内核消息:
$ dmesg | grep -i swap
[ 0.000000] Command line: initrd=\initramfs-linux.img root=/dev/sda2 rw resume=/dev/sda4
[ 0.000000] Kernel command line: initrd=\initramfs-linux.img root=/dev/sda2 rw resume=/dev/sda4
[ 0.350295] PM: Checking hibernation image partition /dev/sda4
[ 8.776686] Adding 8191996k swap on /dev/sda4. Priority:-1 extents:1 across:8191996k FS
$ dmesg | grep -i hibern
[ 0.350295] PM: Checking hibernation image partition /dev/sda4
[ 0.350301] PM: Hibernation image not present or could not be loaded.
Run Code Online (Sandbox Code Playgroud)
所以唯一剩下的可能性是systemctl 没有写入磁盘。事实上,当我运行命令时,屏幕首先会变黑几秒钟,然后我可以再次看到我的终端,最后它会自行关闭。
我读到 pm-utils 不能很好地与 systemd 配合使用,所以我不想切换到那些。有什么建议?
谢谢!
要详细说明@AdrianRatnapala 的评论,您必须:
找到您的交换分区的 uuid。假设分区是sdb3,那么
$ ls -l /dev/disk/by-uuid/ | grep sdb3
lrwxrwxrwx 1 root root 10 ???. 9 08:59 1dd7e123-1f82-45f0-a202-0ff3ea6f081a -> ../../sdb3
Run Code Online (Sandbox Code Playgroud)打开/etc/default/grub,找到以 开头的行GRUB_CMDLINE_LINUX_DEFAULT="。在引号之间添加resume=/dev/disk/by-uuid/your-swap-uuid。举个例子:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=/dev/disk/by-uuid/1dd7e123-1f82-45f0-a202-0ff3ea6f081a"
Run Code Online (Sandbox Code Playgroud)update-grub