You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Ubuntu 24.04 LTS上启用休眠模式?

如何在Ubuntu 24.04 LTS上启用休眠模式?

Hey there! I totally get how frustrating it is when suspend doesn't cut it and hibernation feels out of reach—especially on a Lenovo ThinkBook. Let's walk through step-by-step fixes to get it working for you.

第一步:检查并配置足够的Swap空间

Hibernation saves your entire RAM content to swap, so you need swap space that's at least as large as your total RAM (or slightly bigger for safety). Here's how to check and adjust it:

  • Run free -h in the terminal to see your total RAM size (look at the Mem: total value).
  • Next, check your current swap with swapon --show. If the swap size is smaller than your RAM, we'll need to resize or create a swap file:
    1. Turn off existing swap: sudo swapoff /swapfile
    2. Delete the old swap file (if it exists): sudo rm /swapfile
    3. Create a new swap file matching your RAM size (replace 16G with your actual RAM size): sudo fallocate -l 16G /swapfile
    4. Set proper permissions for security: sudo chmod 600 /swapfile
    5. Format the file as swap: sudo mkswap /swapfile
    6. Enable the new swap: sudo swapon /swapfile
    7. Make swap permanent by adding this line to /etc/fstab (use sudo nano /etc/fstab to edit):
      /swapfile none swap sw 0 0
      
    Save the file and exit nano (Ctrl+O, Enter, then Ctrl+X).

第二步:配置Grub以支持休眠

We need to tell the kernel where to find the swap space when resuming from hibernation:

  • Get your swap partition's UUID by running blkid | grep swap. You'll see output like /dev/nvme0n1p3: UUID="abc123xyz..." TYPE="swap"—copy that UUID string.
  • Edit the Grub config with sudo nano /etc/default/grub. Find the line starting with GRUB_CMDLINE_LINUX_DEFAULT and add resume=UUID=abc123xyz... (replace with your actual UUID) inside the quotes. For example:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=abc123xyz..."
    
  • Update Grub to apply changes: sudo update-grub

第三步:检查BIOS/UEFI设置

Lenovo laptops often have specific power settings that block hibernation. Reboot your laptop and enter BIOS (usually by pressing F2 or Fn+F2 during startup):

  • Look for Secure Boot and disable it (this can interfere with hibernation on some systems).
  • Find power-related options like Resume from Hibernation or Suspend to Disk and make sure they're enabled.
  • Save changes and reboot into Ubuntu.

第四步:测试休眠功能

Now let's test if hibernation works:

  • Run sudo systemctl hibernate in the terminal. Your laptop should shut down completely.
  • Turn it back on—it should resume exactly where you left off.

If that doesn't work, try installing pm-utils (a power management tool) with sudo apt install pm-utils, then run sudo pm-hibernate to test again.

额外:让合盖触发休眠

If you want your laptop to hibernate when you close the lid:

  • Edit /etc/systemd/logind.conf with sudo nano /etc/systemd/logind.conf.
  • Find the line #HandleLidSwitch=suspend, remove the # and change it to HandleLidSwitch=hibernate.
  • Restart the logind service to apply changes: sudo systemctl restart systemd-logind

Hopefully these steps get hibernation working on your ThinkBook! If you hit any snags, let me know which step failed and we can troubleshoot further.

备注:内容来源于stack exchange,提问作者D'Hyena

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 08:08:13