Open JustSimplyKyle opened 2 years ago
Sorry, I meant with debug enabled, so running the script directly with at least -vvv
Also, I was just thinking, do you notice anything in the system's logs (maybe the audit log?) about denying permissions to execute systemctl or anything like that?
this includes my computer literally going hibernate, so the pause there is because of that
@JustSimplyKyle seems like the recording is private
Should be fixed now
@JustSimplyKyle I see the same message:
This recorder token belongs to a different user.
https://asciinema.org/a/556975 How 'bout this?
maybe the audit log?
How would i do this? if you mean dmesg
nothing sus came up
https://asciinema.org/a/lgsPjcY9OPccdkHlg6Y57XD3I
I am a having some trouble as well with arch and a swap file.
Completely new to Linux 😔.
https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file
btrfs inspect-internal map-swapfile -r path/to/swapfile
This to get the "resume_offsett"
https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file
btrfs inspect-internal map-swapfile -r path/to/swapfile
This to get the "resume_offsett"
Got this value but am confused as to where to add this as I cannot find initramfs
Being up front, typically I don't like cluttering a thread with multiple unrelated issues, but I'll go with it this time since JustSimplyKyle already started addressing this issue here. In the future, individuals with issues that do not include the same error message or primary concern as the OP should open a new issue so each situation can be focused on and addressed directly.
@mananhiteshkataria the resume=XXX
argument should be specified in your bootloader configuration. If you're using a swap file instead of a swap partition, several filesystems require the use of the resume_offset=
parameter as well for proper resume so the kernel knows where to find the swap file before the filesystem driver is loaded.
If your bootloader is GRUB, the configuration process would be one (or both) of the following:
/etc/default/grub
file:
GRUB_CMDLINE_LINUX_DEFAULT=
or GRUB_CMDLINE_LINUX_DEFAULT=
lines/boot/grub/grub.cfg
, likely by using grub-mkconfig
/boot/grub/grub.cfg
by hand to edit the linux line that loads your kernel to add the required parametersIf you're using one of the several UEFI-specific boot loaders (rEFInd, systemd-boot, etc), you'll need to look into your bootloader's documentation to find out how and where to edit the kernel command line parameters, but the concept is the same.
initramfs is not related to setting up hibernation or configuring the resume=
parameter, but on Arch Linux, initramfs is generated automatically when a new kernel is installed or manually by using the command mkinitcpio
. Please look that up in the Arch wiki or man pages for more details.
maybe the audit log?
How would i do this? if you mean
dmesg
nothing sus came up
You mentioned dmesg
, which is a great source for kernel log messages, but systemd and other system processes often do their logging in ways that are not included in the dmesg
output.
Many system logs are stored under /var/log/
in some way. On older systems, there were several text files in this location that could be viewed with any text editor. On most modern systems, you can view these system log messages with the journalctl
tool.
Audit logs are one of many messages reported there, and would contain reports of system security audit successes and failures (programs trying to do things that the system allowed/prevented them from doing).
My thought is that perhaps something may be indicated there to help us figure out why your systemctl hibernate
is having issues.
From your video, it seems like the script is finding everything perfectly fine in debug mode. What happens differently when you run systemctl hibernate
?
If needed, we could try to make a modified version of this script to record output to a log file when called by systemctl hibernate
so we can see whats going wrong in that situation.
https://asciinema.org/a/557696 After changing the bottom of the script to this
elif [[ $PRE != 0 ]]; then
echo "streb" > /tmp/status
pre_main
there was nothing at /tmp/status my guess is then my system is "haunted" and doesn't want to excute from pre
❯ doas journalctl -b -u hibernate.target
Feb 06 13:45:45 arch systemd[1]: Dependency failed for System Hibernation.
Feb 06 13:45:45 arch systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
Feb 06 13:50:09 arch systemd[1]: Dependency failed for System Hibernation.
Feb 06 13:50:09 arch systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
Feb 06 13:50:34 arch systemd[1]: Dependency failed for System Hibernation.
Feb 06 13:50:34 arch systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
Feb 06 13:51:54 arch systemd[1]: Dependency failed for System Hibernation.
Feb 06 13:51:54 arch systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
Feb 06 13:55:49 arch systemd[1]: Dependency failed for System Hibernation.
Feb 06 13:55:49 arch systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
huh
Feb 06 13:51:54 arch systemd-sleep[28723]: Failed to find location to hibernate to: Function not implemented
Feb 06 13:51:54 arch systemd[1]: systemd-hibernate.service: Main process exited, code=exited, status=1/FAILURE
Feb 06 13:51:54 arch systemd[1]: systemd-hibernate.service: Failed with result 'exit-code'.
Feb 06 13:51:54 arch systemd[1]: Failed to start Hibernate.
Nov 03 17:47:22 arch systemd-sleep[242438]: Entering sleep state 'hibernate'...
wait what?
I made it working by directly telling it to use zram-hibernate
in pre hibernate(and consequenctly post hibernate), but this isn't ideal.(/etc/systemd/system/hibernate-preparation.service
)
[Unit]
Description=Enable swap file and disable zram before hibernate
Before=systemd-hibernate.service
[Service]
User=root
Type=oneshot
ExecStart=/bin/bash -c "/usr/lib/systemd/system-sleep/zram-hibernate pre"
[Install]
WantedBy=systemd-hibernate.service
Interesting partial workaround there by calling it with "pre" in a service. You should also throw in "hibernate" as a second parameter since that's the expected calling convention.
That makes perfect sense though as to why it wasn't working - if it's never getting called with "pre" it will never set up the swap to hibernate into. "post" is used for cleanup and restoration.
I'm not sure why that might be happening though... From the systemd-sleep (8) manpage, it says:
Immediately before entering system suspend and/or hibernation systemd-suspend.service (and the other mentioned units, respectively) will run all executables in /usr/lib/systemd/system-sleep/ and pass two arguments to them. The first argument will be "pre", the second either "suspend", "hibernate", "hybrid-sleep", or "suspend-then-hibernate" depending on the chosen action. [...] Immediately after leaving system suspend and/or hibernation the same executables are run, but the first argument is now "post". All executables in this directory are executed in parallel, and execution of the action is not continued until all executables have finished.
As a workaround, I wonder if we can use the ExecStop to trigger the post event. Try adding these just after the ExecStart line:
RemainAfterExit=1
ExecStop=/bin/bash -c "/usr/lib/systemd/system-sleep/zram-hibernate post hibernate"
That still doesn't explain why it's not being called as the manpage suggests it should though.
echo "${1}" "${2}" "$SYSTEMD_SLEEP_ACTION" > /tmp/aaar
I even made a simpler script, still nothing shows up in /tmp/aaar
I wonder where should I put this in?
RemainAfterExit=1 ExecStop=/bin/bash -c "/usr/lib/systemd/system-sleep/zram-hibernate post hibernate"
Try putting that in the [Service]
section, directly below ExecStart=
.
Yep that works! And my test script also executed... So it seems like it will only execute scripts in the directory only if the system has already got into hibernation mode
Excellent! Glad to hear that worked!
I'll try to look into what's going on with systemd-sleep and why it's not calling the script and I'll report back here. If you are interested in researching it, and run across anything related, please share it here as well.
If we can't find a more direct solution, are you be interested in contributing your hibernate-preparation.service
file to the project?
Yeah, for a backup case ig. it's not ideal since suspend-then-hibernate wouldn't work, but better than not working at all
It's probably a me problem tbh When I run
doas /usr/lib/systemd/system-sleep/zram-hibernate
it spit out thisI thought this script is supposed to make hibernating without swap but with zram possible?