zoukankan      html  css  js  c++  java
  • Linux 休眠

    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位置的系统来说的,如果是直接安装的系统,休眠功能不需这样的配置,只是启不启用的事情。

  • 相关阅读:
    Navicat Premium 15 永久激活版安装教程
    win10安装redis
    Linux下安装Go环境
    IoT platforms that deserves to be noticed
    TortoiseGit配置
    impot和require区别
    websocket搭建简单的H264实时视频流播放
    应用索引技术优化SQL 语句(Part 3)
    应用索引技术优化SQL 语句(Part 2)
    应用索引技术优化SQL 语句(Part 1)
  • 原文地址:https://www.cnblogs.com/ztguang/p/12647687.html
Copyright © 2011-2022 走看看