FS#66979 - [linux] version 5.7.2.arch1-1 breaks swap file mounting

Attached to Project: Arch Linux
Opened by Javier (je-vv) - Thursday, 11 June 2020, 20:53 GMT
Last edited by freswa (frederik) - Sunday, 13 September 2020, 15:03 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Jan Alexander Steffens (heftig)
Levente Polyak (anthraxx)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Description:

When upgrading linux from 5.6.15.arch1-1 to current 5.7.2.arch1-1, after booting, I get that the swap wasn't mounted, and on a "sudo swapon -a" I get the error:

dswapon: /swap: swapon failed: Invalid argument

Reformatting the swap FS with "sudo mkswap -L swap /swap", although giving no issues, doesn't help at all getting my /swap file mounted as swap, and on mounting I still get the same error. My fstab entry for swap:

/swap none swap nodev,nosuid 0 0

The only way to get the swap file mounting, is to revert linux back to 5.6.15.arch1-1.

Additional info:

* package version(s)

linux 5.7.2.arch1-1 (linux version 5.6.15.arch1-1 works just fine)

* config and/or log files etc.

/etc/fstab
...
/swap none swap nodev,nosuid 0 0
...

Steps to reproduce:

See Description.
This task depends upon

Closed by  freswa (frederik)
Sunday, 13 September 2020, 15:03 GMT
Reason for closing:  Fixed
Comment by loqs (loqs) - Thursday, 11 June 2020, 23:20 GMT
 FS#66921  ?
Comment by Javier (je-vv) - Thursday, 11 June 2020, 23:44 GMT
Not sure if I was the only one trying to use "swapon -a" manually, but it seems only I reported the weird invalid argument error, which is different to the swapfile has holes one...

At any rate, it does seem the same. In the end the swap file doesn't get mounted...
Comment by Luca von der Werth (Lucavon) - Friday, 12 June 2020, 07:20 GMT
Same issue, it happens with swap files created with fallocate. They added this to the Arch Wiki page's part about swap files:


"Note: dynamic space allocation such as using fallocate is not supported, as it causes problems with some file systems such as F2FS[1] and will likely fail to activate at boot time with error "swapon: swapfile has holes" as of kernel 5.7. Hence, contiguous allocation, such as dd, is the only reliable way to allocate a swap file.[2]" (https://wiki.archlinux.org/index.php/Swap#Swap_file).

Simply delete the file and use dd to make it. Here's what I did, and it worked:

swapoff /swapfile
rm -f /swapfile
dd if=/dev/zero of=/swapfile bs=1M count=16384 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
Comment by Javier (je-vv) - Friday, 12 June 2020, 07:24 GMT
Good to know, and yes, I did create the swap file long time ago with fallocate... Will try with dd later, and then upgrade linux, to see how things go...

Thanks !
Comment by Javier (je-vv) - Saturday, 13 June 2020, 01:23 GMT
Reporting that by creating the swap file with dd instead of fallocate, make things work back. Thanks !
Comment by TheFrenchGhosty (TheFrenchGhosty) - Sunday, 21 June 2020, 20:43 GMT
This is working perfectly, thanks!

I personally used:

dd if=/dev/zero of=/swapfile bs=1G count=[NUMBER OF GB OF SWAP WANTED] status=progress
(note: a block is created in the ram, using bs=1G means that you need more than 1GB of ram, if you don't use a lower value but more count)

Loading...