Debian 10 falls asleep while coping files to it (network).

If none of the more specific forums is the right place to ask

Debian 10 falls asleep while coping files to it (network).

Postby millusions » 2020-06-14 08:56

I have Debian 10 with lxde and i'm trying to get my head around sleep assertions.
its a headless mini-itx i3 10TB designated to network backups, lxde is there only to run No-Machine client, there's no keyboard nor mouse.
underneath lxde is openmediavault 5 as lxde doesnt interfere with OMV. I can ditch OMV it's not a big issue.
Unfortunately a google search is not really helping in this instance - could really use help.

i have set power setting in lxde to suspend after 30 minutes and then i run a rsync job to backup some stuff, around 200GB and the box went to sleep.
I turned sleep to never for now.

how does one configure triggers that prevent system sleep? is systemd-inhibit the only way? it's kinda hard to run systemd-inhibit when it just serves and stores files.
I still have to configure wake on U (ethtool -s enp2s0 wol u), if wake on network traffic is configured will it keep machine awake?

on a Mac for example, file copy action creates an assertions which keeps the computer awake until it's done


osx 10.13.6 example:
pmset -g assertions
2020-06-14 19:18:35 +1000
Assertion status system-wide:
BackgroundTask 0
ApplePushServiceTask 0
UserIsActive 1
PreventUserIdleDisplaySleep 0
PreventSystemSleep 0
ExternalMedia 0
PreventUserIdleSystemSleep 1
NetworkClientActive 0
Listed by owning process:
pid 1066(Path Finder): [0x0000047600018364] 00:00:06 NoIdleSleepAssertion named: "Path Finder operation is in progress."
pid 103(hidd): [0x0000001300098200] 00:00:00 UserIsActive named: "com.apple.iohideventsystem.queue.tickle.4294969000.3"
Timeout will fire in 540 secs Action=TimeoutActionRelease
Kernel Assertions: 0xc=USB,BT-HID
id=500 level=255 0x4=USB mod=1/1/70, 10:00 am description=com.apple.usb.externaldevice.1d100000 owner=IOUSBHostDevice
id=503 level=255 0x8=BT-HID mod=1/1/70, 10:00 am description=com.apple.driver.IOBluetoothHIDDriver owner=AppleBluetoothHIDKeyboard
Idle sleep preventers: IODisplayWrangler
User avatar
millusions
 
Posts: 58
Joined: 2014-10-05 14:02

Re: Debian 10 falls asleep while coping files to it (network

Postby LE_746F6D617A7A69 » 2020-06-14 10:01

I'm assuming that You have already seen this:
https://wiki.archlinux.org/index.php/Wake-on-LAN

IMO, the simplest solution would be to write some script which will monitor network traffic on the host side, using netstat or whatever.
Such script could conditionally call systemd-inhibit to prevent system sleep if the traffic is above defined level or if there are active connections on a given port.

In any case however, logic races are unavoidable: f.e. if You will try to connect while the sleep timeout period have just expired.
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 340
Joined: 2020-05-03 14:16

Re: Debian 10 falls asleep while coping files to it (network

Postby millusions » 2020-06-16 08:41

ok. thanks for reply.
arch has a great wiki, but debian wiki is also good

it's a little bit crazy that machine falls asleep bar keystrokes.

i guess OSX spoilt me with the pmset utility. i guess turn the machine on and forget about it is not really a Linux approach unless it's on 24/7
User avatar
millusions
 
Posts: 58
Joined: 2014-10-05 14:02

Re: Debian 10 falls asleep while coping files to it (network

Postby Head_on_a_Stick » 2020-06-16 09:50

millusions wrote:i guess turn the machine on and forget about it is not really a Linux approach unless it's on 24/7

Read LE_746F6D617A7A69's reply again, they have told you how to inhibit the shutdown.

See also https://www.freedesktop.org/software/sy ... hibit.html
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12484
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Debian 10 falls asleep while coping files to it (network

Postby millusions » 2020-06-16 10:45

thanks.

i thought my reply suggests i have read the reply.

it's a little primitive for an OS to have to rely on such mechanisms.

not exactly rocket science - hey, there's network activity why are we going to sleep?

alternative is spending an afternoon or two for such a basic function.

Linux is free, but time is not.
User avatar
millusions
 
Posts: 58
Joined: 2014-10-05 14:02

Re: Debian 10 falls asleep while coping files to it (network

Postby LE_746F6D617A7A69 » 2020-06-16 13:01

millusions wrote:it's a little primitive for an OS to have to rely on such mechanisms.

not exactly rocket science - hey, there's network activity why are we going to sleep?
You're missing the point, which is: there's no one size which fit them all.

First, You have to define the "network activity":
- should NTP protocol prevent system sleep? - obviously not.
- should open SSH connection prevent system sleep? - I would say, it depends - for security reasons, You may wish to drop such connections after some period of inactivity.

millusions wrote:alternative is spending an afternoon or two for such a basic function.
IMO it should take no more than 2-3 hours, including testing -> but You can have a functionality which is tailored to Your specific system/network configuration.

millusions wrote:Linux is free, but time is not.
Linux is more like a toolbox, and Debian is an "Universal Operating System" -> You can have the functionality You need, but it requires a little effort.
You're trying to built NAS-like system using Debian as a base OS -> maybe You should start with f.e. FreeNAS, where all the NAS-specific functionalities are already implemented.
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 340
Joined: 2020-05-03 14:16

Re: Debian 10 falls asleep while coping files to it (network

Postby Head_on_a_Stick » 2020-06-16 18:55

millusions wrote:not exactly rocket science

It certainly isn't:
Code: Select all
systemd-inhibit rsync $source $destination
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12484
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Debian 10 falls asleep while coping files to it (network

Postby millusions » 2020-06-16 21:40

thanks guys!

i'm just surprised, but appreciate your input..

this will all make more sense when i have more free time and I'll have a crack at it

systemd-inhibit rsync $source $destination
sounds simple, but the rsync happens on a different machine :)

FreeNas is a good idea, even started reading some BSD books, but decided I'll stick to what i know, which is Debian (just never really worried about things like sleep and energy usage)

i'll see if i can have it stay awake based on samba traffic on the weekend.
User avatar
millusions
 
Posts: 58
Joined: 2014-10-05 14:02

Re: Debian 10 falls asleep while coping files to it (network

Postby millusions » 2020-06-16 22:11

i should add,
in OSX having a share mounted on remote machine is enough to keep it awake until it's unmounted or corresponding process killed.

i might email Linus about that he he
User avatar
millusions
 
Posts: 58
Joined: 2014-10-05 14:02

Re: Debian 10 falls asleep while coping files to it (network

Postby Head_on_a_Stick » 2020-06-17 08:01

millusions wrote:systemd-inhibit rsync $source $destination
sounds simple, but the rsync happens on a different machine :)

https://wiki.debian.org/Suspend#Disable ... ibernation
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12484
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Debian 10 falls asleep while coping files to it (network

Postby LE_746F6D617A7A69 » 2020-06-17 13:01

millusions wrote:i might email Linus about that he he

Wrong address ;)

It's the systemd which is responsible for handling power states (power-off / hibernation / sleep)
Systemd provides logind interface/daemon, which should be used by the applications to prevent system sleep when needed.
Apparently, Samba / OMV don't use this functionality (at least not by default), and this is the source of Your problem.

Here is one of possible solutions for samba: dontkillsamba.service

This method might be better than My solution (continuous network monitoring), because the script is executed only once, just before entering the sleep state. (although continuous monitoring gives more flexibility)

One more thing: It's not always the best idea to allow system sleep state - there's an alternative solution:
You may put the HDD to sleep and lower the CPU clocks instead (*) -> this completely eliminates the problems exposed by WOL method, but obviously power savings are much smaller in such case.

(*) For this, You'll need cpufrequtils, smartctl and hdparm packages
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 340
Joined: 2020-05-03 14:16

Re: Debian 10 falls asleep while coping files to it (network

Postby arzgi » 2020-06-17 14:45

LE_746F6D617A7A69 wrote:
(*) For this, You'll need cpufrequtils, smartctl and hdparm packages


smartctl is included in smartmontools, it has not an own package.
arzgi
 
Posts: 639
Joined: 2008-02-21 17:03
Location: Finland

Re: Debian 10 falls asleep while coping files to it (network

Postby LE_746F6D617A7A69 » 2020-06-17 15:13

arzgi wrote:smartctl is included in smartmontools, it has not an own package.
... argh, My bad :D
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 340
Joined: 2020-05-03 14:16

Re: Debian 10 falls asleep while coping files to it (network

Postby CwF » 2020-06-17 15:31

LE_746F6D617A7A69 wrote: You'll need cpufrequtils,

cpufrequtils is somewhat generation specific. linux-cpupower is an alternative. The best solution is a fully implemented and tweaked bios, all mine have clock and power controls that shape cpu use better. Keep in mind for some applications damanding response a high idle/high clock can consume as little as low idle/low clock while performing much better. 'Niceness' is also a concept to consider.

Personally I think on/off cycles are the worst for wear-n-tear. My dual Xeons idle at the rate of a penny an hour. If I'm going to use it again in two hours, that 2 cents saved is a false economy.

On hard drives just make sure they are on a capable controller and use a hardware switch.
CwF
 
Posts: 762
Joined: 2018-06-20 15:16

Re: Debian 10 falls asleep while coping files to it (network

Postby millusions » 2020-06-19 23:24

hello again,

i definitely dont want cpufreq and stuffs, it's already installed etc. penny an hour is nothing but then when you multiply it - it becomes something.
i'm too embarassed to say how many computers are here :)
do you know how many watts your dual xeons are pulling?

please help me understand when you say systemd is responsible for power-off /hibernation and sleep, isn't that system wide? when i run 'sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target' as suggested by Head_on_a_Stick, which is gold because i can ssh that, but lxde power control panel does not reflect this change. How is that possible? if OMV is not using this functionality then what is it using? it has some wake on lan and sleep modules

i think i'll need to hit the books and read up on systemd

ive added this service:
[Unit]
Description=Inhibit suspend in case of samba activity
Before=sleep.target

[Service]
Type=oneshot
ExecStart=/usr/bin/sh -c "! smbstatus -nb | tail -n +5 | grep -q '^[0-9]*'"

[Install]
RequiredBy=sleep.target

and

[Install]
RequiredBy=sleep.target

[Unit]
Description=Check for running SSH sessions and, if any, inhibit sleep
Before=sleep.target

[Service]
Type=oneshot
ExecStart=/usr/bin/sh -c ‘! who | grep -qv :0’

[Install]
RequiredBy=sleep.target


quick test and it seems to be working
User avatar
millusions
 
Posts: 58
Joined: 2014-10-05 14:02

Next

Return to General Questions

Who is online

Users browsing this forum: No registered users and 14 guests

fashionable