So if didn’t work as root on shell, I fail to see why it would work in a boot script? I’m using debian containers and it seems to work fine.
# On a machine
root@e2865521f06486:/# fallocate -l 512M /swapfile
root@e2865521f06486:/# ls -l /swapfile
-rw-r--r-- 1 root root 536870912 Mar 28 01:31 /swapfile
# On an app
root@9b8286d7:/# fallocate -l 512M /swapfile
root@9b8286d7:/# ls -l /swapfile
-rw-r--r-- 1 root root 536870912 Mar 28 01:32 /swapfile
root@9b8286d7:/# uname -a
Linux 9b8286d7 5.12.2 #1 SMP Mon Oct 3 13:48:56 UTC 2022 x86_64 GNU/Linux
Not sure if I was clear but: this is an auto generated script from a library suggested in the documentation. I did not write it and I did not manually create any files on the machine, I just ran rails g dockerfile. I expect it to just work. If I wanted to manually set up my swap I would use EC2 or CloudRun, not Fly. I don’t have time for devops.
That it doesn’t work as root exposes the issue that either something is wrong with the infrastructure, or with the script generator suggested in the docs.