Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suspend broken in elogind-239.3 in Gentoo #112

oniGino opened this Issue Feb 13, 2019 · 4 comments


None yet
2 participants
Copy link

oniGino commented Feb 13, 2019

Please see:

index ca3befb30..6a3daab30 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -35,6 +35,7 @@ static int write_hibernate_location_info(void) {
         _cleanup_free_ struct fiemap *fiemap = NULL;
         char offset_str[DECIMAL_STR_MAX(uint64_t)];
         char device_str[DECIMAL_STR_MAX(uint64_t)];
+        char device_num_str [DECIMAL_STR_MAX(uint)*2+2];
         _cleanup_close_ int fd = -1;
         struct stat stb;
         uint64_t offset;
@@ -44,10 +45,15 @@ static int write_hibernate_location_info(void) {
         if (r < 0)
                 return log_debug_errno(r, "Unable to find hibernation location: %m");
-        /* if it's a swap partition, we just write the disk to /sys/power/resume */
-        if (streq(type, "partition"))
-                return write_string_file("/sys/power/resume", device, 0);
-        else if (!streq(type, "file"))
+        /* if it's a swap partition, we just write the corresponding major:minor numbers to /sys/power/resume */
+        if (streq(type, "partition")) {
+                r = stat( device, &stb);
+                if (r == -1) {
+                        return log_debug_errno(errno, "Error while trying to get stats for %s: %m", device);
+                }
+                snprintf(device_num_str, DECIMAL_STR_MAX(uint)*2+2, "%u:%u",major(stb.st_rdev) , minor(stb.st_rdev) );
+                return write_string_file("/sys/power/resume", device_num_str, 0);
+        }else if (!streq(type, "file"))
                 return log_debug_errno(EINVAL, "Invalid hibernate type %s: %m",

@Yamakuzure Yamakuzure self-assigned this Feb 13, 2019


This comment has been minimized.

Copy link

Yamakuzure commented Feb 13, 2019

Interesting. write_hibernate_location_info() has nothing to do with suspending a machine. ;-)

Joke aside, both suspension and hibernation work just fine on three machines here, used at least six times a day, and that for months. But then, I do not have such a special setup like Herbert Wantesh.

I just have migrated master to systemd-240. So before cleaning that mess up, I'll go and see if that patch breaks anything in normal operation.
( I wanted to work off the issue list anyway before going for an elogind-240.1 release. )


This comment has been minimized.

Copy link

oniGino commented Feb 13, 2019

Do any of your test setups utilize luks in an lvm? I think that corner case might be the issue here. (I use that on my laptop)


This comment has been minimized.

Copy link

Yamakuzure commented Feb 13, 2019

No, I do not have any test setup, all my machines are production machines. My spare time is very limited, and maintaining different test setups is simply not possible at the moment.

I concur, the luks+lvm setup is leading to this problem. tomorrow I'll test the patch with my regular setup. It has to keep working.

Yamakuzure added a commit that referenced this issue Feb 14, 2019

Fix hibernation when swap is an LVM partition.
Herbert Wantesh reported on, that
hibernation no longer works if the used swap is an LVM partition.

The reason is, that the LVM name of the swap is something like
/dev/mapper/lm-swap, which is then tried to be written to
/sys/power/resume, and fails.

The solution is to get the major and minor id of the device and write
these as "%u:%u" into the resume file.

To not make things more complicated than neccessary for the majority
of setups, this method is only tried if the regular way fails.

Bug: #112
Closes: #112
Reported-by: Herbert Wantesh <>
Tested-by: Herbert Wantesh <>
Reviewed-by: wranz <>
Reviewed-by: Sven Eden <>
Signed-Off-By: Sven Eden <>

This comment has been minimized.

Copy link

Yamakuzure commented Feb 14, 2019

I have adapted the patch a bit and pushed it to the elogind v239-stable branch. It does not effect my setup, hibernation still works.

Can you please try it out whether it fixes the issue for you?

You can install the live version of the v239-stable branch using my life ebuild for sys-auth/elogind-239.9999 from my overlay "seden", available via layman.

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.