Why enabling swapfile on overlayfs fails with the error message "swapon failed: Invalid argument" in Red Hat Enterprise Linux ?
Issue
- Why enabling swapfile on overlayfs fails with the error message "swapon failed: Invalid argument" in Red Hat Enterprise Linux ?
- Enabling swap from a privileged container fails with the error "swapon failed: Invalid argument" in Red Hat Enterprise Linux
[root@rhel9 ~]# podman run -it --hostname swap --name swap --privileged registry.access.redhat.com/ubi8/ubi:8.10 /bin/bash
[root@swap /]# dd if=/dev/zero of=/swapfile bs=1M count=4096
4096+0 records in
4096+0 records out
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 1.21122 s, 3.5 GB/s
[root@swap /]# chmod 600 /swapfile
[root@swap /]# mkswap /swapfile
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
no label, UUID=10c85cc9-5d82-4cce-9a8f-114c3c54d636
root@swap /]# swapon /swapfile
swapon: /swapfile: swapon failed: Invalid argument
Environment
- Red Hat Enterprise Linux 8/9
- Swapfile on overlayfs (either on container or on host)
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.