Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6543719
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: LINUX

2011-03-10 18:12:06

http://hi.baidu.com/red_woods/blog/item/721676123f5ced56f819b8d5.html

Linux休眠(STD)有shutdown和platform两种方式,platform需要BIOS支持,shutdown不需要。可以休眠到分区或文件,一般用swap来做。

一、休眠到swap分区

1. 准备swap分区,比如 /dev/sda5,将其激活,并加入到/etc/fstab

2. 编辑 /etc/uswsusp.conf
# /etc/uswsusp.conf(8) -- Configuration file for s2disk/s2both
resume device = /dev/sda5
#compress = y
early writeout = y
#image size = 335111045
#RSA key file = /etc/uswsusp.key
#shutdown method = platform
shutdown method = shutdown

3. 编辑 /etc/initramfs-tools/conf.d/resume
RESUME=/dev/sda5

4. 重新生成 /boot/initrd.img
改变以上两个配置文件后,要重新生成 /boot/initrd.img,特别是改变‘resume device’参数后。否则恢复时initrd找不到休眠镜像,并出现“Unable to find swap-space signature”的错误。

二、休眠到swap文件

1. 准备swap文件,比如 /swapfile(不要超过2G),将其激活,并加入到/etc/fstab

2. swap-offset /swapfile
resume offset = 22528 (文件swapfile在文件系统中的偏移量为22528)

3. 编辑 /etc/uswsusp.conf
# /etc/uswsusp.conf(8) -- Configuration file for s2disk/s2both
resume device = /dev/sda2
resume offset = 22528
#compress = y
early writeout = y
#image size = 335111045
#RSA key file = /etc/uswsusp.key
#shutdown method = platform
shutdown method = shutdown

4. 编辑 /etc/initramfs-tools/conf.d/resume
RESUME=/dev/sda2

5. 重新生成 /boot/initrd.img
改变以上两个配置文件后,要重新生成 /boot/initrd.img,特别是改变‘resume device’和‘resume offset’参数后。否则恢复时initrd找不到休眠镜像,并出现“Unable to find swap-space signature”的错误。

PS:与上面两种方法不同,如果系统启动时没有initrd.img,则要把休眠恢复的参数加在grub配置文件的内核参数之后,如加上:
resume=/dev/sda5 (休眠到分区)
OR
resume=/dev/sda2 resume_offset=22528 (休眠到文件)
这时重新生成 /boot/initrd.img的步骤自然也不用了。

三、执行休眠

1. 普通用户要加入/etc/group的'powerdev'组才有执行休眠的权限。

2. 执行休眠的几种方法:
a. echo shutdown > /sys/power/disk; echo disk > /sys/power/state
b. sudo pm-hibernate
c. sudo hibernate-disk
d. 从关机菜单上点“休眠”

P.S.:这篇文章主要是针对搬过“家”,或修改过swap位置的系统来说的,如果是直接安装的系统,休眠功能不需这样的配置,只是启不启用的事情。
阅读(2192) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~