Re: Alternate method of running swapon?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all!

On 08/01/2020 19:09, Jeffrey Walton wrote:
[...]
> 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.

Apparently you run too many (or too fat) programs;-)

> 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:
[... nope ....] 

> 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?

The swapon (and swapoff) command basically calls the swapon()
syscall (and swapoff() syscall, respectively) and their manual
page say the caller needs CAP_SYS_ADMIN capability which usually
means being "root".

Does it work in a root-shell?

The man page says further under errors:
----  snip  ----
EPERM: The caller does not have the CAP_SYS_ADMIN capability.
Alternatively, the maximum number of swap files are already in
use; see NOTES below.
----  snip  ----
The notes below just talk about the maximum numbers of swapfile
depending on the kernel version and activates features.

If the kernel is built/provided by the VPS provider, there may
be further limitations ....

MfG,
	Bernd

PS: I'm not guessing why ....
-- 
"I dislike type abstraction if it has no real reason. And saving
on typing is not a good reason - if your typing speed is the main
issue when you're coding, you're doing something seriously wrong."
    - Linus Torvalds

Attachment: pEpkey.asc
Description: application/pgp-keys

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux