SOLVED prevent suspend mode when installed on a laptop?

abraham_v

Dabbler
Joined
May 15, 2021
Messages
16
Is there a recommended or standard way to prevent the system TrueNAS scale (BETA-1) is installed on from suspending? I'm testing/experimenting with SCALE installed on a spare laptop, but as soon as I close the lid, the system enters suspend mode and becomes unresponsive. On re-opening the lid, I can see log output which shows the system exiting suspend mode.

To compare, I've installed TrueNAS CORE on the same laptop and have never seen that installation enter any kind of suspend mode - its always responsive over the network.

- Abraham V.

EDIT (2021/August/21): marking thread solved
 
Last edited:

Zain

Contributor
Joined
Mar 18, 2021
Messages
124
You will likely have to get into the BIOS and see what the close lid setting is set to. What is the laptop?
 

abraham_v

Dabbler
Joined
May 15, 2021
Messages
16
The system is a Lenovo y510p = https://www.lenovo.com/ca/en/laptops/lenovo/y-series/y510p/

I do not understand why you suggest the BIOS as a solution. i.e. TrueNAS CORE did not have this issue, so why should it be present for TrueNAS SCALE?

Regardless, I just booted into the BIOS menu to check. Navigated over the different options, but did not find anything specific to closing the laptop lid. :/

-Abraham V.
 

Zain

Contributor
Joined
Mar 18, 2021
Messages
124
I know that some Lenovo lappies have a "flip to boot" option in the BIOS, also accessible from the Vantage app. Wasn't sure if there were other lid options in there. I don't have one to browse through but should be device > device settings?
 

abraham_v

Dabbler
Joined
May 15, 2021
Messages
16
As I mentioned in my earlier reply, there's no such option on this bios. As well, proof of this claim, here is a picture of the Configuration menu in the bios,
20210814_155851.jpg


-Abraham V.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
As I mentioned in my earlier reply, there's no such option on this bios. As well, proof of this claim, here is a picture of the Configuration menu in the bios,
Since "Deep S3 Function" is a sleep mode (that's enabled), perhaps you want to look at changing that.
 

abraham_v

Dabbler
Joined
May 15, 2021
Messages
16
Some good news! I think I found a work-around. Via the web-interface, if I navigate to "System Settings > Shell" and give the following command;

Code:
$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target


It seems to disable suspend+sleep mode. Here is the exact output from my system;

Code:
truenas# sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Created symlink /etc/systemd/system/sleep.target → /dev/null.
Created symlink /etc/systemd/system/suspend.target → /dev/null.
Created symlink /etc/systemd/system/hibernate.target → /dev/null.
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null.
#                                                                                                                                                                                                                               
truenas# 


Now, I will confess that I am not sure if the above has other unwanted side-effects on my TrueNAS server (I do not expect it to!). Will keep running it for a few days to see what happens. (if things look alright, I'll mark this thread as "solved" then)

Since "Deep S3 Function" is a sleep mode (that's enabled), perhaps you want to look at changing that.
I did not realize that S3 was a sleep mode. An internet search reveals to me that it saves power when the system is not plugged into AC power. Which is not the case - the laptop is always plugged into AC power. Additionally, the M2 wifi card from this laptop has been removed; its connected to the network via the ethernet jack.

Still, no harm in disabling that setting. Will do so now. In addition to the `systemctl` command I just ran, it will (hopefully) keep the device network-accessible.

- Abraham V.
 

abraham_v

Dabbler
Joined
May 15, 2021
Messages
16
System is still responsive over the network. so, I think it is safe to conclude that the work-around to disable sleep/suspend works. I just logged into the web interface and saw the following warning;

Code:
24692 SSH login failures:
Aug 20 00:00:00 truenas systemd-logind[2851]: Failed to execute suspend operation: Permission denied
Aug 20 00:00:00 truenas systemd-logind[2851]: Failed to execute suspend operation: Permission denied ... 24688 more ...
Aug 20 00:01:09 truenas systemd-logind[2851]: Failed to execute suspend operation: Permission denied
Aug 20 00:01:09 truenas systemd-logind[2851]: Failed to execute suspend operation: Permission denied
2021-08-21 00:04:00 (America/Los_Angeles)


Which is to be expected, I suppose. Am marking this thread as solved.

EDIT: After making this post, it occurred to me that the warning indicates that log messages are still being thrown out. Deciding to investigate, I entered the shell and ran the following;

Code:
$ journalctl -f


which gives a continous tail output of the systemd logs. To my horror, a *continuous* stream of logs kept coming. That was unacceptable. An internet search led me to this SO answer = https://serverfault.com/a/1045950 which helped. What it suggests is,

To edit the /etc/systemd/logind.conf file, add the following lines,

Code:
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore


and finally to restart the systemd process via;

Code:
$ systemctl restart systemd-logind


which seems to have got the logs under control. (When the logs were continously streaming, my CPU usage was *very* high ... I wish I realised that earlier)


-Abraham V.
 
Last edited:

ikhan

Cadet
Joined
Aug 26, 2022
Messages
1

Hi @abraham_v can you help me understanding the above solution you had? as I am having the same issue with truenas scale and to be honest I don't have any knowledge on codding might be the reason I did not understand the above solution you had​

 
Joined
Aug 4, 2023
Messages
1
For anyone still looking for how to edit the config file, here's how:

type "vim /etc/systemd/logind.conf" into the shell console in truenas
press insert
copy and paste the code referred to in the above posts
press esc
type ":wq!"

Took me a stupid amount of time to remember scale is linux based, smh
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
edit the config file
You're probably in for disappointment at some moment in the future when that change is reverted by a reboot or an update.

I have seen some folks on other sites mentioning that they use a script to replace the file with their own version on startup, which would survive an update.

I'll refrain from comment on the likely issues coming your way from running on very poorly suited hardware. Best of luck to you.
 

gaston_senac

Cadet
Joined
Feb 5, 2019
Messages
2
For anyone still looking for how to edit the config file, here's how:

type "vim /etc/systemd/logind.conf" into the shell console in truenas
press insert
copy and paste the code referred to in the above posts
press esc
type ":wq!"

Took me a stupid amount of time to remember scale is linux based, smh
Yes, I was looking for the same issue and I think the cleanest solution is to follow Debian's Suspend advice.
Just uncomment and change these lines:
Code:
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore

Then run
Code:
systemctl restart systemd-logind.service
or reboot.
 

gaston_senac

Cadet
Joined
Feb 5, 2019
Messages
2
Of course after an update my config is gone :confused:
I've created this script that should do the trick:
/mnt/pool-1/no-suspend

Code:
if ! grep "^HandleLidSwitch=ignore" /etc/systemd/logind.conf >/dev/null
        then echo "HandleLidSwitch=ignore" >> /etc/systemd/logind.conf
fi

if ! grep "^HandleLidSwitchExternalPower=ignore" /etc/systemd/logind.conf > /dev/null
        then echo "HandleLidSwitchExternalPower=ignore" >> /etc/systemd/logind.conf
fi

if ! grep "^HandleLidSwitchDocked=ignore" /etc/systemd/logind.conf > /dev/null
        then echo "HandleLidSwitchDocked=ignore" >> /etc/systemd/logind.conf
fi

And I've added this file as an "Init/Shutdown Script" in the Advanced options, as a "PreInit" script so will be applied just after the first reboot after an update.
 
Top