Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Arch Linux 的休眠设置大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

  https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate_(简体中文) https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate https://wiki.archlinux.org/index.php/Po
@H_673_14@
@H_673_14@

 

https://wiki.archlinux.org/index.PHP/Power_management/Suspend_and_hibernate_(简体中文)
https://wiki.archlinux.org/index.PHP/Power_management/Suspend_and_hibernate
https://wiki.archlinux.org/index.PHP/Power_management
https://wiki.archlinux.org/index.PHP/HP_Compaq_6510b

三种挂起方式
名称 挂起方式 电源状态

  • 1. suspend 挂起,待机,暂停 (str: suspend to RAM)保存到内存 通电 低功耗
  • 2. hibernate 休眠,冬眠 (std: suspend to disk)保存至硬盘swap 断电 关机
  • 3. HybridSleep 混合睡眠 (strd:suspend to both)保存到内存和硬盘 通电 低功耗

睡眠模式,比如笔记本电脑:若电池还有电,就等同于挂起;若电池电量耗尽,则等同于休眠模式。

========================
ArchLiux的休眠功能需要用户设置后才能使用。
这里介绍使用systemd休眠。
需要swap分区或者swap文件,大小要求大于等于系统内存。

==== 1. 在bootloader 中增加resume内核参数
需要添加resume=/dev/sdxY (sdxY 是swap分区的名字) ,让系统在启动时读取swap分区中的内容
$ lsblk
├─sdb6 ... /
└─sdb9 ... [SWAP]
当前使用了grub2作为bootloader,swap的分区是/dev/sda9。
== 1.1 编辑/etc/default/grub文件,在GRUB_CMDLINE_LINUX_DEFAULT中添加resume=/dev/sda9
若原本是: GRUB_CMDLINE_LINUX_DEFAULT=”quiet intel_pstate=enable”
添加后: GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_pstate=enable resume=/dev/sda9"
注:这里的 intel_pstate=enable 只针对intel处理器中SAndyBridge(含IvyBridge)及更新的构架的cpu 

当前系统:
原本是: GRUB_CMDLINE_LINUX_DEFAULT="quiet"
添加后: GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=/dev/sda9"

== 1.2 更新 grub 配置:
备份 grub.cfg 这里有手动添加的启动项目,@H_832_21@menuentry ‘windows2008r2‘ {
set root=(hd0,1)
chainloader +1
}

$ sudo grub-mkconfig -o /boot/grub/grub.cfg

==== 2. 配置 initramfs的resume钩子
== 2.1 添加resume钩子 编辑 /etc/mkinitcpio.conf ,在HOOKS行中添加resume钩子:
若原本是: HOOKS="base udev autodetect modconf block filesystems keyboard fsck"
添加后: HOOKS="base udev resume autodetect modconf block filesystems keyboard fsck"

注意: 如果使用lvm分区,需要将resume放在lvm后面
lvm分区: HOOKS="base udev autodetect modconf block lvm2 resume filesystems keyboard fsck"

当前系统:
原本是: HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)
添加后: HOOKS=(base udev resume autodetect modconf block filesystems keyboard fsck)

== 2.2 重新生成 initramfs 镜像:mkinitcpio -p linux

$ sudo mkinitcpio -p linux
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: ‘default‘
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> StarTing build: 5.0.4-arch1-1-ARCH
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [resume]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> CreaTing gzip-compressed initcpio image: /boot/initramfs-linux.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: ‘fallBACk‘
-> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallBACk.img -S autodetect
==> StarTing build: 5.0.4-arch1-1-ARCH
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [resume]
-> Running build hook: [modconf]
-> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: wd719x
==> WARNING: Possibly missing firmware for module: aic94xx
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> CreaTing gzip-compressed initcpio image: /boot/initramfs-linux-fallBACk.img
==> Image generation successful
$

参照:https://wiki.archlinux.org/index.PHP/Mkinitcpio
==> aic94xx-firmware:适用于AIC94xx驱动程序的Adaptec SAS 44300,48300,58300定序器固件
==> wd719x-firmware:Western Digital WD7193,WD7197和WD7296 SCSI卡的驱动程序
大多数人都没有SAS / SCSI磁盘控制器,因此请忽略这些警告,不要安装这些驱动程序。
这些对任何Arch Linux用户都是有用的,特别是那些没有安装这些固件模块的用户。如果您不使用使用这些固件的硬件,则可以忽略此警告消息。

安装: https://gist.github.com/imrvelj/c65cd5ca7f5505a65e59204f5a3f7a6d
git clone https://aur.archlinux.org/aic94xx-firmware.git
cd aic94xx-firmware
@H_883_61@makepkg -sri
git clone https://aur.archlinux.org/wd719x-firmware.git
cd wd719x-firmware
@H_883_61@makepkg -sri
再mkinitcpio -p linux一次。

=========================
==== 设置低电量自动休眠,用于带有内置电池的设备。
修改/etc/UPower/UPower.conf相关配置.示例,在电量低至%5时自动休眠:
PercentageLow=15          #<=15%低电量
PercentageCritical=10      #<=10%警告电量
PercentageAction=5         #<=5%执行动作(即CriticalPowerAction)的电量
CriticalPowerAction=Hibernate       #(在本示例中是电量<=5%)设备会自动休眠。
##CriticalPowerAction的取值有Poweroff、Hibernate和HybidSleep。

===================

==== 3. 设置盖上笔记本盖子或按下电源键休眠
== 3.1 编辑 /etc/systemd/logind.conf  
盖上盖子休眠,添加HandleLidSwitch=hibernate
按下电源键休眠添加HandlePowerKey=hibernate

== 3.2 执行以下命令使其立即生效:
$ sudo systemctl restart systemd-logind

===================

https://github.com/levinit/itnotes/blob/master/linux/laPTOP笔记本相关.md

#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelaymaxSec=5
#HandlePowerKey=poweroff #按下电源键
#HandleSuspendKey=suspend #按下挂起键HandleSleepKey
#HandleHibernateKey=hibernate #按下休眠键
#HandleLidSwitch=suspend #合上笔记本盖
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore #插上扩展坞或者连接外部显示器情况下合上笔记本盖子
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#Inhibitorsmax=8192
#Sessionsmax=8192

poweroff和halt均是关机(具体实现有区别)
supspend是挂起(暂停),设备通电,内容保存在内存中
hybernate是休眠,设备断电(同关机状态),内容保存在硬盘中
hybridSleep是混合睡眠,设备通电,内容保存在硬盘和内存中
lock是锁屏
kexec是从当前正在运行的内核直接引导到一个新内核(多用于升级了内核的情况下)
ignore是忽略该动作,即不进行任何电源事件响应

@H_673_14@

大佬总结

以上是大佬教程为你收集整理的Arch Linux 的休眠设置全部内容,希望文章能够帮你解决Arch Linux 的休眠设置所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:archlinux休眠设置
猜你在找的Linux相关文章
其他相关热搜词更多
phpJavaPython程序员load如何string使用参数jquery开发安装listlinuxiosandroid工具javascriptcap