Alternate method of running swapon?

Valentin Vidić vvidic at
Wed Jan 8 13:23:03 EST 2020

On Wed, Jan 08, 2020 at 01:09:23PM -0500, Jeffrey Walton wrote:
> Hi Everyone,
> I work with an open source project. We have a VM but it is low-end.
> The machine suffers OOM kills. We don't have access to /etc/fstab.
> Everything is an upsell with the VPS provider.
> I'm trying to setup a swapfile during startup using Systemd but:
>     # swapon /swapfile
>     swapon: /swapfile: swapon failed: Operation not permitted
> This may be useful:
> # command -v swapon
> /sbin/swapon
> # file /sbin/swapo
> swapoff  swapon
> # file /sbin/swapon
> /sbin/swapon: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
> dynamically linked (uses shared libs), for GNU/Linux 2.6.32,
> BuildID[sha1]=a4891bc4dcfc533c61d76aa3e69870ab35d90c89, stripped
> My question is, is there a way to sidestep the restriction? Is it
> possible to ask the kernel to use the swapfile without using the
> command?

You can try running for more details:

 # strace swapon /swapfile

but the swap functionality is probably disabled in the kernel itself.


More information about the Kernelnewbies mailing list