You are not logged in.

#21 2024-05-29 06:35:01

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

Thanks for the input @B_B - this is your creation and I'd hate to break something. yikes

Bearded_Blunder wrote:

I found hibernate better supported on old hardware than some of the other states. Of course it does require a user has enough swap configured to write the entire content of RAM to, in addition to any of the swap already in use, that'd be fairly easy to script checking...

At first I was toying with the idea of having the script look into the system before choosing what buttons to enable, but see below:

I know if someone uses the defaults in D-I it configures enough, or used to be, all bets are off if they do manual partitioning, I've not done a clean install of the current version to see what it does WRT swap.

On newer hardware ACPI is less flaky than it used to be, I'd beware of simply enabling hybrid sleep without doing some research, though I think Windows 10 & 11 do, not without creating some issues in the case of 10 on old hardware.

If you were going to chance enabling the hibernate button automagically  You'd be wanting to compare the amount of swap & RAM & probably test the content of /sys/power/state includes disk

cat /sys/power/state

Will list the available sleep states the system declares it can do. It does so in words though.

I'm not sure without looking how to twist Linux's tail to tell me if a system supports the "S3" power state though, & my Google-fu is weak tonight, that's the vital one for hybrid-sleep to function, & it's sometimes flaky on older hardware. (At least the sort of 12 to 15 year old hardware I have ready access to).

So it's all so complex and dependent on a user's individual hardware that I came to the conclusion that it's best to disable the doubtful options by default, and let users who wantedhibernate, hybrid-sleep or suspend-then-hibernate on their logout menu to do the tests on their own machine first. With the proposed config file it then becomes very easy to enable them to taste. So the default menu stays just as it is now. I did add suspend-then-hibernate to the CLI options though, without any testing. The current CLI already offers hibernate and hybrid-sleep so we are presuming that users using CLI already know what works for them.

[edit]
Afterthought, with mind on possible tweaks for Carbon, once you start adding buttons the dialogue starts getting a tad wide, might be worth considering a minor tweak to the yad to stack them vertically.
It'd make it more harmonious with the menu system aesthetically, & would make the addition of a potentially uesful cancel option feasible without it becoming a ribbon right across the screen.
[/edit]

Interesting idea - let's give it a try.
It's already very easy to cancel out - Esc or just click somewhere on the desktop - so I don't know how much we need a Cancel button.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#22 2024-05-29 13:41:25

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 1,146

Re: Add Hibernate to bl-exit options?

I think I left off suspend-then-hibernate because it reliably crashed any of the old systems, or VMs running on old host systems I tested on though that was a long time ago & I can't guarantee I remember right. It also needs a setting on the HibernateDelaySec= key which elogind  has in /etc/elogind/sleep.conf & systemd in /etc/systemd/sleep.conf  to specify the delay between the two actions, I've no idea what the default delay is, since the commented out value seems to be unset (nothing, not even 0, no delay? infinite? I'd need a system where it worked at all without failing to wake properly to test.)

I think sleep-then-hibernate is mainly offered because motherboards are capable, it mostly gets used by automatic power management schemes particularly in Microsoft land, where defining a period to remain in sleep for fast wake times, & then hibernate after X minutes is useful as a battery saving/convenience compromise option, or else as an action on laptop lid closure, to give X seconds for a swift change of mind without having to complete dumping RAM to disk & reading it all in again. How useful it is to a user in practice to trigger manually I've no idea, I can't offhand think of a scenario.

Of what's not shown by default, hibernate is the one that's really useful, particularly in the case of laptops.
Predicting if it ought to work seems feasible, the problem is that older hardware, & (some?) virtual machines, have this nasty tendency to appear to hibernate, & then refuse to resume properly, forcing a hard reset & loss of the saved state, obviously including unsaved work.

For anyone who's system won't resume from hibernation, or is configured such that hibernating won't work, then the fix is to visit /etc/systemd/sleep.conf (or its elogind equivalent) uncomment and set the keys "AllowHibernation=no", "AllowSuspendThenHibernate=no", & "AllowHybridSleep=no" that way if attempted they'll throw an error gracefully, rather than trying & potentially losing the user any unsaved changes in documents or other data.  Doing so will also cause xfce4-power-manager to lock the screen & pop up an error message if it attempts to hibernate with those keys set to no.

Last edited by Bearded_Blunder (2024-05-29 13:42:17)


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

#23 2024-05-29 23:45:31

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

^Thanks, more useful info.

Basically, just provide the facility and leave it to the user whether to enable those hibernatey options or not looks increasingly like the way to go.

I think we can have a new thread on hibernation with hints and tips, and with your permission, might copy some of your input here over there.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#24 2024-05-30 01:37:25

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 1,146

Re: Add Hibernate to bl-exit options?

Feel free to make use of any information provided by me wherever it's useful, with the caveat I've been known on occasion to be mistaken or misinformed.

I certainly see where you're coming from with this, BL isn't in the position of Microsoft where they have a certification programme for hardware & can simply enable by default & if it comes to it wring their hands & say things like "You should have bought certified hardware, speak to the manufacturer".

Hibernate with Linux is like eating a bag of mixed sweeties in the dark, only way to know what flavour you have is suck it & see. Newer the hardware, better your chances are, subject to having enough swap.

Certainly some easily accessed guidance how to configure for & test hibernation for users who want it, & how to enable a button on the exit dialogue once they've tested it functions correctly on their system sounds like a good approach.

Last edited by Bearded_Blunder (2024-05-30 01:38:37)


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

#25 2024-06-02 00:05:23

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 1,146

Re: Add Hibernate to bl-exit options?

FWIW all the standard Debian DEs have a hibernate button regardless if the system can or not, & we expose the option (regardless if the system will or not) in the lightdm-gtk-greeter.

This is one case where I wish I was on Windows because powercfg/exe /a returns the available sleep states for the hardware in nice groups of available& not available, & won't let you enable hibernate if it's not supported.

I can't find a reliable way with Linux, & certainly no simple command, the one situation where Windows is more helpful, usually it's the other way round with hardware information/capabilities.

Anyone in a dual boot situation may find that one useful. Or useful to run before nuking Windows.

As to exposing the button automagically, the situation where I'd risk it is if there's enough swap, & /usr/bin/laptop-detect says we're on a laptop, it returns 0 if it thinks we are or 1 if not (2 if you used it wrong) or some nice text if you add the --verbose switch.

There's a useful table here https://help.ubuntu.com/community/SwapF … _I_need.3F showing how much depending on installed RAM, though I'd probably just look for twice RAM up to 8 gigs, 1.5xRAM for 8 & above, & greater than RAM+10% at or above 16, to reduce & simplify the calculations.

Strictly you want at least double ram up to 4G & round(sqrt(RAM))+RAM above, but I'd struggle to get bash to calculate that, last time I tried "sums" in a script was on Gentoo, & they have bc available, which Bunsen doesn't, it's its own package installed size ~250k, pulls in nothing else here.


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

#26 2024-06-03 07:10:55

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

Still feel reluctant to get involved in all that calculation. Agree that it's not nice to see "hibernate" on lightdm's logout options regardless of whether it's available. That must affect all distros equally though.

Bearded_Blunder wrote:

There's a useful table here https://help.ubuntu.com/community/SwapF … _I_need.3F showing how much depending on installed RAM, though I'd probably just look for twice RAM up to 8 gigs, 1.5xRAM for 8 & above, & greater than RAM+10% at or above 16, to reduce & simplify the calculations.

Strictly you want at least double ram up to 4G & round(sqrt(RAM))+RAM above...

I thought equal-to-RAM (or a little bit more to be on the safe side) was considered enough swap to hibernate. What data other than what's in memory is going to be stored? And in fact the portion of the data in RAM that actually needs to be saved is usually rather less, because a lot of it can be safely thrown away, but exactly what portion that is is so much effort to figure out that it's not worth it.

...but I'd struggle to get bash to calculate that, last time I tried "sums" in a script was on Gentoo, & they have bc available, which Bunsen doesn't, it's its own package installed size ~250k, pulls in nothing else here.

There is a Debian package bc, does that not do what you'd need?


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#27 2024-06-03 10:19:31

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 1,146

Re: Add Hibernate to bl-exit options?

johnraff wrote:

I thought equal-to-RAM (or a little bit more to be on the safe side) was considered enough swap to hibernate. What data other than what's in memory is going to be stored?

It is enough on a system with plenty of RAM. The issue happens if someone has a low RAM system & a ton of stuff open, at which point there's potentially a lot of paged out memory already occupying swap, & you need space to store what's in ram in addition to what's already paged out.

That problem gets obviated with the Windows approach to hibernation, matters not how much pagefile (swap) is in use, hibernate copies RAM to it's own dedicated space guaranteed to not be in use.

As for the calculation, there is indeed a small package called bc which could do the sums as part of a script, but it's not included in a standard Debian or Bunsen system it's not on the system for any such script to use, it'd need adding to the depends of whatever package the checking script shipped in.

Agree that it's not nice to see "hibernate" on lightdm's logout options regardless of whether it's available. That must affect all distros equally though.

It even affects most Debian DE's, it's the commonest choice of display manager & the gtk-greeter is also the most commonly used. Looking to see if that menu is configurable, or if it is in an alternative greeter, is somwhere on my to do list, if it doesn't fall off or get too buried.


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

#28 2024-06-04 04:20:41

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,553
Website

Re: Add Hibernate to bl-exit options?

Bearded_Blunder wrote:
johnraff wrote:

I thought equal-to-RAM (or a little bit more to be on the safe side) was considered enough swap to hibernate. What data other than what's in memory is going to be stored?

It is enough on a system with plenty of RAM. The issue happens if someone has a low RAM system & a ton of stuff open, at which point there's potentially a lot of paged out memory already occupying swap, & you need space to store what's in ram in addition to what's already paged out.

If the limit to what might already have been paged out is the size of the swap partition, then the total needed to hibernate becomes ${RAM}+${swap} which is more than we have available by definition! I need to read up a bit more about swap - I was under the impression that in the process of hibernation the paged-out data would be written back to the hard disk before storing the content of RAM.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#29 2024-06-04 04:32:36

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 1,146

Re: Add Hibernate to bl-exit options?

The amount likely to be used (stuff actually paged out) is limited on a system with enough RAM to begin with, shouldn't be more actually occupied  than the advised "without hibernation" amount in the linked page i.e. round(sqrt(RAM)) so + RAM then becomes enough with, except for machines without much to begin with, which page more out.

You want to be totally safe, go old-school, amount of swap =2xRAM, that level is pretty well guaranteed to be safe, but it's wasteful of disk space on systems with lots of RAM that are unlikely to page much out to swap anyway.


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

Board footer

Powered by FluxBB