instagram arrow-down
Kalle Lilja

Archives

Install Mersenne GIMPS as a daemon

Ubuntu 16.04

Watching this Numberphile video and all of the related ones on YouTube got me on to having a look at this GIMPS, Great Internet Mersenne Prime Search.
I quickly set up an account, joined the Numberphile team, and got it up and running on my Windows machine using the provided getting started Instructions.
The set up is easy enough, download the program- start the program- provide your information- let it run.

As with any service, feature, or task, the question cropped up; Can it be run without intervention Linux? as a daemon
tl;dr: Yes, take a look at the GitHub repo.
Having a look at the Mersenne forum yielded no working result during my search, but I was pointed in a direction, some good old-fashioned tinkering was at hand.

There’s a story here about spinning up test VMs, messing the the code, cursing the transfer of code from Windows to Linux resulting in dos line endings having to be sorted from vi with :set ff=unix or apt-get dos2unix *.
However, I won’t go through all that.

I’ve distributed the working code over on GitHub as per usual.

Setup

The install is automated and performed using setup.sh.
setup.sh will do a whole bunch of good stuff leaving you with a working daemonized install of prime95 to be used by GIMPS.

The snippet will install git from repo if not already installed, download all of the required files to a new folder mprime-gimps/, set the setup.sh script to executable and run it.

First off we’ll create the user account used to run the task, mprime.
This is as basuc as an account can be, no sudo, no password.
The folder to house related data is also created.

Secondly, the script to run the prime95 client, startmprime, is copied over to /usr/sbin/mprime and set to be runable by the new mprime user.

Next up, logging is set up and configured to rotate daily using the logrotate function. Further reading related to logrotate can be found here.

Followed by installing the actual deamonization of the startmprime script and setting it to run on boot via update-rc.d.

Lastly the prime95 client is installed and subsequently configured to use your own mersenne account and so on. Follow the on-screen instructions.

When configured, exit the manually started mprime using the “5. Test/Quit when done” option.
Run the daemonized version, sudo /etc/init.d/mprimed start.
It’s now safe to remove git and wget again if not needed. sudo apt-get remove git wget -y.

Information

With the install in place and running the cpu usage should be up at 100%, also, the mprime.log should start populating, tail -f /var/log/mprime.log.
The machine should also shorty show up under your CPUs on the Mersenne site.
More information available over on GitHub as per usual.

This is working set of code running on blank Linux machines on my end,
this is most likely not the correct, best, or most proper way of doing a deamonized prime95 client, but, it’s a way.
Use at your own risk and all that.