{"id":1058,"date":"2020-03-29T21:54:50","date_gmt":"2020-03-30T02:54:50","guid":{"rendered":"https:\/\/poojanwagh.opalstacked.com\/techblog\/?p=1058"},"modified":"2020-03-29T21:58:14","modified_gmt":"2020-03-30T02:58:14","slug":"folding-at-home-on-freebsd-in-an-iocage-jail","status":"publish","type":"post","link":"https:\/\/tech.poojanblog.com\/blog\/unix-linux\/folding-at-home-on-freebsd-in-an-iocage-jail\/","title":{"rendered":"Folding-at-Home on FreeBSD in an iocage jail"},"content":{"rendered":"\n<p>Given the urgency for research on the novel COVID-19 virus, I have been running Rosetta@Home and Folding@Home on my Windows machine.<\/p>\n\n\n\n<p>BOINC (which powers Rosetta@Home) runs reasonably well on FreeBSD with some special instructions.<\/p>\n\n\n\n<p>I also wanted to run Folding@Home. I currently have a Linux VM in bhyve to do so. But, that is rather inefficient. How bad would it be to run it in a Linux compat jail? Turns out, it&#8217;s not too bad.<\/p>\n\n\n\n<p>Since BOINC is also linux-compat, I basically followed the <a href=\"https:\/\/bellebookandcode.com\/tech\/setting-up-distributed-computing-on-bsd-systems-in-order-to-aid-covid-19-research\/\">BOINC instructions<\/a> (translating the instructions from FreeNAS to stock FreeBSD iocage).<\/p>\n\n\n\n<p>I then installed (within the jail) the rather <a href=\"https:\/\/reviews.freebsd.org\/D24127\">newly-refreshed<\/a> biology\/linux-foldingathome port.<\/p>\n\n\n\n<p>Here are step-by-step instructions. I am using VNET jails and assign hosts in the jail to the 192.168.2.0\/24 network attaching to a vnet1.X (X picked by iocage) interface created on the fly by iocage.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo iocage create -n \"fah\" -r 12.1-RELEASE vnet=\"on\" ip4_addr=\"vnet1|192.168.2.21\/24\" interfaces=\"vnet1:bridge1\" defaultrouter=\"192.168.2.1\" resolver=\"search domain.tld;nameserver 192.168.2.1\" boot=\"on\"<\/pre>\n\n\n\n<p>Get a console to the jail with:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo iocage console fah<\/pre>\n\n\n\n<p>Within the jail (root console from previous command), I ran<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">env ASSUME_ALWAYS_YES=YES pkg bootstrap\npkg update\npkg upgrade\nportsnap fetch\nportsnap extract          # takes a while to extract all ports directories\n<code>Building new INDEX files\u2026 done.<\/code><\/pre>\n\n\n\n<p>Then, it&#8217;s time to build the new biology\/linux-foldingathome, which basically encapsulates <a href=\"https:\/\/www.leidinger.net\/blog\/2020\/03\/19\/fighting-the-coronavirus-with-freebsd-foldinghome\/\">the recipe here<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/usr\/ports\/biology\/linux-foldingathome\nmake config      # I left defaults (of building DOCS)<\/pre>\n\n\n\n<p>To save a build dependency, I used the same process as the BOINC instructions: use pkg to get as many as possible. In this case, linux-base-c7 is the only one:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pkg install linux_base-c7\nmake\nmake install <\/pre>\n\n\n\n<p>Now, I edited \/usr\/local\/etc\/fahclient\/config.xml and updated my username and passkey. I deferred joining Team FreeBSD (team #11743) until I know things are working correctly.<\/p>\n\n\n\n<p>I also added the following lines to the config file to allow access within my trusted network (192.168.1.0\/24):<\/p>\n\n\n\n<code>&lt;allow&gt; 127.0.0.1 192.168.1.0\/24&lt;\/allow&gt;<br>\n&lt;web-allow&gt;127.0.0.1 192.168.1.0\/24&lt;\/web-allow&gt;<br>\n&lt;password&gt;p@33w0r6&lt;\/password&gt;<\/code>\n\n\n\n<p>Enable the fahclient service<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sysrc fahclient_enable=\"YES\"<\/pre>\n\n\n\n<p>Now, exit the jail&#8217;s console. For some reason I did not have linsysfs loaded (yet), so I had to load it. (I am copying all the things that were previously loaded in the BOINC instructions here):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo kldload linsysfs\nsudo kldload linux\nsudo kldload linux64\nsudo sysctl security.bsd.unprivileged_idprio=1<\/pre>\n\n\n\n<p>To make it permanent, add load_linsysfs=&#8221;YES&#8221; to \/boot\/loader.conf, linux_load=&#8221;YES&#8221; to \/etc\/rc.conf, and security.bsd.unprivileged_idprio=1 to \/etc\/sysctl.conf. (I already had it added.)<\/p>\n\n\n\n<p>Set up the correct entries in the Jail&#8217;s fstab:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo iocage fstab -e fah<\/pre>\n\n\n\n<p>Update to look as follows (change the absolute path to correspond to where your iocage jail sits in the host environment):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">proc                 \/tank\/iocage\/jails\/fah\/root\/proc                   procfs          rw        0       0\nlinproc              \/tank\/iocage\/jails\/fah\/root\/compat\/linux\/proc      linprocfs       rw        0       0\nlinsysfs             \/tank\/iocage\/jails\/fah\/root\/compat\/linux\/sys       linsysfs        rw        0       0<\/pre>\n\n\n\n<p>Now, it&#8217;s time to try it out:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo iocage stop fah\nsudo iocage start fah\nsudo iocage console fah\n# Now you're in the jail's console\/shell prompt:\nservice fahclient log<\/pre>\n\n\n\n<p>Hopefully, you should see something informative, and your CPU usage should start going up with assigned work.<\/p>\n\n\n\n<p>See my stats <a href=\"https:\/\/stats.foldingathome.org\/donor\/Wagh\">here<\/a>.<\/p>\n<\/p><div class='wp_likes' id='wp_likes_post-1058'><a class='like' href=\"javascript:wp_likes.like(1058);\" title='' ><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/tech.poojanblog.com\/blog\/wp-content\/plugins\/wp-likes\/images\/like.png\" alt='' border='0'\/><\/a><span class='text'>Be the first to like.<\/span><div class='like' ><a href=\"javascript:wp_likes.like(1058);\">Like<\/a><\/div><div class='unlike' ><a href=\"javascript:wp_likes.unlike(1058);\">Unlike<\/a><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Given the urgency for research on the novel COVID-19 virus, I have been running Rosetta@Home and Folding@Home on my Windows machine. BOINC (which powers Rosetta@Home) runs reasonably well on FreeBSD with some special instructions. I also wanted to run Folding@Home. I currently have a Linux VM in bhyve to do so. But, that is rather [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[252,251,250,12,249,176],"class_list":["post-1058","post","type-post","status-publish","format-standard","hentry","category-unix-linux","tag-charity","tag-compute","tag-foldinghome","tag-freebsd","tag-iocage","tag-jail"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/1058","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/comments?post=1058"}],"version-history":[{"count":50,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/1058\/revisions"}],"predecessor-version":[{"id":1110,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/1058\/revisions\/1110"}],"wp:attachment":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/media?parent=1058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/categories?post=1058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/tags?post=1058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}