kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Jeffrey Walton <noloader@gmail.com>
To: "Valentin Vidić" <vvidic@valentin-vidic.from.hr>
Cc: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: Alternate method of running swapon?
Date: Wed, 8 Jan 2020 13:33:21 -0500	[thread overview]
Message-ID: <CAH8yC8mac63ApaZ+GqKZQXzJg4kDxGZWDAbVfkZ+dYj2=7w2dQ@mail.gmail.com> (raw)
In-Reply-To: <20200108182303.GA8238@valentin-vidic.from.hr>

On Wed, Jan 8, 2020 at 1:23 PM Valentin Vidić
<vvidic@valentin-vidic.from.hr> wrote:
>
> 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.

Thanks Valentin.

Here is the full Pastebin: https://pastebin.com/hHAv5T0N .

I believe this is the relevant part from the Pastebin:

readlink("/swapfile", 0x7ffefb4c0810, 4096) = -1 EINVAL (Invalid argument)
stat("/swapfile", {st_mode=S_IFREG|0600, st_size=2147483648, ...}) = 0
open("/swapfile", O_RDONLY)             = 3
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
65536) = 65536
close(3)                                = 0
swapon("/swapfile", 0)                  = -1 EPERM (Operation not permitted)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2502, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7fdbd8207000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2502
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7fdbd8207000, 4096)            = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/util-linux.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
...

Jeff

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

  reply	other threads:[~2020-01-08 18:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-08 18:09 Alternate method of running swapon? Jeffrey Walton
2020-01-08 18:23 ` Valentin Vidić
2020-01-08 18:33   ` Jeffrey Walton [this message]
2020-01-08 18:42     ` Valentin Vidić
2020-01-08 20:08       ` Jeffrey Walton
2020-01-08 20:28         ` Valentin Vidić
2020-01-08 18:26 ` Bernd Petrovitsch
2020-01-08 22:23   ` Jeffrey Walton
2020-01-08 18:31 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH8yC8mac63ApaZ+GqKZQXzJg4kDxGZWDAbVfkZ+dYj2=7w2dQ@mail.gmail.com' \
    --to=noloader@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=vvidic@valentin-vidic.from.hr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).