You are not logged in.

#1 2019-12-10 09:45:22

TheTopperOne
Member
Registered: 2019-12-10
Posts: 4

Swapfile not detected by systemd-logind

I have a problem hibernating my Laptop. The Error I get is the following:

 # systemctl hibernate 
Failed to hibernate system via logind: Not enough swap space for hibernation

I have set up a swapfile on my device under /home/swapfile

$ swapon
NAME           TYPE SIZE USED PRIO
/home/swapfile file  24G   0B   -2

but the systemd-logind does not detect it, as you can see in the journalctl output:

# journalctl -p 3 -xb
-- Logs begin at Tue 2019-05-14 11:26:39 CEST, end at Tue 2019-12-10 10:16:28 CET. --
Dez 10 10:16:10 Linux kernel: tpm_tis STM7304:00: IRQ index 0 not found
Dez 10 10:16:10 Linux kernel: kvm: disabled by bios
Dez 10 10:16:10 Linux kernel: kvm: disabled by bios
Dez 10 10:16:10 Linux kernel: kvm: disabled by bios
Dez 10 10:16:11 Linux kernel: kvm: disabled by bios
Dez 10 10:16:11 Linux kernel: kvm: disabled by bios
Dez 10 10:16:11 Linux kernel: rmi4_f34 rmi4-00.fn34: rmi_f34v7_probe: Unrecognized bootloader version
Dez 10 10:16:11 Linux kernel: kvm: disabled by bios
Dez 10 10:16:11 Linux kernel: kvm: disabled by bios
Dez 10 10:16:11 Linux kernel: kvm: disabled by bios
Dez 10 10:16:13 Linux systemd-logind[499]: Failed to open /home/swapfile: No such file or directory
Dez 10 10:16:13 Linux systemd-logind[499]: Failed to open /home/swapfile: No such file or directory
Dez 10 10:16:18 Linux systemd-logind[499]: Failed to open /home/swapfile: No such file or directory
Dez 10 10:16:18 Linux systemd-logind[499]: Failed to open /home/swapfile: No such file or directory
Dez 10 10:16:18 Linux systemd-logind[499]: Failed to open /home/swapfile: No such file or directory

I have tried another swapfile which is located on the root-partition and everything works. The problem is there is not enough space if my RAM uses more than 4GB, since there is no more space left on the root-partition.

My guess is that I made a mistake referencing the swapfile the correct way in the "resume" options for grub.
From /etc/default/grub :

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=/dev/nvme0n1p2 resume_offset=34816"

The root partition is /dev/nvme0n1p2 and the /home/swapfile is a path from this partition. The problem(?) is the path destination is located on /dev/nvme0n1p3 which is my workspace partition for /home .

  GNU nano 4.6                                                 /etc/fstab                                                             
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/nvme0n1p1
UUID=0868-0747                                  /boot/EFI       vfat            defaults                0 0

# /dev/nvme0n1p2
UUID=51b4f482-4f63-49df-a551-3692a5137d04       /               ext4            rw,discard,relatime     0 1

# /dev/nvme0n1p3
UUID=50fdda00-12df-432a-b46f-cf781252fc9c       /home           ext4            rw,discard,relatime     0 2

# Swapfile on /dev/nvme0n1p3
/home/swapfile                                  none            swap            defaults                0 0

Any ideas how to solve it?

Offline

#2 2019-12-10 09:53:36

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,738

Re: Swapfile not detected by systemd-logind

Well at the very least, your file is on the partition slated for /home so your resume device should be  resume=/dev/nvme0n1p3 (if you where to just mount / your /home path wouldn't exist.) That doesn't necessarily explain why logind doesn't find the swap file, not on my Arch but I'd guess some ProtectHome directive denying direct access to the home partition to the system service

Edit:

systemd-logind.service wrote:

...
ProtectHome=yes
...

You could define an override here to change that to no but I don't think you should. Not entirely sure what the best course of action would be here, without unnecessarily opening up the system, you could definitely do it as a intermediate test

Last edited by V1del (2019-12-10 10:22:18)

Offline

#3 2019-12-10 10:38:29

TheTopperOne
Member
Registered: 2019-12-10
Posts: 4

Re: Swapfile not detected by systemd-logind

Thank you for your quick reply

I just changed the resume-point in the grub file and as you mentioned nothing changed.
Since I want to detect the error I will change the entry

system-logind.service wrote:

...
ProtectHome=yes
...

for now and look what happens. It seems that at least does the trick for finding the file.

Edit: This option allows hibernate but as said by V1del it is not an ideal solution. Has anybody an idea how to solve this without changing the global setting in system-logind.service ?

Another option I have is changing the size of my root-partition. But I think this could be very risky and I could lose data.

Last edited by TheTopperOne (2019-12-10 12:13:08)

Offline

#4 2019-12-10 13:13:37

Zod
Member
From: Hoosiertucky
Registered: 2019-03-10
Posts: 630

Re: Swapfile not detected by systemd-logind

You could always backup your data and then rebuild the system providing for a suitable swap space/partition?

Offline

#5 2019-12-11 13:12:06

TheTopperOne
Member
Registered: 2019-12-10
Posts: 4

Re: Swapfile not detected by systemd-logind

Of course I can do that but the old solution was working quite well. I don't know when something changed I only noticed that the Laptop did not start hibernating. So I'd like to find a solution without rebuilding the whole system. Maybe I can allow the systemd-logind to access the swapfile on boot/login. I mean at boot it gets recognized by the system and if I set ProtectHome=no it can be accessed by the systemd-logind.

Offline

#6 2019-12-11 15:08:30

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,791

Re: Swapfile not detected by systemd-logind

You should not have to use a swap partition.  A file should work.  The problem is, that file has to be available when you come out of hibernation.  I am not sure that the home partition is the best place for it;  I would generally want it someplace on the root.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2019-12-11 21:06:07

TheTopperOne
Member
Registered: 2019-12-10
Posts: 4

Re: Swapfile not detected by systemd-logind

As I already said on my root is not enough space left for a 16G+ swapfile and therefore I am looking for an alternative. So I created the file on my home partition. This method worked quite well for a long time but then I turned hibernation off in my settings. Now I wanted to turn hibernation back on and it does not work as expected.

Offline

Board footer

Powered by FluxBB