Skip to content
The Chat Archive
gpt-4o-2024-05-13· OpenAI WildChat-4.8M (AI2)

I tried to fully disable hibernation in Debian but stay suspend works. It works, but…

  1. User

    I tried to fully disable hibernation in Debian but stay suspend works. It works, but there is some problems:

    1. When I click "Suspend" button in my desktop environment, it refers me to xorg screensaver screen only;
    2. When I close laptop lid, Debian doesn't go to suspend mode;
    3. I don't understand what difference between suspend and sleep modes. When I say "suspend" I mean mode in which operating system stay in RAM and wait. Is it right?

    Please help me to find mistakes in my config files and fix it. Also tell which systemd tasks I should mask and not. There is 3 points I wanna reach:

    1. Fully disable and deny hibernation in Debian;
    2. Make pressing power button is ignored;
    3. Make laptop go to sleep mode when lid is closed;
    4. Leave sleep mode when lid is open;
    5. Go to sleep mode after idle of 15 minutes;

    There is my configuration files:

    /etc/systemd/logind.conf: [Login] #NAutoVTs=6 #ReserveVT=6 #KillUserProcesses=no #KillOnlyUsers= #KillExcludeUsers=root #InhibitDelayMaxSec=5 #UserStopDelaySec=10 HandlePowerKey=ignore HandlePowerKeyLongPress=ignore #HandleRebootKey=reboot #HandleRebootKeyLongPress=poweroff #HandleSuspendKey=suspend #HandleSuspendKeyLongPress=hibernate HandleHibernateKey=ignore HandleHibernateKeyLongPress=ignore #HandleLidSwitch=suspend #HandleLidSwitchExternalPower=suspend #HandleLidSwitchDocked=ignore #PowerKeyIgnoreInhibited=no #SuspendKeyIgnoreInhibited=no #HibernateKeyIgnoreInhibited=no #LidSwitchIgnoreInhibited=yes #RebootKeyIgnoreInhibited=no #HoldoffTimeoutSec=30s IdleAction=suspend IdleActionSec=15min #RuntimeDirectorySize=10% #RuntimeDirectoryInodesMax= #RemoveIPC=yes #InhibitorsMax=8192 #SessionsMax=8192 #StopIdleSessionSec=infinity

    /etc/systemd/sleep.conf: [Sleep] AllowSuspend=yes AllowHibernation=no AllowSuspendThenHibernate=no AllowHybridSleep=no #SuspendMode= #SuspendState=mem standby freeze #HibernateMode=platform shutdown #HibernateState=disk #HybridSleepMode=suspend platform shutdown #HybridSleepState=disk #HibernateDelaySec= #SuspendEstimationSec=60min

    /etc/initramfs-tools/conf.d/resume (I just commented resume entry. Is it ok?): #RESUME=/dev/mapper/swap

    /etc/default/grub: ... GRUB_CMDLINE_LINUX_DEFAULT="quiet nohibernation" ...

  2. Assistant

    Let's address each of your points step by step. You're trying to achieve several configuration objectives on your Debian system:

    1. Fully disable and deny hibernation: This seems to be partially configured, and there's some redundancy. Let's make sure it's consistent.

    2. Make pressing power button is ignored: Your current /etc/systemd/logind.conf configuration achieves this already.

    3. Make laptop go to sleep mode when lid is closed: You need to ensure that the HandleLidSwitch settings in your logind.conf file are set correctly to suspend the system.

    4. Leave sleep mode when lid is open: This generally works out of the box but ensuring the system goes to sleep correctly when the lid is closed will indirectly fix this.

    5. Go to sleep mode after idle of 15 minutes: You have this correctly set up in your logind.conf.

    Let's consolidate these into a single, coherent configuration.

    Step-by-Step Configuration

    1. Fully Disable Hibernation

    • You already have the AllowHibernation=no in your /etc/systemd/sleep.conf.

    • Add noresume to your GRUB configuration to ensure hibernation is disabled at the kernel level. Modify your /etc/default/grub:

      GRUB_CMDLINE_LINUX_DEFAULT="quiet noresume"
      

      Then update your GRUB configuration:

      sudo update-grub
      

      Commenting out the RESUME entry in /etc/initramfs-tools/conf.d/resume is correct. So, that part is fine.

    2. Ignore Power Button Press Your /etc/systemd/logind.conf handles this with the following settings:

    [Login]
    HandlePowerKey=ignore
    HandlePowerKeyLongPress=ignore
    

    3. Make Laptop Go to Sleep Mode When the Lid is Closed Update the relevant settings in /etc/systemd/logind.conf. You need to uncomment and set the following:

    [Login]
    HandleLidSwitch=suspend
    HandleLidSwitchExternalPower=suspend
    HandleLidSwitchDocked=ignore
    

    4. Leave Sleep Mode When Lid is Open There isn't a specific setting required for this. The system typically wakes up upon lid open if it properly suspends on lid close.

    5. Go to Sleep Mode After Idle of 15 Minutes This is already correctly configured in /etc/systemd/logind.conf:

    [Login]
    IdleAction=suspend
    IdleActionSec=15min
    

    Sample Configuration Files

    Here are the final versions of your configuration files with the necessary changes:

    /etc/systemd/logind.conf:

    [Login]
    #NAutoVTs=6
    #ReserveVT=6
    #KillUserProcesses=no
    #KillOnlyUsers=
    #KillExcludeUsers=root
    #InhibitDelayMaxSec=5
    #UserStopDelaySec=10
    HandlePowerKey=ignore
    HandlePowerKeyLongPress=ignore
    #HandleRebootKey=reboot
    #HandleRebootKeyLongPress=poweroff
    #HandleSuspendKey=suspend
    #HandleSuspendKeyLongPress=hibernate
    HandleHibernateKey=ignore
    HandleHibernateKeyLongPress=ignore
    HandleLidSwitch=suspend
    HandleLidSwitchExternalPower=suspend
    HandleLidSwitchDocked=ignore
    #PowerKeyIgnoreInhibited=no
    #SuspendKeyIgnoreInhibited=no
    #HibernateKeyIgnoreInhibited=no
    #LidSwitchIgnoreInhibited=yes
    #RebootKeyIgnoreInhibited=no
    #HoldoffTimeoutSec=30s
    IdleAction=suspend
    IdleActionSec=15min
    #RuntimeDirectorySize=10%
    #RuntimeDirectoryInodesMax=
    #RemoveIPC=yes
    #InhibitorsMax=8192
    #SessionsMax=8192
    #StopIdleSessionSec=infinity
    

    /etc/systemd/sleep.conf:

    [Sleep]
    AllowSuspend=yes
    AllowHibernation=no
    AllowSuspendThenHibernate=no
    AllowHybridSleep=no
    #SuspendMode=
    #SuspendState=mem standby freeze
    #HibernateMode=platform shutdown
    #HibernateState=disk
    #HybridSleepMode=suspend platform shutdown
    #HybridSleepState=disk
    #HibernateDelaySec=
    #SuspendEstimationSec=60min
    

    /etc/default/grub: Add noresume to GRUB_CMDLINE_LINUX_DEFAULT like so:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet noresume"
    

    After editing, remember to update GRUB:

    sudo update-grub
    

    /etc/initramfs-tools/conf.d/resume: Keep this as it is (commented out):

    #RESUME=/dev/mapper/swap
    

    Final Steps

    • Reload systemd configurations and restart systemd-logind:
      sudo systemctl daemon-reload
      sudo systemctl restart systemd-logind
      

    This should bring your system into the desired state. If you face any further issues, check the logs (journalctl -xe) for more detailed error messages and troubleshooting steps.