休眠状态成功
Tofloor
poster avatar
VI~TONISEN
deepin
2018-10-31 19:43
Author
本帖最后由 toni 于 2018-10-31 15:17 编辑

因为我已经有休眠文件了,所以如果没有休眠文件参照简书操作。
1.安装和配置uswsusp:
1.1)安装uswsusp:
终端执行 sudo apt install uswsusp
1.2)配置uswsusp:

终端执行 sudo dpkg-reconfigure -pmedium uswsusp,然后会出现如下提示框:
此处选择你的swap文件,我这里是/swapfile这个文件
密码根据需要选择(开启加密功能之后休眠时间会增加,如果选择是:我的电脑会导致休眠失败,错误未知)。
1.3)对uswsusp进行进一步配置
    配置文件/etc/uswsusp.conf内容如下所示:这是系统默认的配置。(默认就行,不用操作)
“resume offset = 34816”是交换文件实际存放的地方。你可以终端sudo swap-offset /swapfile获得这个值
“resume device”必须是分区,不是文件。如/dev/sda1
之后:
终端执行 sudo update-initramfs -u

2.默认启动的配置:
为了让系统启动时加载swapfile文件。对/etc/default/grub文件中的设置进行修改:
GRUB_CMDLINE_LINUX_DEFAULT ="resume=/dev/sda1 quiet"
其中“/dev/sda1”是交换文件所在的分区。
终端执行sudo update-grub

测试下系统休眠:
sudo s2disk


3.做个弹窗。效果如图。



这时使用的方法是:polkit 。
3.1)配置文件
      以deepin的/usr/share/polkit-1/actions/com.deepin.repair-tools.policy文件为例
         
         做些修改如图:
             /usr/share/polkit-1/actions/com.s2disk.policy
         
   3.2)新建文件:/usr/bin/s2disk-pkexec   ,内容如下:
         #!/bin/sh
        pkexec "/usr/sbin/s2disk" "$@"

   3.3)对文件/usr/bin/s2disk-pkexec , 加运行权限之后,测试下,终端输入:s2disk-pkexec,如图:



4.建立开始菜单快捷方式。
在/usr/share/applications 文件夹中,新建一个s2disk-pkexec.desktop文件,图标在网上自己找。如图:


测试下电脑休眠:点击图标


如果点击后出现弹窗,输入密码,进入休眠状态,一切正常OK(缺点是开机时不用输入密码,直接进入桌面).
Reply Favorite View the author
All Replies
1 / 2
To page
aida
deepin
2018-10-31 21:31
#1
666 支持原创!
后面我们一定会加进去的!

请给我们的开发小哥哥一首歌的时间!
Reply View the author
abc
deepin
2018-10-31 21:54
#2

这个功能可以加到系统里面,对于那些想省电,但是不想第二天重新打开程序的用户很重要
Reply View the author
Comments
jone_jys
2019-03-24 20:48
嗯!很赞!机械盘尤其有用
VI~TONISEN
deepin
2018-10-31 21:55
#3
Reply View the author
qq420100523
deepin
2018-10-31 22:51
#4
支持加入系统功能
Reply View the author
137******47
deepin
2018-10-31 22:53
#5
https://bbs.deepin.org/post/170386
这个功能可以加到系统里面,对于那些想省电,但是不想第二天重新打开程序的用户很重要 ...

绝对支持,希望加进去呀  https://bbs.deepin.org/user/101846
Reply View the author
临之
deepin
2018-10-31 23:11
#6
GRUB_CMDLINE_LINUX_DEFAULT ="resume = /dev/sda1 quiet"
resume后面的等号前后不能有空格

另外,恢复后无法进入桌面,黑屏,也无法进入其他tty
Reply View the author
whoam1
deepin
2018-10-31 23:29
#7
运行权限那里没有中文,好像policy文件白写了,用的systemctl hibernate这个命令.
Reply View the author
VI~TONISEN
deepin
2018-10-31 23:34
#8
https://bbs.deepin.org/post/170386
GRUB_CMDLINE_LINUX_DEFAULT ="resume = /dev/sda1 quiet"
resume后面的等号前后不能有空格

我的一切正常,编辑文档时是多打了空格,你看下具体原因。我的唤醒正常,就是直接进入桌面了,另外,我把内核已经更新到了4.19,要不你尝试换一下内核,
Reply View the author
临之
deepin
2018-10-31 23:37
#9
https://bbs.deepin.org/post/170386
我的一切正常,编辑文档时是多打了空格,你看下具体原因。我的唤醒正常,就是直接进入桌面了,另外,我把 ...

好的,十分感谢分享和回复!

我的是工作电脑,恢复后直接进入桌面,不用密码,有点不合适。暂时不再尝试了。
Reply View the author
137******47
deepin
2018-11-01 18:26
#10
太牛了,心情莫名的激动。
Reply View the author
海天鹰
deepin
2018-11-01 18:38
#11
用户又给官方 pull request 了
Reply View the author
Daryl Xu
deepin
2018-11-12 04:21
#12
本帖最后由 hyikesong 于 2018-11-11 20:23 编辑
https://bbs.deepin.org/post/170386
好的,十分感谢分享和回复!

我的是工作电脑,恢复后直接进入桌面,不用密码,有点不合适。暂时不再尝试 ...

有解决办法的,思路就是,在锁定屏幕之后再执行这个休眠操作。
下面给出一个解决办法。
dde-lock &                                              # 在后台执行锁屏动作
sleep 3                                                     # 确保锁屏动作完成,避免开机的时候锁屏还没有完成
sudo echo "你的密码"|sudo -S s2disk  # 执行休眠操作
希望作者也可以把这个整理进去@toni
Reply View the author
Daryl Xu
deepin
2018-11-12 04:27
#13
https://bbs.deepin.org/post/170386
运行权限那里没有中文,好像policy文件白写了,用的systemctl hibernate这个命令. ...

有swap分区这个命令是好使的,如果是用swapfile就不好使了
Reply View the author
Daryl Xu
deepin
2018-11-12 04:30
#14
https://bbs.deepin.org/post/170386
666 支持原创!
后面我们一定会加进去的!

一首歌,我的歌单都循环完了
Reply View the author
ylxdxx
deepin
2018-11-16 18:51
#15
请问一下,我已有swap分区,现在是15.8,而/etc/default/grub里面有两个GRUB_CMDLINE_LINUX_DEFAULT选项
  1. # If you change this file, run 'update-grub' afterwards to update
  2. # /boot/grub/grub.cfg.
  3. # For full documentation of the options in this file, see:
  4. #   info -f grub -n 'Simple configuration'

  5. GRUB_DEFAULT=0
  6. GRUB_TIMEOUT=5
  7. GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
  8. GRUB_CMDLINE_LINUX_DEFAULT="quiet"
  9. GRUB_CMDLINE_LINUX=""

  10. # Uncomment to enable BadRAM filtering, modify to suit your needs
  11. # This works with Linux (no patch required) and with any kernel that obtains
  12. # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
  13. #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

  14. # Uncomment to disable graphical terminal (grub-pc only)
  15. #GRUB_TERMINAL=console

  16. # The resolution used on graphical terminal
  17. # note that you can use only modes which your graphic card supports via VBE
  18. # you can see them in real GRUB with the command `vbeinfo'
  19. #GRUB_GFXMODE=640x480

  20. # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
  21. #GRUB_DISABLE_LINUX_UUID=true

  22. # Uncomment to disable generation of recovery mode menu entries
  23. #GRUB_DISABLE_RECOVERY="true"

  24. # Uncomment to get a beep at grub start
  25. #GRUB_INIT_TUNE="480 440 1"
  26. # Generated by deepin-installer
  27. GRUB_BACKGROUND="/boot/grub/themes/deepin/background.png"
  28. GRUB_CMDLINE_LINUX_DEFAULT="splash quiet"
  29. GRUB_DEFAULT=0
  30. GRUB_DISTRIBUTOR="`/usr/bin/lsb_release -d -s 2>/dev/null || echo Deepin`"
  31. GRUB_THEME="/boot/grub/themes/deepin/theme.txt"
  32. GRUB_TIMEOUT=5
  33. GRUB_GFXMODE=1024x768
Copy the Code

修改加resume=/dev/sda5 quiet均无效,该怎么修改呀?
Reply View the author
湘巴佬儿
deepin
2018-11-16 21:05
#16
https://bbs.deepin.org/post/170386
666 支持原创!
后面我们一定会加进去的!

哈哈,很期待。

我口水都已经叫干啦
Reply View the author
湘巴佬儿
deepin
2018-11-16 21:10
#17
https://bbs.deepin.org/post/170386
有swap分区这个命令是好使的,如果是用swapfile就不好使了
安装系统时已分swap分区后不能休眠的情况下,修改grub配置文件即可。
打开如下路径修改: /etc/default/grub

将其:GRUB_CMDLINE_LINUX_DEFAULT="splash quiet"
改为:GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda5 quiet"其中“/dev/sda5”为swap分区

修改完成后,执行命令更新启动器:终端中输入:sudo update-grub


哈哈哈,还是你之前告诉我的这个方法最简单啦!
https://bbs.deepin.org/post/144256
74# 我置顶啦!

Reply View the author
湘巴佬儿
deepin
2018-11-16 21:14
#18
https://bbs.deepin.org/post/170386
请问一下,我已有swap分区,现在是15.8,而/etc/default/grub里面有两个GRUB_CMDLINE_LINUX_DEFAULT选项

...
GRUB_CMDLINE_LINUX_DEFAULT="splash quiet"


改这一行吧!确认下你的SWAP分区是不是sda5呀。。。
Reply View the author
kevinlong
deepin
2018-11-16 21:56
#19
我的8G内存, 没有安装swap分区, 能安装休眠功能吗?
之前在win10, 常使用这个功能
Reply View the author
14******70@qq.com
deepin
2018-11-16 22:22
#20
支持原创! 希望官方下个版本能够原生支持
Reply View the author
1 / 2
To page