linux 电源管理: hibernate实现方法

主要可以参考: https://www.cnx-software.com/2017/08/30/save-power-hibernate-your-embedded-linux-system/

 

 

1. 使能swap模式

 

swap memory

Swap memory is the area on disk that is reserved to be used as extra RAM when your system needs more RAM than what is available. When your embedded Linux system runs out of free memory, then kernel can move some of the inactive pages into swap partition to make free room for active pages in RAM memory. If you plan to use hibernation in your embedded Linux systems, then you swap space have to be at least twice the RAM capacity

2. 使能内核对hibernate 模式支持

 

3.创建swap分区

 

1.以root身份进入控制台(登录系统),输入

# swapoff -a #停止所有的swap分区

2. 用fdisk命令(例:# fdisk /dev/sdb)对磁盘进行分区,添加swap分区,新建分区,在fdisk中用“t”命令将新添的分区id改为82(Linux swap类型),最后用w将操作实际写入硬盘(没用w之前的操作是无效的)。

3. # mkswap /dev/sdb2 #格式化swap分区,这里的sdb2要看您加完后p命令显示的实际分区设备名

4. # swapon /dev/sdb2 #启动新的swap分区

5. 为了让系统启动时能自动启用这个交换分区,可以编辑/etc/fstab,加入下面一行

/dev/sdb2 swap swap defaults 0 0

 

4. 设定hibernate 模式

echo reboot > /sys/power/disk  //保存现场后重启

echo disk > /sys/power/state 

 

5. uboot设置

setenv bootargs 'console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 resume=/dev/mmcblk0p2 resumewait'

系统启动后就会恢复到之前的状态。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值