36

I'm running BOINC on my old netbook, which only has 2 GB of RAM onboard, which isn't enough for some tasks to run. As in, they refuse to, seeing how low on RAM the device is.

I have zRAM with backing_dev and zstd algorithm enabled, so in reality, lack of memory is never an issue, and in especially tough cases I can always just use systemd-run --scope -p (I have successfully ran programs that demanded +16 GB of RAM using this)

How can I make BOINC think that my laptop has more than 2 GB of RAM installed, so that I could run those demanding tasks?

4
  • I don't how does BOINK check for amount of available RAM, it may just read /proc/meminfo but could you start from creating a swap file if you have enough disk space available? Commented Apr 19, 2020 at 9:47
  • 1
    Or something like here unix.stackexchange.com/questions/258145/… Commented Apr 19, 2020 at 9:51
  • 2
    If that program is checking the avail memory via /proc/meminfo you can simply edit the binary and replace the /proc/meminfo with some other path having the same length. Eg. perl -pe 's,/proc/meminfo,/etc/bmeminfo,' -i /path/to/that/binary. This is MUCH better than having to set up namespaces or mess up your system in other ways. With a little bit of assembly knowledge, you can also change that check to always return true, so you don't even have to create a fake meminfo file.
    – user313992
    Commented Apr 19, 2020 at 12:51
  • Do you mean BOINC?
    – wizzwizz4
    Commented Apr 21, 2020 at 13:19

2 Answers 2

52

Create a fake meminfo and mount it over an original /proc/meminfo:

$ mkdir fake-meminfo && cd fake-meminfo
$ cp /proc/meminfo .
$ chmod +w meminfo
$ sed -Ei 's,^MemTotal:        [0-9]+ kB,MemTotal:        8839012 kB,' meminfo   # replace 8839012 with an amount of RAM you want to pretend you have
$ free -m  # check how much RAM you have now
              total        used        free      shared  buff/cache   available
Mem:           7655        1586        3770         200        2298        5373
$ sudo mount --bind meminfo /proc/meminfo                                 
$ free -m  # check how much RAM you pretend to have after replacing /proc/meminfo
              total        used        free      shared  buff/cache   available
Mem:           8631        2531        3800         201        2299        5403
$ sudo umount /proc/meminfo # restore an original /proc/meminfo
$ free -m
              total        used        free      shared  buff/cache   available
Mem:           7655        1549        3806         200        2299        5410

You can also run the above commands in a mount namespace isolated from the rest of the system. References: Recover from faking /proc/meminfo

1
  • mount --bind meminfo /proc/meminfo says mount point /proc/meminfo is not a directory in CentOS docker
    – Suor
    Commented Dec 26, 2023 at 14:11
9

After some thinking, I did this:

Started with nano /proc/meminfo

Changed MemTotal, MemFree, MemAvailable, SwapTotal and SwapFree to desired values and saved to ~./meminfo

Gave the user boinc password sudo passwd boinc and shell -- sudo nano /etc/passwd , found the line boinc:x:129:141:BOINC core client,,,:/var/lib/boinc-client:/usr/sbin/nologin and changed the /usr/sbin/nologin part to /bin/bash

Then I faked RAM info using examples from here Recover from faking /proc/meminfo

unshare -m bash    #unshares mount spaces, for specific program "bash" only (and for whatever you want to launch from it)
mount --bind ~./meminfo /proc/meminfo      #substitutes real meminfo data with fake one

and confirmed with free that it worked

          total        used        free         shared     buff/cache  available
Mem:     2321456       21456     2300000           0           0     2300000
Swap:     5000000     1000000     4000000

Then switched to user su - boinc and just launched the program with

boinc --check_all_logins --redirectio --dir /var/lib/boinc-client

BOINC Manager can be launched then as usual

Total success, tasks which previously refused to run, started to download and then ran with no complications

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .