Create a swap file


I’m trying to create a swap file in my Raspberry Pi 3 Model B machine, which runs resionOS.
I followed this guide here Create a swap file (see section Create a swap file).

Each of the commands there goes fine, but at the end it doesn’t look that I have a usable swap file in my machine.
When I try to monitor my swap space, it shows me a total of 0.

  1. > free -m
    Swap: 0 0 0

  2. > swapon --all
    this throws an error:
    swapon: /swapfile: swapon failed: Input/output error

  3. > top
    KiB Swap: 0 total, 0 used, 0 free.

So, as far as I understand it looks like something goes wrong when trying to crate the swap file, but I’m not sure what it is.
What can it be?
Is there any other approach to create a swap file?


Hi @dbeqiraj

That guide is rather old, I’ll have to check with the team if this is still supported at all – let me get back to you on that.

That said it’s worth considering if a swap file is the right solution, SD cards tend to have a limited write count in their lifetime, and swap tends to cause a very high frequency of writes, shortening the lifetime of the card quite severely.


I checked with the team and the feedback is that this isn’t really supported anymore, resin in 2013 was a very different beast from what it is today – they also reitterated that swap on media like an SD card is not a great idea, especially in production.

That said if it’s critical for your use case, you could look at and see if it works.

I’ll also update the blog post and add a deprecated note to it – thanks for bringing that to our attention