Contents
Why is swap file invalid argument in Linux?
The swap file implementation in the kernel expects to be able to write to the file directly, without the assistance of the filesystem. This is a problem on files with holes or on copy-on-write files on filesystems like Btrfs. Commands like cp (1) or truncate (1) create files with holes.
Can a preallocated swap file be rejected by Swapon?
These files will be rejected by swapon. Preallocated files created by fallocate (1) may be interpreted as files with holes too depending of the filesystem. Preallocated swap files are supported on XFS since Linux 4.18. The most portable solution to create a swap file is to use dd (1) and /dev/zero. The italicized note seems to explain everything.
What does it mean when Swapon fails to mount a partition?
Issuing the swapon command to mount the failed partition results in an Invalid argument error The affected swap partition has been deleted or has become corrupt. 1. Ensure swap is really off for the problem partition.
How to enable the swap to see error?
Enable the swap to see error. This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Why is Swapon unable to create swap file with error?
Can upgrade to RHEL8 as issue is fixed for XFS. The swap file implementation in the kernel expects to be able to write to the file directly, without the assistance of the filesystem. This is a problem on files with holes. Commands like cp (1) or truncate (1) create files with holes. These files will be rejected by swapon.
Why does Swapon reject preallocated files with holes?
This is a problem on files with holes. Commands like cp (1) or truncate (1) create files with holes. These files will be rejected by swapon. Preallocated files created by fallocate (1) may be interpreted as files with holes too depending of the filesystem.
Are there any preallocated swap files in Linux?
Preallocated swap files are supported on XFS since Linux 4.18. The most portable solution to create a swap file is to use dd (1) and /dev/zero. The italicized note seems to explain everything. Unfortunately, even with verbose output, swapon doesn’t mention the cause (files with holes) of failure.