The bug still persists.
I am on Fedora 32 and just upgraded to the latest 5.8 kernel.
I am still getting the error of my swap file being failed to be activated, and as a result I have no swap space after boot.
I use a swap file and not a swap partition.
This problem is carried over from the 5.7 kernel, I reported it over here. It still exists in the 5.8 kernel.
How do I activate my swap file ?
Is there some sort of work around ?
On 11/11/20 10:04 PM, Sreyan Chakravarty wrote:
The bug still persists.
I am on Fedora 32 and just upgraded to the latest 5.8 kernel.
I am still getting the error of my swap file being failed to be activated, and as a result I have no swap space after boot.
Is there an error message? What is the line in your /etc/fstab? What happens if you do "swapon /path/to/your/swapfile"?
On Thu, Nov 12, 2020 at 11:45 AM Samuel Sieb samuel@sieb.net wrote:
Is there an error message? What is the line in your /etc/fstab? What happens if you do "swapon /path/to/your/swapfile"?
No idea why this is happening though:
swapon /fedora.swap swapon: /fedora.swap: swapon failed: Invalid argument
I am getting the following error message during boot
$ journalctl -b 0
Nov 13 11:55:46 localhost.HPNotebook systemd[1]: Activating swap /fedora.swap... Nov 13 11:56:01 localhost.HPNotebook swapon[1018]: swapon: /fedora.swap: swapon failed: Invalid argument Nov 13 11:55:46 localhost.HPNotebook systemd[1]: fedora.swap.swap: Swap process exited, code=exited, status=255/EXCEPTION Nov 13 11:55:46 localhost.HPNotebook systemd[1]: fedora.swap.swap: Failed with result 'exit-code'. Nov 13 11:55:46 localhost.HPNotebook systemd[1]: Failed to activate swap /fedora.swap. Nov 13 11:56:01 localhost.HPNotebook swapon[1104]: swapon: /fedora.swap: swapon failed: Invalid argument Nov 13 11:56:00 localhost.HPNotebook systemd[1]: Activating swap /fedora.swap... Nov 13 11:56:01 localhost.HPNotebook systemd[1]: fedora.swap.swap: Swap process exited, code=exited, status=255/EXCEPTION Nov 13 11:56:01 localhost.HPNotebook systemd[1]: fedora.swap.swap: Failed with result 'exit-code'. Nov 13 11:56:01 localhost.HPNotebook systemd[1]: Failed to activate swap /fedora.swap. Nov 13 11:56:02 localhost.HPNotebook systemd[1]: Activating swap /fedora.swap... Nov 13 11:56:02 localhost.HPNotebook swapon[1122]: swapon: /fedora.swap: swapon failed: Invalid argument Nov 13 11:56:02 localhost.HPNotebook systemd[1]: fedora.swap.swap: Swap process exited, code=exited, status=255/EXCEPTION Nov 13 11:56:02 localhost.HPNotebook systemd[1]: fedora.swap.swap: Failed with result 'exit-code'. Nov 13 11:56:02 localhost.HPNotebook systemd[1]: Failed to activate swap /fedora.swap.
I can confirm that swap does not work as :
$ free
total used free shared buff/cache available Mem: 8041504 1887468 4029028 321996 2125008 5525636 Swap: 0 0 0
Free gives 0 swap, and my hibernate option is disabled.
On 11/12/20 10:42 PM, Sreyan Chakravarty wrote:
On Thu, Nov 12, 2020 at 11:45 AM Samuel Sieb <samuel@sieb.net mailto:samuel@sieb.net> wrote:
Is there an error message? What is the line in your /etc/fstab? What happens if you do "swapon /path/to/your/swapfile"?No idea why this is happening though:
swapon /fedora.swap swapon: /fedora.swap: swapon failed: Invalid argument
What do "ls -lh /fedora.swap", "du -h /fedora.swap", and "blkid /fedora.swap" show? Didn't you have a similar problem a while ago or was that someone else? There was some kernel change that might require you to recreate the swap file.
On Fri, Nov 13, 2020 at 12:31 PM Samuel Sieb samuel@sieb.net wrote:
What do "ls -lh /fedora.swap", "du -h /fedora.swap", and "blkid /fedora.swap" show?
This is the requested data:
$ ls -lh /fedora.swap -rw-------. 1 root root 8.0G Nov 13 15:36 /fedora.swap
$ du -h /fedora.swap 8.1G /fedora.swap
$ blkid /fedora.swap (No Output)
Didn't you have a similar problem a while ago or was that someone else?
I had the same problem with the 5.7 kernel, and my solution was to use the 5.6 kernel.
There was some kernel change that might require you to recreate the swap
file.
I have created the swap but they still get the same error.
Nov 13 15:39:33 localhost.HPNotebook kernel: swapon: swapfile has holes
Anything else I can do ?
On 13/11/2020 18:18, Sreyan Chakravarty wrote:
On Fri, Nov 13, 2020 at 12:31 PM Samuel Sieb <samuel@sieb.net mailto:samuel@sieb.net> wrote:
What do "ls -lh /fedora.swap", "du -h /fedora.swap", and "blkid /fedora.swap" show?This is the requested data:
$ ls -lh /fedora.swap -rw-------. 1 root root 8.0G Nov 13 15:36 /fedora.swap
$ du -h /fedora.swap 8.1G /fedora.swap
$ blkid /fedora.swap (No Output)
Didn't you have a similar problem a while ago or was that someone else?I had the same problem with the 5.7 kernel, and my solution was to use the 5.6 kernel.
There was some kernel change that might require you to recreate the swap file.I have created the swap but they still get the same error.
Nov 13 15:39:33 localhost.HPNotebook kernel: swapon: swapfile has holes
Anything else I can do ?
Looking at https://bbs.archlinux.org/viewtopic.php?id=256614 and the URL's contained within it seems doing a
dd if=/dev/zero of=/fedora.swap bs=1M count=2048 status=progress
may cure the w(hole) issue. :-)
--- The key to getting good answers is to ask good questions.
On 13/11/2020 18:27, Ed Greshko wrote:
On 13/11/2020 18:18, Sreyan Chakravarty wrote:
On Fri, Nov 13, 2020 at 12:31 PM Samuel Sieb <samuel@sieb.net mailto:samuel@sieb.net> wrote:
What do "ls -lh /fedora.swap", "du -h /fedora.swap", and "blkid /fedora.swap" show?
This is the requested data:
$ ls -lh /fedora.swap -rw-------. 1 root root 8.0G Nov 13 15:36 /fedora.swap
$ du -h /fedora.swap 8.1G /fedora.swap
$ blkid /fedora.swap (No Output)
Didn't you have a similar problem a while ago or was that someone else?
I had the same problem with the 5.7 kernel, and my solution was to use the 5.6 kernel.
There was some kernel change that might require you to recreate the swap file.
I have created the swap but they still get the same error.
Nov 13 15:39:33 localhost.HPNotebook kernel: swapon: swapfile has holes
Anything else I can do ?
Looking at https://bbs.archlinux.org/viewtopic.php?id=256614 and the URL's contained within it seems doing a
dd if=/dev/zero of=/fedora.swap bs=1M count=2048 status=progress
may cure the w(hole) issue. :-)
Sorry, the count above was for a 2GB swap file. Increase it to cover your 8GB file.
--- The key to getting good answers is to ask good questions.
On Fri, Nov 13, 2020 at 4:00 PM Ed Greshko ed.greshko@greshko.com wrote:
Looking at https://bbs.archlinux.org/viewtopic.php?id=256614 and the
URL's contained within
it seems doing a
dd if=/dev/zero of=/fedora.swap bs=1M count=2048 status=progress
may cure the w(hole) issue. :-)
Sorry, the count above was for a 2GB swap file. Increase it to cover your 8GB file.
dd if=/dev/zero of=/fedora.swap bs=1M count=8192 status=progress
This command has partially solved my problem
But I have a couple of questions,
1) Why doesn't fallocate work anymore ? 2) I tried dd if=/dev/zero of=/fedora.swap bs=1 count=0 seek=8G
This did not work. swapon complained about files being full of holes. What is so special about bs=1M ?
I now have a new problem.
SELinux is preventing systemd-logind to read the swap file.
Here is the message:
SELinux is preventing systemd-logind from read access on the file /fedora.swap.
***** Plugin restorecon (99.5 confidence) suggests ************************
If you want to fix the label. /fedora.swap default label should be etc_runtime_t. Then you can run restorecon. The access attempt may have been stopped due to insufficient permissions to access a parent directory in which case try to change the following command accordingly. Do # /sbin/restorecon -v /fedora.swap
***** Plugin catchall (1.49 confidence) suggests **************************
If you believe that systemd-logind should be allowed read access on the fedora.swap file by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: # ausearch -c 'systemd-logind' --raw | audit2allow -M my-systemdlogind # semodule -X 300 -i my-systemdlogind.pp
Additional Information: Source Context system_u:system_r:systemd_logind_t:s0 Target Context unconfined_u:object_r:swapfile_t:s0 Target Objects /fedora.swap [ file ] Source systemd-logind Source Path systemd-logind Port <Unknown> Host localhost.HPNotebook Source RPM Packages Target RPM Packages SELinux Policy RPM selinux-policy-targeted-3.14.5-44.fc32.noarch Local Policy RPM selinux-policy-targeted-3.14.5-44.fc32.noarch Selinux Enabled True Policy Type targeted Enforcing Mode Enforcing Host Name localhost.HPNotebook Platform Linux localhost.HPNotebook 5.8.18-200.fc32.x86_64 #1 SMP Mon Nov 2 19:49:11 UTC 2020 x86_64 x86_64 Alert Count 3 First Seen 2020-11-13 17:59:22 IST Last Seen 2020-11-13 17:59:22 IST Local ID 375aec7e-f77d-47ab-865a-f83a47c12423
Raw Audit Messages type=AVC msg=audit(1605270562.371:320): avc: denied { read } for pid=1256 comm="systemd-logind" name="fedora.swap" dev="dm-2" ino=13 scontext=system_u:system_r:systemd_logind_t:s0 tcontext=unconfined_u:object_r:swapfile_t:s0 tclass=file permissive=0
Hash: systemd-logind,systemd_logind_t,swapfile_t,file,read
I don't know much about SELinux, can you help me fix the label ?
How can I fix the label as described here?
If you want to fix the label. /fedora.swap default label should be etc_runtime_t.
On Fri, Nov 13, 2020 at 5:41 AM Sreyan Chakravarty sreyan32@gmail.com wrote:
- Why doesn't fallocate work anymore ?
Fallocate is the preferred way to do this, e.g.
fallocate -l 8G swapfile
- I tried dd if=/dev/zero of=/fedora.swap bs=1 count=0 seek=8G
This did not work. swapon complained about files being full of holes.
That's because that command creates a sparse file, which has holes in it. Same as using 'truncate'.
What is so special about bs=1M ?
I think it's count=0 and seek= that causes it to become sparse. I don't think the bs size is relevant.
/fedora.swap none swap sw 0 0
I have no idea what 'sw' is in the fstab file is for; I don't see it in either man fstab or man swapon. I'd just make this line:
/fedora.swap none defaults
I now have a new problem.
SELinux is preventing systemd-logind to read the swap file.
Here is the message:
SELinux is preventing systemd-logind from read access on the file /fedora.swap.
mkswap sets the label. So this is a secondary effect of what Sam Sieb already discovered from the lack of a blkid swap signature. You forgot to use mkswap on the file.
On Fri, Nov 13, 2020 at 3:58 PM Ed Greshko ed.greshko@greshko.com wrote:
Looking at https://bbs.archlinux.org/viewtopic.php?id=256614 and the URL's contained within it seems doing a
dd if=/dev/zero of=/fedora.swap bs=1M count=2048 status=progress
may cure the w(hole) issue. :-)
Also weirdly my 8GB swap file is being interpreted as only 8MB.
$ swapon -s Filename Type Size Used Priority /fedora.swap file 8388604 0 -2
$ ls -sh /fedora.swap 8.1G /fedora.swap
What on earth is happening?
On Fri, Nov 13, 2020 at 6:28 PM Sreyan Chakravarty sreyan32@gmail.com wrote:
On Fri, Nov 13, 2020 at 3:58 PM Ed Greshko ed.greshko@greshko.com wrote:
Looking at https://bbs.archlinux.org/viewtopic.php?id=256614 and the URL's contained within it seems doing a
dd if=/dev/zero of=/fedora.swap bs=1M count=2048 status=progress
may cure the w(hole) issue. :-)
Also weirdly my 8GB swap file is being interpreted as only 8MB.
$ swapon -s Filename Type Size Used Priority /fedora.swap file 8388604 0 -2
$ ls -sh /fedora.swap 8.1G /fedora.swap
What on earth is happening?
Ok my mistake.
I seem to have 8 GB of swap space. I can confirm by the free command.
$ free -h total used free shared buff/cache available Mem: 7.7Gi 1.7Gi 4.4Gi 337Mi 1.6Gi 5.4Gi Swap: 8.0Gi 0B 8.0Gi
BUT
I am still unable to hibernate:
$ systemctl hibernate Failed to hibernate system via logind: Not enough swap space for hibernation
I don't understand why after having 8GB of free swap space, I am still unable to hibernate ?
Is this an SELinux issue ?
What is the problem here ?
On Fri, 2020-11-13 at 20:22 +0530, Sreyan Chakravarty wrote:
$ systemctl hibernate Failed to hibernate system via logind: Not enough swap space for hibernation
I don't understand why after having 8GB of free swap space, I am still unable to hibernate ?
Is this an SELinux issue ?
What is the problem here ?
It's been years since I did this so things may have changed (I don't use hibernation as it doesn't work with GPU passthrough for VMs), but in my notes it says to add the UUID of the swap device to the command line in /etc/sysconfig/grub:
GRUB_CMDLINE_LINUX="... resume=UUID=xxxxxxxxxxxxxxxx ..."
and then run 'grub2-mkconfig' to do its magic. I'm not sure if this can be adapted to using a swapfile, but something tells me it can't. It has to be a device or partition unless things have changed. I'm sure more experienced hands will correct this if I'm wrong.
poc
On Fri, Nov 13, 2020 at 05:44:57PM +0000, Patrick O'Callaghan wrote:
It's been years since I did this so things may have changed (I don't use hibernation as it doesn't work with GPU passthrough for VMs), but in my notes it says to add the UUID of the swap device to the command line in /etc/sysconfig/grub:
GRUB_CMDLINE_LINUX="... resume=UUID=xxxxxxxxxxxxxxxx ..."
and then run 'grub2-mkconfig' to do its magic. I'm not sure if this can be adapted to using a swapfile, but something tells me it can't. It has to be a device or partition unless things have changed. I'm sure more experienced hands will correct this if I'm wrong.
There are extra steps if you use a swap file, instead of a swap partition.
According to the kernel documentation: https://www.kernel.org/doc/html/latest/power/swsusp-and-swap-files.html
The Linux kernel handles swap files almost in the same way as it handles swap partitions and there are only two differences between these two types of swap areas: (1) swap files need not be contiguous, (2) the header of a swap file is not in the first block of the partition that holds it. From the swsusp’s point of view (1) is not a problem, because it is already taken care of by the swap-handling code, but (2) has to be taken into consideration.
In principle the location of a swap file’s header may be determined with the help of appropriate filesystem driver. Unfortunately, however, it requires the filesystem holding the swap file to be mounted, and if this filesystem is journaled, it cannot be mounted during resume from disk. For this reason to identify a swap file swsusp uses the name of the partition that holds the file and the offset from the beginning of the partition at which the swap file’s header is located. For convenience, this offset is expressed in <PAGE_SIZE> units.
In order to use a swap file with swsusp, you need to:
1) Create the swap file and make it active, eg.:
# dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k> # mkswap <swap_file_path> # swapon <swap_file_path>
2) Use an application that will bmap the swap file with the help of the FIBMAP ioctl and determine the location of the file’s swap header, as the offset, in <PAGE_SIZE> units, from the beginning of the partition which holds the swap file.
3) Add the following parameters to the kernel command line:
resume=<swap_file_partition> resume_offset=<swap_file_offset>
where <swap_file_partition> is the partition on which the swap file is located and <swap_file_offset> is the offset of the swap header determined by the application in 2) (of course, this step may be carried out automatically by the same application that determines the swap file’s header offset using the FIBMAP ioctl)
On Fri, 13 Nov 2020 13:16:05 -0500 Jonathan Billings billings@negate.org wrote:
2) Use an application that will bmap the swap file with the help of the FIBMAP ioctl and determine the location of the file’s swap header, as the offset, in <PAGE_SIZE> units, from the beginning of the partition which holds the swap file. 3) Add the following parameters to the kernel command line:
Use an application that will bmap the swap file with the help
Does this application already exists or we need to write one? ;-)
On Fri, 2020-11-13 at 13:16 -0500, Jonathan Billings wrote:
In principle the location of a swap file’s header may be determined with the help of appropriate filesystem driver. Unfortunately, however, it requires the filesystem holding the swap file to be mounted, and if this filesystem is journaled, it cannot be mounted during resume from disk. For this reason to identify a swap file swsusp uses the name of the partition that holds the file and the offset from the beginning of the partition at which the swap file’s header is located. For convenience, this offset is expressed in <PAGE_SIZE> units.
Surely the absolute position of any file in a file system couldn't be relied upon to always be the same?
On 11/13/20 9:35 PM, Tim via users wrote:
On Fri, 2020-11-13 at 13:16 -0500, Jonathan Billings wrote:
In principle the location of a swap file’s header may be determined with the help of appropriate filesystem driver. Unfortunately, however, it requires the filesystem holding the swap file to be mounted, and if this filesystem is journaled, it cannot be mounted during resume from disk. For this reason to identify a swap file swsusp uses the name of the partition that holds the file and the offset from the beginning of the partition at which the swap file’s header is located. For convenience, this offset is expressed in <PAGE_SIZE> units.Surely the absolute position of any file in a file system couldn't be relied upon to always be the same?
Of course it can. How is it going to move around?
Thank you.
It works now after setting the correct parameters.
Thanks again.
On Thu, Nov 12, 2020 at 11:45 AM Samuel Sieb samuel@sieb.net wrote:
What is the line in your /etc/fstab?
My /etc/fstab has the following:
/dev/mapper/vgfedora-fedora / ext4 defaults,x-systemd.device-timeout=0 1 1 UUID=4d112d8e-080d-44f2-8962-9c13f20a7885 /boot ext4 defaults 1 2 UUID=041A-E511 /boot/efi vfat defaults,uid=0,gid=0,umask=077,shortname=winnt 0 2 /fedora.swap none swap sw 0 0