<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Let's Play a Game</title><link>http://blog.mthode.org/</link><description></description><lastBuildDate>Wed, 24 Apr 2019 00:00:00 -0500</lastBuildDate><item><title>Building Gentoo disk images</title><link>http://blog.mthode.org/building-gentoo-disk-images.html</link><description>&lt;h2&gt;Disclaimer&lt;/h2&gt;
&lt;p&gt;I'm not responsible if you ruin your system, this guide functions as documentation for future me.  Remember to back up your data.&lt;/p&gt;
&lt;h2&gt;Why this is useful / needed&lt;/h2&gt;
&lt;p&gt;It's useful to have a way of building a disk image for shipping, either for testing or production usage.  The image output formats could be qcow2, raw or compressed tarball, it's up to you to make this what you want it to be.&lt;/p&gt;
&lt;h2&gt;Pre-work&lt;/h2&gt;
&lt;p&gt;Install diskimage-builder, for Gentoo you just have to 'emerge' the latest version.  I personally keep one around in a virtual environment for testing (this allows me to build musl images as well easily).&lt;/p&gt;
&lt;h2&gt;The actual setup&lt;/h2&gt;
&lt;p&gt;What diskimage-builder actually does is take elements and run them. Each elements consists of a set of phases where the element takes actions.  All you are really doing is defining the elements and they will insert themselves where needed.
It also uses environment variables for tunables, or for other various small tweaks.&lt;/p&gt;
&lt;p&gt;This is how I build the images at http://distfiles.gentoo.org/experimental/amd64/openstack/&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GENTOO_PORTAGE_CLEANUP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;True
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DIB_INSTALLTYPE_pip_and_virtualenv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;package
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DIB_INSTALLTYPE_simple_init&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;repo
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GENTOO_PYTHON_TARGETS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;python3_6&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GENTOO_PYTHON_ACTIVE_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;python3.6&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ELEMENTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gentoo simple-init growroot vm openssh-server block-device-mbr&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;COMMAND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;disk-image-create -a amd64 -t qcow2 --image-size 3&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;date -u +%Y%m%d&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;

&lt;span class="nv"&gt;GENTOO_PROFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;default/linux/amd64/17.0/no-multilib/hardened &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;COMMAND&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; -o &lt;span class="s2"&gt;&amp;quot;gentoo-openstack-amd64-hardened-nomultilib-&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ELEMENTS&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;GENTOO_PROFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;default/linux/amd64/17.0/no-multilib &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;COMMAND&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; -o &lt;span class="s2"&gt;&amp;quot;gentoo-openstack-amd64-default-nomultilib-&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ELEMENTS&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;GENTOO_PROFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;default/linux/amd64/17.0/hardened &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;COMMAND&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; -o &lt;span class="s2"&gt;&amp;quot;gentoo-openstack-amd64-hardened-&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ELEMENTS&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;GENTOO_PROFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;default/linux/amd64/17.0/systemd &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;COMMAND&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; -o &lt;span class="s2"&gt;&amp;quot;gentoo-openstack-amd64-systemd-&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ELEMENTS&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;COMMAND&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; -o &lt;span class="s2"&gt;&amp;quot;gentoo-openstack-amd64-default-&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ELEMENTS&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;For musl I've had to do some custom work as I have to build the stage4s locally, but it's largely the same (with the additional need to define a musl overlay.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/diskimage-builder
cp ~/10-gentoo-image.musl diskimage_builder/elements/gentoo/root.d/10-gentoo-image
pip install -U .
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/

&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GENTOO_PORTAGE_CLEANUP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;False
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DIB_INSTALLTYPE_pip_and_virtualenv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;package
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;DIB_INSTALLTYPE_simple_init&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;repo
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GENTOO_PYTHON_TARGETS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;python3_6&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GENTOO_PYTHON_ACTIVE_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;python3.6&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;date +%Y%m%d&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GENTOO_OVERLAYS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;musl&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GENTOO_PROFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;default/linux/amd64/17.0/musl/hardened

disk-image-create -a amd64 -t qcow2 --image-size &lt;span class="m"&gt;3&lt;/span&gt; -o gentoo-openstack-amd64-hardened-musl-&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DATE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; gentoo simple-init growroot vm

&lt;span class="nb"&gt;cd&lt;/span&gt; ~/diskimage-builder
git checkout diskimage_builder/elements/gentoo/root.d/10-gentoo-image
pip install -U .
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Generic images&lt;/h2&gt;
&lt;p&gt;The elements I use are for an OpenStack image, meaning there is no default user/pass, those are set by cloud-init / glean.  For a generic image you will want the following elements.&lt;/p&gt;
&lt;p&gt;'gentoo growroot devuser vm'&lt;/p&gt;
&lt;p&gt;The following environment variables are needed as well (changed to match your needs).&lt;/p&gt;
&lt;p&gt;DIB_DEV_USER_PASSWORD=supersecrete DIB_DEV_USER_USERNAME=secrete DIB_DEV_USER_PWDLESS_SUDO=yes DIB_DEV_USER_AUTHORIZED_KEYS=/foo/bar/.ssh/authorized_keys&lt;/p&gt;
&lt;h2&gt;Fin&lt;/h2&gt;
&lt;p&gt;All this work was done upstream, if you have a question (or feature request) just ask.  I'm on irc (Freenode) as prometheanfire or the same nick at gentoo.org for email.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Wed, 24 Apr 2019 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2019-04-24:/building-gentoo-disk-images.html</guid><category>stages</category><category>images</category><category>openstack</category></item><item><title>Native ZFS encryption for your rootfs</title><link>http://blog.mthode.org/native-zfs-encryption-for-your-rootfs.html</link><description>&lt;h2&gt;Disclaimer&lt;/h2&gt;
&lt;p&gt;I'm not responsible if you ruin your system, this guide functions as documentation for future me.  Remember to back up your data.&lt;/p&gt;
&lt;h2&gt;Why do this instead of luks&lt;/h2&gt;
&lt;p&gt;I wanted to remove a layer from the File to Disk layering, before it was ZFS -&amp;gt; LUKS -&amp;gt; disk, now it's ZFS -&amp;gt; disk.&lt;/p&gt;
&lt;h2&gt;Prework&lt;/h2&gt;
&lt;p&gt;I just got a new laptop and wanted to just migrate the data, luckily the old laptop was using ZFS as well, so the data could be sent/received though native ZFS means.&lt;/p&gt;
&lt;h2&gt;The actual setup&lt;/h2&gt;
&lt;p&gt;Set up your root pool with the encryption key, it will be inherited by all child datasets, no child datasets will be allowed to be unencrypted.&lt;/p&gt;
&lt;p&gt;In my case the pool name was &lt;code&gt;slaanesh-zp00&lt;/code&gt;, so I ran the following to create the fresh pool.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;zpool create -O &lt;span class="nv"&gt;encryption&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;on -O &lt;span class="nv"&gt;keyformat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;passphrase zfstest /dev/zvol/slaanesh-zp00/zfstest
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;After that just go on and create your datasets as normal, transfer old data as needed (it'll be encrypted as it's written).  See https://wiki.gentoo.org/wiki/ZFS for a good general guide on setting up your datasets.&lt;/p&gt;
&lt;h2&gt;decrypting at boot&lt;/h2&gt;
&lt;p&gt;If you are using dracut it should just work.  No changes to what you pass on the kernel command line are needed.  The code is upstream in https://github.com/zfsonlinux/zfs/blob/master/contrib/dracut/90zfs/zfs-load-key.sh.in&lt;/p&gt;
&lt;h2&gt;notes&lt;/h2&gt;
&lt;p&gt;Make sure you install from git master, there was a disk format change for encrypted datasets that just went in a week or so ago.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Sat, 10 Feb 2018 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2018-02-10:/native-zfs-encryption-for-your-rootfs.html</guid><category>dracut</category><category>zfs</category><category>linux</category></item><item><title>Undervolting your CPU for fun and profit</title><link>http://blog.mthode.org/undervolting-your-cpu-for-fun-and-profit.html</link><description>&lt;h2&gt;Disclaimer&lt;/h2&gt;
&lt;p&gt;I'm not responsible if you ruin your system, this guide functions as documentation for future me.  While this should just cause MCEs or system resets if done wrong it might also be able to ruin things in a more permanent way.&lt;/p&gt;
&lt;h2&gt;Why do this&lt;/h2&gt;
&lt;p&gt;It lowers temps generally and if you hit thermal throttling (as happens with my 5th Generation X1 Carbon) you may thermally throttle less often or at a higher frequency.&lt;/p&gt;
&lt;h2&gt;Prework&lt;/h2&gt;
&lt;p&gt;Repaste first, it's generally easier to do and can result in better gains (and it's all about them gains).  For instance, my Skull Canyon NUC was resetting itself thermally when stress testing.  Repasting lowered the max temps by 20°C.&lt;/p&gt;
&lt;h2&gt;Undervolting - The How&lt;/h2&gt;
&lt;p&gt;I based my info on https://github.com/mihic/linux-intel-undervolt which seems to work on my Intel Kaby Lake based laptop.&lt;/p&gt;
&lt;p&gt;Using the MSR registers to write the values via msr-tools wrmsr binary.&lt;/p&gt;
&lt;p&gt;The following python3 snippet is how I got the values to write.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# for a -110mv offset I run the following&lt;/span&gt;
&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xFFE00000&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.024&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="mh"&gt;0xFFF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;08x&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;What you are actually writing is actually as follows, with the plane index being for cpu, gpu or cache for 0, 1 or 2 respectively.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;constant&lt;/th&gt;
&lt;th&gt;plane index&lt;/th&gt;
&lt;th&gt;constant&lt;/th&gt;
&lt;th&gt;write/read&lt;/th&gt;
&lt;th&gt;offset&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;80000&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;F1E00000&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;So we end up with &lt;code&gt;0x80000011F1E00000&lt;/code&gt; to write to MSR register 0x150.&lt;/p&gt;
&lt;h2&gt;Undervolting - The Integration&lt;/h2&gt;
&lt;p&gt;I made a script in &lt;code&gt;/opt/bin/&lt;/code&gt;, where I place my custom system scripts called &lt;code&gt;undervolt.sh&lt;/code&gt; (make sure it's executable).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/usr/bin/env sh&lt;/span&gt;
/usr/sbin/wrmsr 0x150 0x80000011F1E00000  &lt;span class="c1"&gt;# cpu core  -110&lt;/span&gt;
/usr/sbin/wrmsr 0x150 0x80000211F1E00000  &lt;span class="c1"&gt;# cpu cache -110&lt;/span&gt;
/usr/sbin/wrmsr 0x150 0x80000111F4800000  &lt;span class="c1"&gt;# gpu core  -90&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I then made a custom systemd unit in &lt;code&gt;/etc/systemd/system&lt;/code&gt; called &lt;code&gt;undervolt.service&lt;/code&gt; with the following content.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[Unit]&lt;/span&gt;
&lt;span class="na"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;Undervolt Service&lt;/span&gt;

&lt;span class="k"&gt;[Service]&lt;/span&gt;
&lt;span class="na"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/opt/bin/undervolt.sh&lt;/span&gt;

&lt;span class="k"&gt;[Install]&lt;/span&gt;
&lt;span class="na"&gt;WantedBy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;multi-user.target&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I then &lt;code&gt;systemctl enable undervolt.service&lt;/code&gt; so I'll get my settings on boot.&lt;/p&gt;
&lt;p&gt;The following script was also placed in &lt;code&gt;/usr/lib/systemd/system-sleep/undervolt.sh&lt;/code&gt; to get the settings after recovering from sleep, as they are lost at that point.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;post&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  /opt/bin/undervolt.sh
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;That's it, everything after this point is what I went through in testing.&lt;/p&gt;
&lt;h2&gt;Testing for stability&lt;/h2&gt;
&lt;p&gt;I stress tested with mprime in stress mode for the CPU and glxmark or gputest for the GPU.  I only recorded the results for the CPU, as that's what I care about.&lt;/p&gt;
&lt;p&gt;No changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15-17W package tdp&lt;/li&gt;
&lt;li&gt;15W core tdp&lt;/li&gt;
&lt;li&gt;3.06-3.22 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;50mv Undervolt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15-16W package tdp&lt;/li&gt;
&lt;li&gt;14-15W core tdp&lt;/li&gt;
&lt;li&gt;3.22-3.43 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;70mv undervolt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15-16W package tdp&lt;/li&gt;
&lt;li&gt;14W core tdp&lt;/li&gt;
&lt;li&gt;3.22-3.43 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;90mv undervolt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15W package tdp&lt;/li&gt;
&lt;li&gt;13-14W core tdp&lt;/li&gt;
&lt;li&gt;3.32-3.54 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;100mv undervolt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15W package tdp&lt;/li&gt;
&lt;li&gt;13W core tdp&lt;/li&gt;
&lt;li&gt;3.42-3.67 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;110mv undervolt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15W package tdp&lt;/li&gt;
&lt;li&gt;13W core tdp&lt;/li&gt;
&lt;li&gt;3.42-3.67 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;started getting gfx artifacts, switched the gfx undervolt to 100 here&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;115mv undervolt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15W package tdp&lt;/li&gt;
&lt;li&gt;13W core tdp&lt;/li&gt;
&lt;li&gt;3.48-3.72 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;115mv undervolt with repaste:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15-16W package tdp&lt;/li&gt;
&lt;li&gt;14-15W core tdp&lt;/li&gt;
&lt;li&gt;3.63-3.81 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;120mv undervolt with repaste:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;15-16W package tdp&lt;/li&gt;
&lt;li&gt;14-15W core tdp&lt;/li&gt;
&lt;li&gt;3.63-3.81 Ghz&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I decided on 110mv cpu and 90mv gpu undervolt for stability, with proper ventilation I get about 3.7-3.8 Ghz out of a max of 3.9 Ghz.&lt;/p&gt;
&lt;p&gt;Other notes:
Undervolting made the cpu max speed less spiky.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Thu, 18 Jan 2018 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2018-01-18:/undervolting-your-cpu-for-fun-and-profit.html</guid><category>Hardware</category><category>Laptop</category><category>Linux</category></item><item><title>Gentoo Puppet Portage Package Provider</title><link>http://blog.mthode.org/gentoo-puppet-portage-package-provider.html</link><description>&lt;h2&gt;Why do this&lt;/h2&gt;
&lt;p&gt;The previus built in puppet portage package provider (I'm just going to shorten it to PPPP) only supported very simplistic package interactions.  Mainly package name (with slot) install and uninstall.  This has proven fairly limiting, if you want to install a specific version of a package and lock it down you were forced to call out to exec or editing &lt;code&gt;package.{mask,unmask,keywords}&lt;/code&gt; files.&lt;/p&gt;
&lt;p&gt;The new provider (which will be built into puppet in 5.0 or puppet-agent-2.0) supports all the package provider attributes.&lt;/p&gt;
&lt;h2&gt;How do I get this awesome thing&lt;/h2&gt;
&lt;p&gt;Emerge puppet or puppet-agent with the &lt;code&gt;experimental&lt;/code&gt; use flag.&lt;/p&gt;
&lt;h2&gt;What it can do&lt;/h2&gt;
&lt;p&gt;You can use the following attributes with the new PPPP.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Name - The full package atom works now, using &lt;code&gt;qatom&lt;/code&gt; on the backend.&lt;/li&gt;
&lt;li&gt;ensure - now allowing a package purge as well (&lt;code&gt;CONFIG_PROTECT="-*"&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;install_options - you can now pass options to emerge (&lt;code&gt;--deep&lt;/code&gt; or &lt;code&gt;--usepkgonly&lt;/code&gt; for example).&lt;/li&gt;
&lt;li&gt;uninstall_options - just like install_options&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Being able to call out specific versions and per package install options will give much greater flexability.&lt;/p&gt;
&lt;h2&gt;fin&lt;/h2&gt;
&lt;p&gt;Here is the &lt;a href="https://github.com/puppetlabs/puppet/pull/5498" title="pull request"&gt;pull request&lt;/a&gt; that upstream puppet merged.&lt;/p&gt;
&lt;p&gt;If you have any questions I'm on freenode as prometheanfire.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Sat, 10 Jun 2017 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2017-06-10:/gentoo-puppet-portage-package-provider.html</guid><category>Gentoo</category><category>puppet</category></item><item><title>Gentoo portage templates</title><link>http://blog.mthode.org/gentoo-portage-templates.html</link><description>&lt;h2&gt;Why do this&lt;/h2&gt;
&lt;p&gt;Gentoo is known for being somewhat complex to manage, making clusters of gentoo machines even more complex in most scenarios.  Using the following methods the configuration becomes easier.&lt;/p&gt;
&lt;p&gt;By the end of this you should be able to have a default hiera configuration for Gentoo while still being able to override it for specific use cases.  What makes the method I chose particularly powerful is the ability to delete default vales entirely, not just setting them to something else.&lt;/p&gt;
&lt;p&gt;Most of these methods came from my experience with chef that I thought would apply well to other config engines.  While some don't like shoving logic to the configuration template engine, I'm open to suggestions.&lt;/p&gt;
&lt;h2&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Puppet 4.x or puppet-agent with hiera support.&lt;/li&gt;
&lt;li&gt;Puppet's stdlib installed (specifically for delete_values stuff).&lt;/li&gt;
&lt;li&gt;(optional) use puppetserver instead of running this oneoff.&lt;/li&gt;
&lt;li&gt;Hiera configured to use the following configuration.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Hiera config&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;:merge_behavior&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;deeper&lt;/span&gt;
&lt;span class="l l-Scalar l-Scalar-Plain"&gt;:deep_merge_options&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt;
  &lt;span class="l l-Scalar l-Scalar-Plain"&gt;:merge_hash_arrays&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;true&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Basic Setup&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Convert the common portage configuraitons to templates.&lt;/li&gt;
&lt;li&gt;Convert the data in those templates to a datastructure.&lt;/li&gt;
&lt;li&gt;Use hiera to write the defaults / node overrides.&lt;/li&gt;
&lt;li&gt;Call the templates via a puppet module.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Datastructures&lt;/h2&gt;
&lt;p&gt;The easiest way of explaing how this works is to say that the only data stored in the 'deepest' value is ever going to be &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;.  The reason for this is a because using deep_merge in hiera is an additive process and we need a flag to remove things further down the line.&lt;/p&gt;
&lt;p&gt;The datastructure itself is fairly simple, here is an excerpt from my setup.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;make_conf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="nt"&gt;emerge_default_opts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;quot;--quiet-build&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;true&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;quot;--changed-use&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;true&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If I wanted to disable &lt;code&gt;--quiet-build&lt;/code&gt; down the line you would just set the value to &lt;code&gt;False&lt;/code&gt; in a higher precidence (the specific node config instead of the general location.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;make_conf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="nt"&gt;emerge_default_opts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;quot;--quiet-build&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;false&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Configuration Templates&lt;/h2&gt;
&lt;p&gt;The templates themselves are epp based, not erb (the old method).&lt;/p&gt;
&lt;h3&gt;package.keywords&lt;/h3&gt;
&lt;p&gt;For this one I'll also supply how I auto-set the right archetecture, works for amd64 at least.&lt;/p&gt;
&lt;h4&gt;Hiera data&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;app-admin/paxtest&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;~%{facts.architecture}&amp;quot;&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;true&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;Template&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&amp;amp;lt;%- |$packages| -%&amp;amp;gt;
# THIS FILE WAS GENERATED BY PUPPET, CHANGES WILL BE OVERWRITTEN

&amp;amp;lt;%- keys(delete_values($packages, false)).each |$package| { -%&amp;amp;gt;
&amp;amp;lt;%= &amp;quot;$package&amp;quot; %&amp;amp;gt;
&amp;amp;lt;%- } -%&amp;amp;gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This one is the simplest, if a value for the key (paxtest in this case) is set to false, don't use it, the remaining keys are then set as plan text.&lt;/p&gt;
&lt;h3&gt;package.use&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&amp;amp;lt;%- |$packages| -%&amp;amp;gt;
# THIS FILE WAS GENERATED BY PUPPET, CHANGES WILL BE OVERWRITTEN

&amp;amp;lt;%- keys(delete_values($packages, false)).each |$package| { -%&amp;amp;gt;
  &amp;amp;lt;%- if ! empty(keys(delete_values($packages[$package], false))) { -%&amp;amp;gt;
&amp;amp;lt;%= &amp;quot;$package&amp;quot; %&amp;amp;gt; &amp;amp;lt;%= join(keys(delete_values($packages[$package], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;
  &amp;amp;lt;%- } -%&amp;amp;gt;
&amp;amp;lt;%- } -%&amp;amp;gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This one is fairly straight forward as well, for each package that isn't disabled, if there are keys for the package (signifying use flags, needed because we remove the unset flags) then set them.  This combines the flags set from all levels in hiera.&lt;/p&gt;
&lt;h3&gt;make.conf&lt;/h3&gt;
&lt;p&gt;This will be the most complicated one, but it's also likely to be the most important.  I'll explain a bit about it after the paste.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&amp;amp;lt;%- |$config| -%&amp;amp;gt;
# THIS FILE WAS GENERATED BY PUPPET, CHANGES WILL BE OVERWRITTEN

CFLAGS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;cflags&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
CXXFLAGS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;cxxflags&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
CHOST=&amp;quot;&amp;amp;lt;%= $config[&amp;#39;chost&amp;#39;] %&amp;amp;gt;&amp;quot;
MAKEOPTS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;makeopts&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
CPU_FLAGS_X86=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;cpu_flags_x86&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
ABI_X86=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;abi_x86&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;

USE=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;use&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;

GENTOO_MIRRORS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;gentoo_mirrors&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
&amp;amp;lt;% if has_key($config, &amp;#39;portage_binhost&amp;#39;) { -%&amp;amp;gt;
  &amp;amp;lt;%- if $config[&amp;#39;portage_binhost&amp;#39;] != false { -%&amp;amp;gt;
PORTAGE_BINHOST=&amp;quot;&amp;amp;lt;%= $config[&amp;#39;portage_binhost&amp;#39;] %&amp;amp;gt;&amp;quot;
  &amp;amp;lt;%- } -%&amp;amp;gt;
&amp;amp;lt;% } -%&amp;amp;gt;

FEATURES=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;features&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
EMERGE_DEFAULT_OPTS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;emerge_default_opts&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
PKGDIR=&amp;quot;&amp;amp;lt;%= $config[&amp;#39;pkgdir&amp;#39;] %&amp;amp;gt;&amp;quot;
PORT_LOGDIR=&amp;quot;&amp;amp;lt;%= $config[&amp;#39;port_logdir&amp;#39;] %&amp;amp;gt;&amp;quot;
PORTAGE_GPG_DIR=&amp;quot;&amp;amp;lt;%= $config[&amp;#39;portage_gpg_dir&amp;#39;] %&amp;amp;gt;&amp;quot;
PORTAGE_GPG_KEY=&amp;#39;&amp;amp;lt;%= $config[&amp;#39;portage_gpg_key&amp;#39;] %&amp;amp;gt;&amp;#39;

GRUB_PLATFORMS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;grub_platforms&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
LINGUAS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;linguas&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
L10N=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;l10n&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;

PORTAGE_ELOG_CLASSES=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;portage_elog_classes&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
PORTAGE_ELOG_SYSTEM=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;portage_elog_system&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
PORTAGE_ELOG_MAILURI=&amp;quot;&amp;amp;lt;%= $config[&amp;#39;portage_elog_mailuri&amp;#39;] %&amp;amp;gt;&amp;quot;
PORTAGE_ELOG_MAILFROM=&amp;quot;&amp;amp;lt;%= $config[&amp;#39;portage_elog_mailfrom&amp;#39;] %&amp;amp;gt;&amp;quot;

&amp;amp;lt;% if has_key($config, &amp;#39;accept_licence&amp;#39;) { -%&amp;amp;gt;
ACCEPT_LICENSE=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;accept_licence&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
&amp;amp;lt;%- } -%&amp;amp;gt;
POLICY_TYPES=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;policy_types&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
PAX_MARKINGS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;pax_markings&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;

USE_PYTHON=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;use_python&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
PYTHON_TARGETS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;python_targets&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
RUBY_TARGETS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;ruby_targets&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;
PHP_TARGETS=&amp;quot;&amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;php_targets&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;&amp;quot;

&amp;amp;lt;% if has_key($config, &amp;#39;source&amp;#39;) { -%&amp;amp;gt;
source &amp;amp;lt;%= join(keys(delete_values($config[&amp;#39;source&amp;#39;], false)), &amp;#39; &amp;#39;) %&amp;amp;gt;
&amp;amp;lt;%- } -%&amp;amp;gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The basic idea of this is that you pass in the full make.conf datastructre you will generate as a single variable.  Everything else is pulled (or elemated from that).&lt;/p&gt;
&lt;p&gt;Each option that is selected already has all the options merged, but this could mean both the disabled versions of a given value could be still there, this is removed using the &lt;code&gt;delete_values($config['foo'], false)&lt;/code&gt; bit.&lt;/p&gt;
&lt;h2&gt;The puppet module itself&lt;/h2&gt;
&lt;p&gt;It's fairly easy to call, just make sure the template is in the template location and do it as follows.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;file&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;/etc/portage/make.conf&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;&amp;amp;&lt;/span&gt;&lt;span class="na"&gt;gt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="na"&gt;epp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;portage/portage-make_conf.epp&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;config&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;&amp;amp;&lt;/span&gt;&lt;span class="na"&gt;gt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="na"&gt;hiera_hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;portage&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;make_conf&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;fin&lt;/h2&gt;
&lt;p&gt;If you have any questions I'm on freenode as prometheanfire.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Sat, 03 Jun 2017 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2017-06-03:/gentoo-portage-templates.html</guid><category>Gentoo</category><category>puppet</category></item><item><title>Gentoo at Fosdem</title><link>http://blog.mthode.org/gentoo-at-fosdem.html</link><description>&lt;h2&gt;At the stand&lt;/h2&gt;
&lt;p&gt;It was nice to meet everyone and hang out as well.  There was an interview with &lt;a href="http://hackerpublicradio.org/"&gt;Hacker Public Radio&lt;/a&gt; which you can find &lt;a href="http://ftp.heanet.ie/mirrors/fosdem-video/2017/stands/K1B.2_Gentoo.flac"&gt;HERE&lt;/a&gt; as well.&lt;/p&gt;
&lt;p&gt;Just a short one this time, but it was nice to meet everyone.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Thu, 09 Feb 2017 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2017-02-09:/gentoo-at-fosdem.html</guid><category>Gentoo</category></item><item><title>Openstack Newton Update</title><link>http://blog.mthode.org/openstack-newton-update.html</link><description>&lt;h2&gt;The short of it&lt;/h2&gt;
&lt;p&gt;Openstack Newton was packaged early last week (when rc2 was still going on upstream) and the tags for the major projects were packaged the day they released (nova and the like).&lt;/p&gt;
&lt;p&gt;I've updated the openstack-meta package to 2016.2.9999 and would recommend people use that.&lt;/p&gt;
&lt;p&gt;Heat has also been packaged this time around so you are able to use that if you wish.&lt;/p&gt;
&lt;p&gt;I'll link to my &lt;a href="https://dev.gentoo.org/~prometheanfire/dist/openstack/newton.keywords" title="newton.keywords"&gt;keywords&lt;/a&gt; and &lt;a href="https://dev.gentoo.org/~prometheanfire/dist/openstack/newton.use" title="newton.use"&gt;use&lt;/a&gt; files so you may use them if you wish as well.  Please keep in mind that my use file is for my personal setup (static kernel, vxlan/linuxbridge and postgresql)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Tue, 11 Oct 2016 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2016-10-11:/openstack-newton-update.html</guid><category>openstack</category><category>Gentoo</category></item><item><title>Gentoo, Openstack and OSIC</title><link>http://blog.mthode.org/gentoo-openstack-and-osic.html</link><description>&lt;h2&gt;What to use it for&lt;/h2&gt;
&lt;p&gt;I recently applied for, and use an allocation from https://osic.org/ do extend more support for running Openstack on Gentoo.
The end goal of this is to allow Gentoo to become a gated job within the Openstack test infrastructure.
To do that, we need to add support for building an image that can be used.&lt;/p&gt;
&lt;h2&gt;(pre)work&lt;/h2&gt;
&lt;p&gt;To speed up the work on adding support for generating an openstack infra Gentoo image I already completed work on adding Gentoo to diskimage builder.
You can see images at http://gentoo.osuosl.org/experimental/amd64/openstack/&lt;/p&gt;
&lt;h2&gt;(actual)work&lt;/h2&gt;
&lt;p&gt;The actual work has been slow going unfortunately, working with upstreams to add Gentoo support has tended to find other issues that need fixing along the way.
The main thing that slowed me down though was the Openstack summit (Newton).  That went on at the same time and reveiws were delated at least a week, usually two.&lt;/p&gt;
&lt;p&gt;Since then though I've been able to work though some of the issues and have started testing the final image build in diskimage builder.&lt;/p&gt;
&lt;h2&gt;More to do&lt;/h2&gt;
&lt;p&gt;The main things left to do is to add gentoo support to the bindep elemet within diskimage builder and finish and other rough edges in other elements (if they exist).
After that, Openstack Infra can start caching a Gentoo image and the real work can begin.  Adding Gentoo support to the Openstack Ansible project to allow for better deployments.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Mon, 06 Jun 2016 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2016-06-06:/gentoo-openstack-and-osic.html</guid><category>openstack</category><category>Gentoo</category></item><item><title>Of OpenStack and uwsgi</title><link>http://blog.mthode.org/of-openstack-and-uwsgi.html</link><description>&lt;h2&gt;Why use uwsgi&lt;/h2&gt;
&lt;p&gt;Not all OpenStack services support uwsgi. However, in the Liberty timeframe it is supported as the primary way to run Keystone api services and recommended way of running Horizon (if you use it).
Going forward other openstack services will be movnig to support it as well, for instance I know that Neutron is working on it or have it completed for the Mitaka release.&lt;/p&gt;
&lt;h2&gt;Basic Setup&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Install &lt;code&gt;&amp;gt;=www-servers/uwsgi-2.0.11.2-r1&lt;/code&gt; with the &lt;code&gt;python&lt;/code&gt; use flag as it has an updated init script.&lt;/li&gt;
&lt;li&gt;Make sure you note the group you want for the webserver to access the uwsgi sockets, I chose nginx.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Configs and permissions&lt;/h2&gt;
&lt;p&gt;When defaults are available I will only note what needs to change.&lt;/p&gt;
&lt;h3&gt;uwsgi configs&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;/etc/conf.d/uwsgi&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;UWSGI_EMPEROR_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/etc/uwsgi.d/&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;UWSGI_EMPEROR_GROUP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;nginx
&lt;span class="nv"&gt;UWSGI_EXTRA_OPTIONS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--need-plugins python27&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;code&gt;/etc/uwsgi.d/keystone-admin.ini&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;uwsgi&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;master&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="nv"&gt;plugins&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; python27
&lt;span class="nv"&gt;processes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
&lt;span class="nv"&gt;threads&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
chmod-socket &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;660&lt;/span&gt;

&lt;span class="nv"&gt;socket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /run/uwsgi/keystone_admin.socket
&lt;span class="nv"&gt;pidfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /run/uwsgi/keystone_admin.pid
&lt;span class="nv"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; file:/var/log/keystone/uwsgi-admin.log

&lt;span class="nv"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; keystone
&lt;span class="nv"&gt;uid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; keystone
&lt;span class="nv"&gt;gid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; nginx

&lt;span class="nv"&gt;chdir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /var/www/keystone/
wsgi-file &lt;span class="o"&gt;=&lt;/span&gt; /var/www/keystone/admin
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;code&gt;/etc/uwsgi.d/keystone-main.ini&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;uwsgi&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;master&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;span class="nv"&gt;plugins&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; python27
&lt;span class="nv"&gt;processes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;
&lt;span class="nv"&gt;threads&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
chmod-socket &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;660&lt;/span&gt;

&lt;span class="nv"&gt;socket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /run/uwsgi/keystone_main.socket
&lt;span class="nv"&gt;pidfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /run/uwsgi/keystone_main.pid
&lt;span class="nv"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; file:/var/log/keystone/uwsgi-main.log

&lt;span class="nv"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; keystone
&lt;span class="nv"&gt;uid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; keystone
&lt;span class="nv"&gt;gid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; nginx

&lt;span class="nv"&gt;chdir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /var/www/keystone/
wsgi-file &lt;span class="o"&gt;=&lt;/span&gt; /var/www/keystone/main
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I have horizon in use via a virtual environment so enabled vaccum in this config.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/etc/uwsgi.d/horizon.ini&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;uwsgi&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;master&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;  
&lt;span class="nv"&gt;plugins&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; python27
&lt;span class="nv"&gt;processes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;  
&lt;span class="nv"&gt;threads&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;  
chmod-socket &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;660&lt;/span&gt;
&lt;span class="nv"&gt;vacuum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;

&lt;span class="nv"&gt;socket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /run/uwsgi/horizon.sock  
&lt;span class="nv"&gt;pidfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /run/uwsgi/horizon.pid  
log-syslog &lt;span class="o"&gt;=&lt;/span&gt; file:/var/log/horizon/horizon.log

&lt;span class="nv"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; horizon
&lt;span class="nv"&gt;uid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; horizon
&lt;span class="nv"&gt;gid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; nginx

&lt;span class="nv"&gt;chdir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; /var/www/horizon/
wsgi-file &lt;span class="o"&gt;=&lt;/span&gt; /var/www/horizon/horizon.wsgi
&lt;/pre&gt;&lt;/div&gt;


&lt;h3&gt;wsgi scripts&lt;/h3&gt;
&lt;p&gt;The directories are owned by the serverice they are containing, keystone:keystone or horizon:horizon.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/var/www/keystone/admin&lt;/code&gt; perms are &lt;code&gt;0750 keystone:keystone&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# Copyright 2013 OpenStack Foundation&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#    Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;); you may&lt;/span&gt;
&lt;span class="c1"&gt;#    not use this file except in compliance with the License. You may obtain&lt;/span&gt;
&lt;span class="c1"&gt;#    a copy of the License at&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#         http://www.apache.org/licenses/LICENSE-2.0&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#    Unless required by applicable law or agreed to in writing, software&lt;/span&gt;
&lt;span class="c1"&gt;#    distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS, WITHOUT&lt;/span&gt;
&lt;span class="c1"&gt;#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the&lt;/span&gt;
&lt;span class="c1"&gt;#    License for the specific language governing permissions and limitations&lt;/span&gt;
&lt;span class="c1"&gt;#    under the License.&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;keystone.server&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;wsgi&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;wsgi_server&lt;/span&gt;


&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vm"&gt;__file__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# NOTE(ldbragst): &amp;#39;application&amp;#39; is required in this context by WSGI spec.&lt;/span&gt;
&lt;span class="c1"&gt;# The following is a reference to Python Paste Deploy documentation&lt;/span&gt;
&lt;span class="c1"&gt;# http://pythonpaste.org/deploy/&lt;/span&gt;
&lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wsgi_server&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initialize_application&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;code&gt;/var/www/keystone/main&lt;/code&gt; perms are &lt;code&gt;0750 keystone:keystone&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# Copyright 2013 OpenStack Foundation&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#    Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;); you may&lt;/span&gt;
&lt;span class="c1"&gt;#    not use this file except in compliance with the License. You may obtain&lt;/span&gt;
&lt;span class="c1"&gt;#    a copy of the License at&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#         http://www.apache.org/licenses/LICENSE-2.0&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#    Unless required by applicable law or agreed to in writing, software&lt;/span&gt;
&lt;span class="c1"&gt;#    distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS, WITHOUT&lt;/span&gt;
&lt;span class="c1"&gt;#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the&lt;/span&gt;
&lt;span class="c1"&gt;#    License for the specific language governing permissions and limitations&lt;/span&gt;
&lt;span class="c1"&gt;#    under the License.&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;keystone.server&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;wsgi&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;wsgi_server&lt;/span&gt;


&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vm"&gt;__file__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# NOTE(ldbragst): &amp;#39;application&amp;#39; is required in this context by WSGI spec.&lt;/span&gt;
&lt;span class="c1"&gt;# The following is a reference to Python Paste Deploy documentation&lt;/span&gt;
&lt;span class="c1"&gt;# http://pythonpaste.org/deploy/&lt;/span&gt;
&lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wsgi_server&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initialize_application&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Note that this has paths to where I have my horizon virtual environment.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/var/www/horizon/horizon.wsgi&lt;/code&gt; perms are &lt;code&gt;0750 horizon:horizon&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/usr/bin/env python&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;


&lt;span class="n"&gt;activate_this&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;/home/horizon/horizon/.venv/bin/activate_this.py&amp;#39;&lt;/span&gt;
&lt;span class="nb"&gt;execfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;activate_this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vm"&gt;__file__&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;activate_this&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;/home/horizon/horizon&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;DJANGO_SETTINGS_MODULE&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;openstack_dashboard.settings&amp;#39;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;django.core.wsgi&lt;/span&gt;
&lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;django&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wsgi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_wsgi_application&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Wed, 23 Mar 2016 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2016-03-23:/of-openstack-and-uwsgi.html</guid><category>openstack</category><category>Gentoo</category></item><item><title>Creating Gentoo VM Images</title><link>http://blog.mthode.org/creating-gentoo-vm-images.html</link><description>&lt;h2&gt;Initial Setup and Info&lt;/h2&gt;
&lt;p&gt;This guide uses Openstack's Diskimage-builder tool for generation of images, while you can use this for Openstack, you can also create generic images with it.&lt;/p&gt;
&lt;p&gt;Setting up Diskimage-builder is fairly simple, when you use it, it does expect to be run as root.&lt;/p&gt;
&lt;p&gt;All you need to do is follow &lt;a href="http://docs.openstack.org/developer/diskimage-builder/user_guide/installation.html"&gt;this guide&lt;/a&gt;, at it's simplest it's just a couple of git clones and &lt;code&gt;PATH&lt;/code&gt; setup.&lt;/p&gt;
&lt;p&gt;You will need &lt;code&gt;app-emulation/qemu&lt;/code&gt; for generation of qcow2 files.&lt;/p&gt;
&lt;p&gt;The current setup utilizes the stage4 images being generated, see &lt;a href="https://mthode.org/posts/2016/Jan/stage4-tarballs-minimal-and-cloud/"&gt;this link&lt;/a&gt; for more details.&lt;/p&gt;
&lt;p&gt;There are currently only 4 profiles supported, however I hope to support musl and selinux profiles 'soon'.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;default/linux/amd64/13.0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;default/linux/amd64/13.0/no-multilib&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hardened/linux/amd64&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hardened/linux/amd64/no-multilib&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Generating an Openstack image&lt;/h2&gt;
&lt;p&gt;To use a profile other than &lt;code&gt;default/linux/amd64/13.0&lt;/code&gt; set the &lt;code&gt;GENTOO_PROFILE&lt;/code&gt; environment variable to one of the other supported profiles.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;disk-image-create -a amd64 -t qcow2 --image-size 2 gentoo simple-init growroot vm&lt;/code&gt; is all you need to start.  It will output a file named &lt;code&gt;image.qcow2&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For openstack there are two ways you could go for initial setup (post-vm start).  The first and most common is cloud-init, but that includes a few python deps that I don't think are really needed.  The other is simple-init (glean), which is more limited, but as it's name suggests, simple.&lt;/p&gt;
&lt;p&gt;Here is a link to glean (simple-init) for those wanting more info &lt;a href="https://github.com/openstack-infra/glean/"&gt;glean&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Generating a Generic Image You Can Log Into&lt;/h2&gt;
&lt;p&gt;Using the &lt;code&gt;devuser&lt;/code&gt; element you can set up custom users.  You will need to set up some more environment variables though.&lt;/p&gt;
&lt;p&gt;Docs can be found &lt;a href="https://github.com/openstack/diskimage-builder/tree/master/elements/devuser"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;An example invocation follows, simple-init may be needed so that interfaces get dhcp addresses, though you may wat to set that up manually, your choice.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;DIB_DEV_USER_PASSWORD=foobar DIB_DEV_USER_USERNAME=gentoo DIB_DEV_USER_PWDLESS_SUDO=yes DIB_DEV_USER_AUTHORIZED_KEYS=/dev/null disk-image-create -a amd64 -t qcow2 --image-size 2 gentoo simple-init growroot devuser vm&lt;/code&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Thu, 18 Feb 2016 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2016-02-18:/creating-gentoo-vm-images.html</guid><category>openstack</category><category>Gentoo</category></item><item><title>Stage4 tarballs, minimal and cloud</title><link>http://blog.mthode.org/stage4-tarballs-minimal-and-cloud.html</link><description>&lt;h2&gt;Where are they&lt;/h2&gt;
&lt;p&gt;The tarballs can be found in the &lt;a href="http://distfiles.gentoo.org/releases/amd64/autobuilds/"&gt;normal place&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Minimal&lt;/h2&gt;
&lt;p&gt;This is meant to be just what you need to boot, the disk won't expand itself, it won't even get networking info or set any passwords for you (no default password).&lt;/p&gt;
&lt;p&gt;This tarball is suposed to be the base you generate more complex images from, it is what is going to be used by Openstack's diskimage-builder.&lt;/p&gt;
&lt;p&gt;The primary things it does is get you a kernel, bootloader and sshd.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://gitweb.gentoo.org/proj/releng.git/tree/releases/weekly/specs/amd64/stage4-minimal.spec"&gt;stage4-minimal spec&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Cloud&lt;/h2&gt;
&lt;p&gt;This was primarilly targeted for use with openstack but it should work with amazon as well, both use cloud-init.&lt;/p&gt;
&lt;p&gt;Network interfaces are expected to use dhcp, a couple of other useful things are installed as well, syslog, logrotate, etc.&lt;/p&gt;
&lt;p&gt;By default cloud-init will take data (keys mainly) and set them up for the 'gentoo' user.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://gitweb.gentoo.org/proj/releng.git/tree/releases/weekly/specs/amd64/stage4-cloud.spec"&gt;stage4-cloud spec&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Next&lt;/h2&gt;
&lt;p&gt;I'll be posting about the work being done to take these stages and build bootable images.  At the momebt I do have images available here.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://gentoo.osuosl.org/experimental/amd64/openstack/"&gt;openstack images&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Fri, 29 Jan 2016 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2016-01-29:/stage4-tarballs-minimal-and-cloud.html</guid><category>openstack</category><category>Gentoo</category></item><item><title>Of OpenStack and SSL</title><link>http://blog.mthode.org/of-openstack-and-ssl.html</link><description>&lt;h2&gt;SSL in vanila OpenStack&lt;/h2&gt;
&lt;p&gt;The nature of OpenStack projects is largely like projects in Gentoo.  Even though they are all under the OpenStack umbrella that doesn't mean they all have to work the same, or even work together.&lt;/p&gt;
&lt;p&gt;For instance, nova has the ability to do ssl itself, you can define a CA and public/private keypair.   Glance (last time I checked) doesn't do ssl yourself so you must offload it.  Other service might do ssl themselves but not in the same way nova does it.&lt;/p&gt;
&lt;p&gt;This means that the most 'standard' setup would be to not run ssl, but this isn't exactly desirable.  So run a ssl reverse proxy.&lt;/p&gt;
&lt;h2&gt;Basic Setup&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;OpenStack services are set up on one host (just in this example).&lt;/li&gt;
&lt;li&gt;OpenStack services are configed to listen on localhost only.&lt;/li&gt;
&lt;li&gt;Public, Internal and Admin URLs need to be defined with https.&lt;/li&gt;
&lt;li&gt;Some tuning needs to be done so services work properly, primarily to glance and nova-novnc.&lt;/li&gt;
&lt;li&gt;Nginx is used as the reverse proxy.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Configs and Tuning&lt;/h2&gt;
&lt;h3&gt;General Config for All Services/Sites&lt;/h3&gt;
&lt;p&gt;This is the basic setup for each of the openstack services, the only difference between them will be what goes in the location subsection.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;server &lt;span class="o"&gt;{&lt;/span&gt;
    listen LOCAL_PUBLIC_IPV4:PORT&lt;span class="p"&gt;;&lt;/span&gt;
    listen &lt;span class="o"&gt;[&lt;/span&gt;LOCAL_PUBLIC_IPV6&lt;span class="o"&gt;]&lt;/span&gt;:PORT&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;server_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; name.subdomain.example.com&lt;span class="p"&gt;;&lt;/span&gt;
    access_log /var/log/nginx/keystone/access.log&lt;span class="p"&gt;;&lt;/span&gt;
    error_log /var/log/nginx/keystone/error.log&lt;span class="p"&gt;;&lt;/span&gt;

    ssl on&lt;span class="p"&gt;;&lt;/span&gt;
    ssl_certificate /etc/nginx/ssl/COMBINED_PUB_PRIV_KEY.pem&lt;span class="p"&gt;;&lt;/span&gt;
    ssl_certificate_key /etc/nginx/ssl/COMBINED_PUB_PRIV_KEY.pem&lt;span class="p"&gt;;&lt;/span&gt;
    add_header Public-Key-Pins &lt;span class="s1"&gt;&amp;#39;pin-sha256=&amp;quot;PUB_KEY_PIN_SHA&amp;quot;; max-age=2592000; includeSubDomains&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    ssl_dhparam /etc/nginx/params.4096&lt;span class="p"&gt;;&lt;/span&gt;
    resolver TRUSTED_DNS_SERVER&lt;span class="p"&gt;;&lt;/span&gt;
    resolver_timeout 5s&lt;span class="p"&gt;;&lt;/span&gt;
    ssl_stapling on&lt;span class="p"&gt;;&lt;/span&gt;
    ssl_stapling_verify on&lt;span class="p"&gt;;&lt;/span&gt;
    ssl_trusted_certificate /etc/nginx/ssl/COMBINED_PUB_PRIV_KEY.pem&lt;span class="p"&gt;;&lt;/span&gt;
    add_header X-XSS-Protection &lt;span class="s2"&gt;&amp;quot;1; mode=block&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    add_header Content-Security-Policy &lt;span class="s2"&gt;&amp;quot;default-src &amp;#39;self&amp;#39; https: wss:;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    add_header Strict-Transport-Security &lt;span class="s2"&gt;&amp;quot;max-age=31536000; includeSubdomains; preload&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    add_header X-Frame-Options DENY&lt;span class="p"&gt;;&lt;/span&gt;
    add_header X-Content-Type-Options nosniff&lt;span class="p"&gt;;&lt;/span&gt;

    location / &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;# this changes depending on the service&lt;/span&gt;
        proxy_pass http://127.0.0.1:PORT&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h3&gt;Keystone and Uwsgi&lt;/h3&gt;
&lt;p&gt;It turns out keystone has switched to uwsgi for it's service backend.  This is good because it means we can have the web server connect to that, no more trying to do it all by itself.  I'll leave the setting up of uwsgi itself as an exercise to the reader :P&lt;/p&gt;
&lt;p&gt;Please keep in mind keystone has two services, admin and main (ports 35357 and 5000 by default).&lt;/p&gt;
&lt;p&gt;This config has a few extra things, but it is currently what I know to be 'secure' (similiar config on this blog gets an A+ on all those ssl test things).  It's the last location piece that changes the most between services.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;location / &lt;span class="o"&gt;{&lt;/span&gt;
    uwsgi_pass unix:///run/uwsgi/keystone_admin.socket&lt;span class="p"&gt;;&lt;/span&gt;
    include /etc/nginx/uwsgi_params&lt;span class="p"&gt;;&lt;/span&gt;
    uwsgi_param SCRIPT_NAME &lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h3&gt;Glance&lt;/h3&gt;
&lt;p&gt;Glance just needs one thing on top of the general proxying that it needs.  It needs &lt;code&gt;client_max_body_size 0;&lt;/code&gt; in the main server stanza so that you can upload images without being cut off at some low size.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;client_max_body_size &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
location / &lt;span class="o"&gt;{&lt;/span&gt;
    proxy_pass http://127.0.0.1:9191&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h3&gt;Nova&lt;/h3&gt;
&lt;p&gt;The serviecs for nova just need the basic proxy_pass line.  The only exception is novnc, it needs some proxy headers passed.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;location / &lt;span class="o"&gt;{&lt;/span&gt;
    proxy_pass http://127.0.0.1:6080&lt;span class="p"&gt;;&lt;/span&gt;
    proxy_http_version &lt;span class="m"&gt;1&lt;/span&gt;.1&lt;span class="p"&gt;;&lt;/span&gt;
    proxy_set_header Host &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    proxy_set_header Upgrade &lt;span class="nv"&gt;$http_upgrade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Rabbitmq&lt;/h2&gt;
&lt;p&gt;Rabbit is fairly simple, you just need to enable ssl and disable the plaintext port (setting up your config of course).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;ssl, &lt;span class="o"&gt;[{&lt;/span&gt;versions, &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;tlsv1.2&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;tlsv1.1&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]}]}&lt;/span&gt;,
    &lt;span class="o"&gt;{&lt;/span&gt;rabbit, &lt;span class="o"&gt;[&lt;/span&gt;
        &lt;span class="o"&gt;{&lt;/span&gt;tcp_listeners, &lt;span class="o"&gt;[]}&lt;/span&gt;,
        &lt;span class="o"&gt;{&lt;/span&gt;ssl_listeners, &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="m"&gt;5671&lt;/span&gt;&lt;span class="o"&gt;]}&lt;/span&gt;,
        &lt;span class="o"&gt;{&lt;/span&gt;ssl_options, &lt;span class="o"&gt;[{&lt;/span&gt;cacertfile,&lt;span class="s2"&gt;&amp;quot;/etc/rabbitmq/ssl/CA_CERT.pem&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;,
                       &lt;span class="o"&gt;{&lt;/span&gt;certfile,  &lt;span class="s2"&gt;&amp;quot;/etc/rabbitmq/ssl/PUB_KEY.pem&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;,
                       &lt;span class="o"&gt;{&lt;/span&gt;keyfile,   &lt;span class="s2"&gt;&amp;quot;PRIV_KEYKEY.key&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;,
                       &lt;span class="o"&gt;{&lt;/span&gt;versions, &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;tlsv1.2&amp;#39;&lt;/span&gt;, &lt;span class="s1"&gt;&amp;#39;tlsv1.1&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]}&lt;/span&gt;
                      &lt;span class="o"&gt;]&lt;/span&gt;
        &lt;span class="o"&gt;}]&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;.
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Openstack Configs&lt;/h2&gt;
&lt;p&gt;The openstack configs can differ slightly but they are all mostly the same now they are using the same libraries (oslo stuff).&lt;/p&gt;
&lt;h4&gt;General Config&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;keystone_authtoken&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;auth_uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https://name.subdomain.example.com:5000
&lt;span class="nv"&gt;auth_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https://name.subdomain.example.com:35357

&lt;span class="o"&gt;[&lt;/span&gt;oslo_messaging_rabbit&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;rabbit_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; name.subdomain.example.com
&lt;span class="nv"&gt;rabbit_port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;5671&lt;/span&gt;
&lt;span class="nv"&gt;rabbit_use_ssl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; True
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;Nova&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;osapi_compute_listen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;127&lt;/span&gt;.0.0.1
&lt;span class="nv"&gt;metadata_listen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;127&lt;/span&gt;.0.0.1
&lt;span class="nv"&gt;novncproxy_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;127&lt;/span&gt;.0.0.1
&lt;span class="nv"&gt;enabled_apis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; osapi_compute, metadata
&lt;span class="o"&gt;[&lt;/span&gt;vnc&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;novncproxy_base_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https://name.subdomain.example.com:6080/vnc_auto.html
&lt;span class="c1"&gt;# the following only on the &amp;#39;master&amp;#39; host&lt;/span&gt;
&lt;span class="nv"&gt;vncserver_proxyclient_address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;.2.3.4
&lt;span class="nv"&gt;vncserver_listen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;.2.3.4

&lt;span class="o"&gt;[&lt;/span&gt;glance&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; name.subdomain.example.com
&lt;span class="nv"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https
&lt;span class="nv"&gt;api_servers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https://name.subdomain.example.com:9292

&lt;span class="o"&gt;[&lt;/span&gt;neutron&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https://name.subdomain.example.com:9696
&lt;span class="nv"&gt;auth_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https://name.subdomain.example.com:35357
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;Cinder&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# api-servers get this&lt;/span&gt;
&lt;span class="nv"&gt;osapi_volume_listen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;127&lt;/span&gt;.0.0.1

&lt;span class="c1"&gt;# volume-servers and api-servers get this&lt;/span&gt;
&lt;span class="nv"&gt;glance_api_servers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://name.subdomain.example.com:9292
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;Glance&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;glance_api_servers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://name.subdomain.example.com:9292
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;Glance&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# api&lt;/span&gt;
&lt;span class="nv"&gt;bind_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;127&lt;/span&gt;.0.0.1
&lt;span class="nv"&gt;registry_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; name.subdomain.example.com
&lt;span class="nv"&gt;registry_port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;9191&lt;/span&gt;
&lt;span class="nv"&gt;registry_client_protocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# cache&lt;/span&gt;
&lt;span class="nv"&gt;registry_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; name.subdomain.example.com
&lt;span class="nv"&gt;registry_port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;9191&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# registry&lt;/span&gt;
&lt;span class="nv"&gt;bind_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;127&lt;/span&gt;.0.0.1
&lt;span class="nv"&gt;rabbit_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; name.subdomain.example.com
&lt;span class="nv"&gt;rabbit_port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;5671&lt;/span&gt;
&lt;span class="nv"&gt;rabbit_use_ssl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; True
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# scrubber&lt;/span&gt;
&lt;span class="nv"&gt;registry_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; name.subdomain.example.com
&lt;span class="nv"&gt;registry_port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;9191&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h4&gt;Neutron&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# neutron.conf&lt;/span&gt;
&lt;span class="nv"&gt;bind_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;127&lt;/span&gt;.0.0.1
&lt;span class="nv"&gt;nova_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https://name.subdomain.example.com:8774/v2

&lt;span class="o"&gt;[&lt;/span&gt;nova&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;auth_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https://name.subdomain.example.com:35357
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# metadata_agent.ini&lt;/span&gt;
&lt;span class="nv"&gt;nova_metadata_ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; name.subdomain.example.com
&lt;span class="nv"&gt;nova_metadata_protocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; https
&lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Mon, 18 Jan 2016 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2016-01-18:/of-openstack-and-ssl.html</guid><category>openstack</category><category>Gentoo</category><category>security</category></item><item><title>OpenStack on Gentoo is awesome</title><link>http://blog.mthode.org/openstack-on-gentoo-is-awesome.html</link><description>&lt;p&gt;Some may wonder why to run OpenStack on Gentoo, it's akin to running one extremely complex piece of software on another potentially extremely complex operating system.&lt;/p&gt;
&lt;p&gt;I propose Gentoo as the most correct operating system to run OpenStack as Gentoo is best prepared to handle some of the complexities that come with OpenStack.&lt;/p&gt;
&lt;h2&gt;Things Gentoo does well for OpenStack&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Dependency resolution - we can take upstream's dependencies (requirements.txt) and map it directly to Gentoo's packages without changing the versions supported.  This is not always the case in other distributions.&lt;/li&gt;
&lt;li&gt;Because of this we can better rely on upstream's testing as validation that OpenStack on Gentoo will work properly.&lt;/li&gt;
&lt;li&gt;useflags - some dependencies (such as memcached, qemu, etc) are optional depending on what services you are running.&lt;/li&gt;
&lt;li&gt;python3 support - as upstream is finally moving to python3 we are easily able to extend support as it occurs.&lt;/li&gt;
&lt;li&gt;patching - https://wiki.gentoo.org/wiki//etc/portage/patches allows users to patch anything as needed.&lt;/li&gt;
&lt;li&gt;Upstream vanilla Openstack - We are not carrying many (I can count them on one hand) patches that are not upstreamed.&lt;/li&gt;
&lt;li&gt;Testing - All the major services have testing support to validate good installs and / or custom patches not breaking things.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Future of OpenStack on Gentoo&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;The Liberty release 15/10/2015&lt;ul&gt;
&lt;li&gt;Upstream is reversioning the major components of OpenStack, 2015.2.0 will not exist, it will be something like 12.0.0.&lt;/li&gt;
&lt;li&gt;The reversioning will mean some manual intervention if you wish to use Liberty on Gentoo, namely you will need to mask greater than version 2000 of the major components of OpenStack&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;More services&lt;ul&gt;
&lt;li&gt;I will at least add Heat during the next (Liberty) release cycle, possibly more&lt;/li&gt;
&lt;li&gt;I will investigate readding Horizon, but doubt it'll be easily packagable.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Security&lt;ul&gt;
&lt;li&gt;I'd like to look into some of the selinux policies that are being developed for some of the services.  I know nova/qemu has apparmor support.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Limits of testing&lt;/h2&gt;
&lt;p&gt;You cannot directly test OpenStack packages by emerging with USE="test" FEATURES="test" because there are interdepenecies that cause loops in the depgraph of portage for the (test) dependencies.  You can get around it one way though.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# install only the test deps&lt;/span&gt;
emerge --onlydeps --oneshot --with-test-deps sys-cluster/nova
&lt;span class="c1"&gt;# test and install the actual package&lt;/span&gt;
&lt;span class="nv"&gt;USE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test&amp;quot;&lt;/span&gt; &lt;span class="nv"&gt;FEATURES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;test&amp;quot;&lt;/span&gt; emerge sys-cluster/nova
&lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Thu, 24 Sep 2015 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2015-09-24:/openstack-on-gentoo-is-awesome.html</guid><category>openstack</category><category>Gentoo</category></item><item><title>Gentoo Hardened ZFS rootfs with dm-crypt/luks 0.6.5</title><link>http://blog.mthode.org/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-065.html</link><description>&lt;h1&gt;Disclaimer&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Keep in mind that ZFS on Linux is supported upstream, for differing values of support&lt;/li&gt;
&lt;li&gt;I do not care much for hibernate, normal suspending works.&lt;/li&gt;
&lt;li&gt;This is for a laptop/desktop, so I choose multilib.&lt;/li&gt;
&lt;li&gt;IANAL&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If you patch the kernel to add in ZFS support directly, you cannot share the binary, the cddl and gpl2 are not compatible in that way.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Initialization&lt;/h2&gt;
&lt;p&gt;Make sure your installation media supports zfs on linux and installing whatever bootloader is required (uefi needs media that supports it as well).
It does not matter too much if it is older media, as long as it supports what you need, Gentoo is nice like that.
Here is an iso that works well for me at &lt;a href="https://mirrors.kernel.org/gentoo//releases/amd64/20140826/" title="Gentoo Hyrid ISO livedvd"&gt;this link&lt;/a&gt;
Live DVDs newer then 12.1 should also have support.&lt;/p&gt;
&lt;h2&gt;Formatting&lt;/h2&gt;
&lt;p&gt;I will be assuming the following.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;/boot on /dev/sda1&lt;/li&gt;
&lt;li&gt;cryptroot on /dev/sda2&lt;/li&gt;
&lt;li&gt;An optional bios_boot partition for grub (gpt stuff)&lt;/li&gt;
&lt;li&gt;swap inside cryptroot OR not used.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;When using GPT for partitioning, create the first partition at 1M, just to make sure you are on a sector boundry&lt;/em&gt;
&lt;em&gt;Most newer drives are 4k advanced format drives.  Because of this you need ashift=12, some/most newer SSDs need ashift=13 or greater&lt;/em&gt;
&lt;em&gt;compression set to lz4 will make your system incompatible with upstream (oracle) zfs, if you want to stay compatible then just set compression=on&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;General Setup&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# setup encrypted partition&lt;/span&gt;
&lt;span class="c1"&gt;# aes-xts-plain64 was chosen due to speed, xts-essiv SHOULD be more secure, but about half as slow, on aes-ni I was getting about 200MBps&lt;/span&gt;
cryptsetup luksFormat -l &lt;span class="m"&gt;512&lt;/span&gt; -c aes-xts-plain64 -h sha512 /dev/sda2
cryptsetup luksOpen /dev/sda2 cryptroot

&lt;span class="c1"&gt;# setup ZFS&lt;/span&gt;
&lt;span class="c1"&gt;# a deeper look into this can be found at [this link](https://github.com/ryao/zfs-overlay/blob/master/zfs-install &amp;quot;ryao&amp;#39;s repo&amp;quot;)&lt;/span&gt;
zpool create -f -o &lt;span class="nv"&gt;ashift&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt; -o &lt;span class="nv"&gt;cachefile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/zpool.cache -O &lt;span class="nv"&gt;normalization&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;formD -m none -R /mnt/gentoo mypool /dev/mapper/cryptroot
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;lz4 mypool/ROOT
&lt;span class="c1"&gt;# rootfs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/ mypool/ROOT/rootfs
&lt;span class="c1"&gt;# system mountpoints were seperated so that we can set nodev and nosuid as mount options&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt mypool/ROOT/rootfs/OPT
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr mypool/ROOT/rootfs/USR
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/src -o &lt;span class="nv"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;disabled mypool/ROOT/rootfs/USR/SRC
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var mypool/ROOT/rootfs/VAR
&lt;span class="c1"&gt;# portage&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none -o &lt;span class="nv"&gt;setuid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off mypool/GENTOO
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage -o &lt;span class="nv"&gt;atime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off mypool/GENTOO/portage
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/distfiles -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off mypool/GENTOO/distfiles
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/packages -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off mypool/GENTOO/packages
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/tmp/portage -o &lt;span class="nv"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;disabled mypool/GENTOO/build-dir
&lt;span class="c1"&gt;# homedirs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home mypool/HOME
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/root mypool/HOME/root
&lt;span class="c1"&gt;# replace USER with your username&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/USER mypool/HOME/USER
&lt;span class="c1"&gt;# set the bootfs, some initrams require this&lt;/span&gt;
zpool &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nv"&gt;bootfs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mypool/ROOT/rootfs mypool

&lt;span class="nb"&gt;cd&lt;/span&gt; /mnt/gentoo

&lt;span class="c1"&gt;# Download the latest stage3 and extract it.&lt;/span&gt;
wget ftp://gentoo.osuosl.org/pub/gentoo/releases/amd64/autobuilds/current-stage3-amd64-hardened/stage3-amd64-hardened-*.tar.bz2
tar -xf /mnt/gentoo/stage3-amd64-hardened-*.tar.bz2 -C /mnt/gentoo

&lt;span class="c1"&gt;# get the latest portage tree&lt;/span&gt;
emerge --sync

&lt;span class="c1"&gt;# copy the zfs cache from the live system to the chroot&lt;/span&gt;
mkdir -p /mnt/gentoo/etc/zfs
cp /tmp/zpool.cache /mnt/gentoo/etc/zfs/zpool.cache
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Kernel Config&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;If you are compiling the modules into the kernel staticly, then keep these things in mind.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When configuring the kernel, make sure that CONFIG_SPL and CONFIG_ZFS are set to 'Y'.&lt;/li&gt;
&lt;li&gt;Portage will want to install sys-kernel/spl and sys-fs/zfs-kmod when &lt;code&gt;emerge sys-fs/zfs&lt;/code&gt; is run because of dependencies. Also, both are still necessary to make the sys-fs/zfs configure script happy.&lt;/li&gt;
&lt;li&gt;You do not need to run or install module-rebuild.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Install as normal up until the kernel install.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-kernel/genkernel-3.4.40 ~amd64       #needed for zfs and encryption support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
emerge sys-kernel/genkernel
emerge sys-kernel/gentoo-sources                &lt;span class="c1"&gt;#or hardned-sources&lt;/span&gt;

&lt;span class="c1"&gt;# patch the kernel&lt;/span&gt;

&lt;span class="c1"&gt;# If you want to build the modules into the kernel directly, you will need to patch the kernel directly.  Otherwise, skip the patch commands.&lt;/span&gt;
&lt;span class="c1"&gt;# configure the kernel then prepare for zfs / spl&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /usr/src/linux
make prepare
make scripts
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-kernel/spl/spl-0.6.5.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-kernel/spl-0.6.5/work/spl-0.6.5/ &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--with-spl=/usr/src/linux --enable-linux-builtin --with-spl-obj=/usr/src/linux&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-fs/zfs-kmod/zfs-kmod-0.6.5.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-fs/zfs-kmod-0.6.5  /work/zfs-kmod-0.6.5 &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--with-spl=/usr/src/linux --enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-fs/zfs/zfs-0.6.5.ebuild clean merge
mkdir -p /etc/portage/profile
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs -kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/profile/package.use.mask
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.use

&lt;span class="c1"&gt;# finish configuring, building and installing the kernel making sure to enable dm-crypt support&lt;/span&gt;

&lt;span class="c1"&gt;# if not building zfs into the kernel, install module-rebuild&lt;/span&gt;
emerge module-rebuild

&lt;span class="c1"&gt;# install SPL and ZFS stuff zfs pulls in spl automatically&lt;/span&gt;
mkdir -p /etc/portage/profile
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs -kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/profile/package.use.mask
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.use
emerge sys-fs/zfs

&lt;span class="c1"&gt;# Add zfs to the correct runlevel&lt;/span&gt;
rc-update add zfs-mount boot

&lt;span class="c1"&gt;# initrd creation, add &amp;#39;--callback=&amp;quot;module-rebuild rebuild&amp;quot;&amp;#39; to the options if not building the modules into the kernel&lt;/span&gt;
genkernel --luks --zfs --disklabel initramfs
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Finish installing as normal, your kernel line should look like this, and you should also have a the initrd defined.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# kernel line for grub2, libzfs support is not needed in grub2 because you are not mounting the filesystem directly.&lt;/span&gt;
linux  /kernel-3.5.0-gentoo &lt;span class="nv"&gt;real_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ZFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mypool/ROOT/rootfs &lt;span class="nv"&gt;crypt_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sda2 &lt;span class="nv"&gt;dozfs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;force ro
initrd /initramfs-genkernel-x86_64-3.5.0
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In /etc/fstab, make sure BOOT, ROOT and SWAP lines are commented out and finish the install.&lt;/p&gt;
&lt;p&gt;You should now have a working encryped zfs install.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Wed, 02 Sep 2015 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2015-09-02:/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-065.html</guid><category>zfs</category><category>Gentoo</category><category>encryption</category></item><item><title>Gentoo on the Odroid-U3</title><link>http://blog.mthode.org/gentoo-on-the-odroid-u3.html</link><description>&lt;h1&gt;Arm cross compiler setup and stuffs&lt;/h1&gt;
&lt;p&gt;This will set up a way to compile things for arm on your native system (amd64 for me)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;emerge dev-embedded/u-boot-tools sys-devel/crossdev
crossdev -S -s4 -t armv7a-hardfloat-linux-gnueabi
&lt;/pre&gt;&lt;/div&gt;


&lt;h1&gt;Building the kernel&lt;/h1&gt;
&lt;p&gt;This assumes you have kernel sources, I'm testing 3.17-rc2 since they just got support for the odroid-u3 into upstream.&lt;/p&gt;
&lt;p&gt;Also, I tend to build without modules, so keep that in mind.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# get the base config (For me on an odroid-u3&lt;/span&gt;
&lt;span class="nv"&gt;ARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;arm &lt;span class="nv"&gt;CROSS_COMPILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;armv7a-hardfloat-linux-gnueabi- make exynos_defconfig
&lt;span class="c1"&gt;# change it to add what I want/need&lt;/span&gt;
&lt;span class="nv"&gt;ARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;arm &lt;span class="nv"&gt;CROSS_COMPILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;armv7a-hardfloat-linux-gnueabi- make menuconfig
&lt;span class="c1"&gt;# build the kernel&lt;/span&gt;
&lt;span class="nv"&gt;ARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;arm &lt;span class="nv"&gt;CROSS_COMPILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;armv7a-hardfloat-linux-gnueabi- make -j10
&lt;/pre&gt;&lt;/div&gt;


&lt;h1&gt;Setting up the SD Card&lt;/h1&gt;
&lt;p&gt;I tend to be generous, 10M for the bootloader&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;parted /dev/sdb mklabel msdos y
parted /dev/sdb mkpart p fat32 10M 200M
parted /dev/sdb mkpart p 200M &lt;span class="m"&gt;100&lt;/span&gt;%
parted /dev/sdb toggle &lt;span class="m"&gt;1&lt;/span&gt; boot

mkfs.vfat /dev/sdb1
mkfs.ext4 /dev/sdb2
&lt;/pre&gt;&lt;/div&gt;


&lt;h1&gt;Building uboot&lt;/h1&gt;
&lt;p&gt;This may differ between boards, but should general look like the following (I hear vanilla uboot works now)&lt;/p&gt;
&lt;p&gt;I used the odroid-v2010.12 branch and one thing to note is that if it sees a zImage on the boot partition it will ONLY use that, kinda of annoying.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;git clone git://github.com/hardkernel/u-boot.git
&lt;span class="nb"&gt;cd&lt;/span&gt; u-boot
sed -i -e &lt;span class="s2"&gt;&amp;quot;s/soft-float/float-abi=hard -mfpu=vfpv3/g&amp;quot;&lt;/span&gt; arch/arm/cpu/armv7/config.mk
&lt;span class="nv"&gt;ARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;arm &lt;span class="nv"&gt;CROSS_COMPILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;armv7a-hardfloat-linux-gnueabi- make smdk4412_config
&lt;span class="nv"&gt;ARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;arm &lt;span class="nv"&gt;CROSS_COMPILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;armv7a-hardfloat-linux-gnueabi- make -j1
sudo &lt;span class="s2"&gt;&amp;quot;sh /home/USER/dev/arm/u-boot/sd_fuse/sd_fusing.sh /dev/sdb&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1&gt;Copying the kernel/userland&lt;/h1&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sudo -i
mount /dev/sdb2 /mnt/gentoo
mount /dev/sdb1 /mnt/gentoo/boot
cp /home/USER/dev/linux/arch/arm/boot/dts/exynos4412-odroidu3.dtb /mnt/gentoo/boot/
cp /home/USER/dev/linux/arch/arm/boot/zImage /mnt/gentoo/boot/kernel-3.17-rc2.raw
&lt;span class="nb"&gt;cd&lt;/span&gt; /mnt/gentoo/boot
cat kernel-3.17-rc2.raw exynos4412-odroidu3.dtb &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; kernel-3.17-rc2

tar -xf /tmp/stage3-armv7a_hardfp-hardened-20140627.tar.bz2 -C /mnt/gentoo/
&lt;/pre&gt;&lt;/div&gt;


&lt;h1&gt;Setting up userland&lt;/h1&gt;
&lt;p&gt;I tend to just copy or generate a shadow file and overwrite the root entry in /etc/shadow...&lt;/p&gt;
&lt;p&gt;Then set up on when booted&lt;/p&gt;
&lt;h1&gt;Setting up the bootloader&lt;/h1&gt;
&lt;p&gt;put this in /mnt/gentoo/boot/boot.txt&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;setenv initrd_high &amp;quot;0xffffffff&amp;quot;
setenv fdt_high &amp;quot;0xffffffff&amp;quot;
setenv fb_x_res &amp;quot;1920&amp;quot;
setenv fb_y_res &amp;quot;1080&amp;quot;
setenv hdmi_phy_res &amp;quot;1080&amp;quot;
setenv bootcmd &amp;quot;fatload mmc 0:1 0x40008000 kernel-3.17-rc2; bootm 0x40008000&amp;quot;
setenv bootargs &amp;quot;console=tty1 console=ttySAC1,115200n8 fb_x_res=&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;fb_x_res&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt; fb_y_res=&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;fb_y_res&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt; hdmi_phy_res=&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;hdmi_phy_res&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt; root=/dev/mmcblk0p2 rootwait ro mem=2047M&amp;quot;
boot
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and run this&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;mkimage -A arm -T script -C none -n &lt;span class="s2"&gt;&amp;quot;Boot.scr for odroid-u3&amp;quot;&lt;/span&gt; -d boot.txt boot.scr
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;That should do it :D&lt;/p&gt;
&lt;p&gt;I used steev (a fellow gentoo dev) and http://www.funtoo.org/ODROID_U2 as sources.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Mon, 25 Aug 2014 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2014-08-25:/gentoo-on-the-odroid-u3.html</guid><category>Gentoo</category><category>arm</category><category>kernel</category><category>linux</category></item><item><title>testing the s3700</title><link>http://blog.mthode.org/testing-the-s3700.html</link><description>&lt;h1&gt;The Setup&lt;/h1&gt;
&lt;p&gt;Two 100G s3700 drives, one tested with luks, one not.&lt;/p&gt;
&lt;p&gt;Filled the drive to test with it filled.&lt;/p&gt;
&lt;p&gt;Testing 4k/8k, with luks using --size=8 or --size=9 for 4k and 8k respectivly.&lt;/p&gt;
&lt;p&gt;I used the following settings in fio, changing the filename and block size where appropriate.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[global]&lt;/span&gt;
&lt;span class="na"&gt;bs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;4k&lt;/span&gt;
&lt;span class="na"&gt;ioengine&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;posixaio&lt;/span&gt;
&lt;span class="na"&gt;iodepth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;32&lt;/span&gt;
&lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;200g&lt;/span&gt;
&lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/dev/mapper/testssd&lt;/span&gt;
&lt;span class="na"&gt;direct&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;[rand-read]&lt;/span&gt;
&lt;span class="na"&gt;rw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;randread&lt;/span&gt;
&lt;span class="na"&gt;stonewall&lt;/span&gt;

&lt;span class="k"&gt;[rand-write]&lt;/span&gt;
&lt;span class="na"&gt;rw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;randwrite&lt;/span&gt;
&lt;span class="na"&gt;stonewall&lt;/span&gt;

&lt;span class="k"&gt;[seq-read]&lt;/span&gt;
&lt;span class="na"&gt;rw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;read&lt;/span&gt;
&lt;span class="na"&gt;stonewall&lt;/span&gt;

&lt;span class="k"&gt;[seq-write]&lt;/span&gt;
&lt;span class="na"&gt;rw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;write&lt;/span&gt;
&lt;span class="na"&gt;stonewall&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h1&gt;Results&lt;/h1&gt;
&lt;p&gt;There was generally high interupts and context switches, but oddly less so with luks.&lt;/p&gt;
&lt;h2&gt;Sequential IOPS&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;4k sequential writes with luks was 73.7% of max ( 12424 vs 16855 )&lt;/li&gt;
&lt;li&gt;4k sequential reads with luks was 76.7% of max ( 14471 vs 18864 )&lt;/li&gt;
&lt;li&gt;8k sequential writes with luks was 71.0% of max ( 9640 vs 13573 )&lt;/li&gt;
&lt;li&gt;8k sequential reads with luks was 71.8% of max ( 10744 vs 14966 )&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Random IOPS&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;4k random writes with luks was 82.2% of max ( 13919 vs 16924&lt;/li&gt;
&lt;li&gt;4k random reads with luks was 80.7% of max ( 6260 vs 7756 )&lt;/li&gt;
&lt;li&gt;8k random writes with luks was 71.7% of max ( 9718 vs 13557 )&lt;/li&gt;
&lt;li&gt;8k random reads with luks was 64.7% of max ( 4222 vs 6526 )&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;My use case is zfs usage as l2arc/zil cache, I'll be using 8k on luks.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Sun, 02 Mar 2014 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2014-03-02:/testing-the-s3700.html</guid><category>testing</category></item><item><title>Interupts and Context Switches with ZFS with LUKS</title><link>http://blog.mthode.org/interupts-and-context-switches-with-zfs-with-luks.html</link><description>&lt;h1&gt;Why care?&lt;/h1&gt;
&lt;p&gt;Interupts and Context switches represent overhead and ineffeciency (in general).&lt;/p&gt;
&lt;h1&gt;The Setup&lt;/h1&gt;
&lt;p&gt;The Same 15 4TB drives in a raidz3 with a hotspare (16 drives total).&lt;/p&gt;
&lt;p&gt;Testing was just a scrub (no fresh boot).  Switched between CFQ and NOOP a couple of times.&lt;/p&gt;
&lt;h1&gt;Results&lt;/h1&gt;
&lt;p&gt;The picture generally speaks for itself, but in general I noticed a doubling of the context switches and adding 1 to the load level.&lt;/p&gt;
&lt;p&gt;I also about a 20% increase in Interupts.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://i.imgur.com/kXiXqGb.png"&gt;The results&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Use NOOP.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Thu, 20 Feb 2014 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2014-02-20:/interupts-and-context-switches-with-zfs-with-luks.html</guid><category>zfs</category></item><item><title>ZFS performance on LUKS</title><link>http://blog.mthode.org/zfs-performance-on-luks.html</link><description>&lt;h1&gt;the setup&lt;/h1&gt;
&lt;p&gt;The system being tested is a 15 drive raidz3 setup with 4TB drives running kernel 3.13.2 (non-hardened for testing).&lt;/p&gt;
&lt;h1&gt;The encryption algorithm&lt;/h1&gt;
&lt;p&gt;I was previously using cbc-essiv, this causes I found (via a simple scrub test) that it caused my performance to be about 10% lower then xts-plain64.&lt;/p&gt;
&lt;p&gt;cbc-essiv was slow because it needed to read the previous block in order to write the current one.&lt;/p&gt;
&lt;h2&gt;I chose xts-plain64 even though there are known attacks against it.&lt;/h2&gt;
&lt;p&gt;From &lt;a href="https://en.wikipedia.org/wiki/Disk_encryption_theory#XEX-based_tweaked-codebook_mode_with_ciphertext_stealing_.28XTS.29" title="XTS"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;XTS mode is susceptible to data manipulation and tampering, and applications must employ measures to detect modifications of data if manipulation and tampering is a concern:
"...since there are no authentication tags then any ciphertext (original or modified by attacker) will be decrypted as some plaintext and there is no built-in mechanism to detect alterations.
The best that can be done is to ensure that any alteration of the ciphertext will completely randomize the plaintext,
and rely on the application that uses this transform to include sufficient redundancy in its plaintext to detect and discard such random plaintexts."
The mode is also susceptible to traffic analysis, replay, and sector randomization attacks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ol&gt;
&lt;li&gt;I believe that the auth tag is double verified by both luks checksuming and zfs checksuming.&lt;/li&gt;
&lt;li&gt;I am not sure about the other issues (traffic analysis, replay, and sector randomization attacks).&lt;/li&gt;
&lt;li&gt;I do not currently consider myself up against state actors.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;Setting the Elevator&lt;/h1&gt;
&lt;p&gt;I unknowningly was using cfq, this caused more load spikes, longer scrub times and higher load in general.&lt;/p&gt;
&lt;p&gt;ZFSonLinux does set the elevator to NOOP if it is put directly on a hard disk but using LUKS interferes with this.&lt;/p&gt;
&lt;p&gt;Here is the results of me testing via scrubs (done only once, fresh boot each time, but good enough for me...).&lt;/p&gt;
&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;Elevator&lt;/td&gt;
    &lt;td&gt;Scrub Time&lt;/td&gt;
    &lt;td&gt;Average Load15&lt;/td&gt;
    &lt;td&gt;Link to load&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;NOOP&lt;/td&gt;
    &lt;td&gt;10h42m&lt;/td&gt;
    &lt;td&gt;5.1 (ish)&lt;/td&gt;
    &lt;td&gt;&lt;a href="http://i.imgur.com/ccTXYrF.png"&gt;NOOP Graph&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;CFQ&lt;/td&gt;
    &lt;td&gt;11h47m&lt;/td&gt;
    &lt;td&gt;6.5 (ish)&lt;/td&gt;
    &lt;td&gt;&lt;a href="http://i.imgur.com/s8YPFG2.png"&gt;CFQ Graph&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;By changing all drives to xts-plain64 and the elevators to noop my scrubs went from 360MB/s to 450MB/s (a 20% gain).&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Tue, 18 Feb 2014 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2014-02-18:/zfs-performance-on-luks.html</guid><category>zfs</category></item><item><title>Of ZFS and SELinux</title><link>http://blog.mthode.org/of-zfs-and-selinux.html</link><description>&lt;h1&gt;This patchset has been incuded in zfsonlinux, the selinux policy is still needed&lt;/h1&gt;
&lt;p&gt;This continues my work in adding zfs to the list of filesystems that SELinux supports&lt;/p&gt;
&lt;h1&gt;Disclaimer&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;These patches are against git master (because 0.6.3 should be out 'soon').&lt;/li&gt;
&lt;li&gt;IANAL&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If you patch the kernel to add in ZFS support directly, you cannot share the binary, the cddl and gpl2 are not compatible in that way.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;The Patch&lt;/h2&gt;
&lt;p&gt;The only patch you should need comes from this pull request.  If you wish, you could also use my selinux forked branch).&lt;/p&gt;
&lt;p&gt;http://dev.gentoo.org/~prometheanfire/patches/zfs/rootcontext.patch&lt;/p&gt;
&lt;p&gt;https://github.com/prometheanfire/zfs/tree/selinux&lt;/p&gt;
&lt;p&gt;These pull requests may be intresting to you as well.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/zfsonlinux/zfs/pull/1835" title="SELinux rootcontext support"&gt;SELinux rootcontext support&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/zfsonlinux/zfs/pull/1837" title="better init scripts"&gt;better init scripts (fixes grep)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/zfsonlinux/zfs/pull/1838" title="python3 support for arcstats and dbuffstat"&gt;python3 support for arcstats and dbuffstat&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;what it does&lt;/h3&gt;
&lt;p&gt;The patch adds selinux support to more inode types (links and directories and stuff).
When it detects selinux support, it will also add the mountoption rootcontext= to the mount commands it sends the host.&lt;/p&gt;
&lt;h2&gt;Building the stuffs&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#get the patches&lt;/span&gt;
mkdir -p /etc/portage/patches/sys-fs/zfs /etc/portage/patches/sys-fs/zfs-kmod
curl http://dev.gentoo.org/~prometheanfire/patches/zfs/rootcontext.patch -o /etc/portage/patches/sys-fs/zfs/rootcontext.patch
curl http://dev.gentoo.org/~prometheanfire/patches/zfs/rootcontext.patch -o /etc/portage/patches/sys-fs/zfs-kmod/rootcontext.patch

&lt;span class="c1"&gt;#get the code into the kernel if compiling statically&lt;/span&gt;
&lt;span class="c1"&gt;#replace configure with merge to install normally&lt;/span&gt;
&lt;span class="c1"&gt;#if you wish to use my zfs branch, include the following line to the env ebuild command at the start of it (right after &amp;#39;env&amp;#39;)&lt;/span&gt;
&lt;span class="c1"&gt;#EGIT_BRANCH=selinux zfs_kmod_LIVE_REPO=&amp;#39;git://github.com/prometheanfire/zfs.git&amp;#39; zfs_LIVE_REPO=&amp;#39;git://github.com/prometheanfire/zfs.git&amp;#39;&lt;/span&gt;
&lt;span class="c1"&gt;#configure the kernel normally and run &amp;#39;make prepare&amp;#39;&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-kernel/spl/spl-9999.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-kernel/spl-9999/work/spl-9999 &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--with-spl=/usr/src/linux --enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-fs/zfs-kmod-9999/work/zfs-kmod-9999 &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;#build and install the kernel, making sure to enable spl/zfs if you are compiling statically.&lt;/span&gt;

&lt;span class="c1"&gt;#merge this no mater what&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--with-spl=/usr/src/linux --enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-fs/zfs/zfs-9999.ebuild clean merge

&lt;span class="c1"&gt;#build the initrd and configure your bootloader&lt;/span&gt;

&lt;span class="c1"&gt;#get the code into the system if NOT compiling statically&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-kernel/spl/spl-9999.ebuild clean merge
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Labeling the datasets&lt;/h2&gt;
&lt;p&gt;When you reboot into the new kernel and with the new zfs userland tools you can set the rootcontext as a property directly.&lt;/p&gt;
&lt;p&gt;The rootcontext for default is 'system_u:object_r:fs_t'.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;zfs &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nv"&gt;rootcontext&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;system_u:object_r:portage_ebuild_t node02-zp00/GENTOO/portage

&lt;span class="c1"&gt;# zfs list -o name,mountpoint,rootcontext&lt;/span&gt;
NAME                                  MOUNTPOINT              ROOTCONTEXT
node02-zp00                           none                    default
node02-zp00/GENTOO                    none                    default
node02-zp00/GENTOO/portage            /usr/portage            system_u:object_r:portage_ebuild_t
node02-zp00/GENTOO/portage/distfiles  /usr/portage/distfiles  system_u:object_r:portage_ebuild_t
node02-zp00/GENTOO/portage/packages   /usr/portage/packages   system_u:object_r:portage_ebuild_t
node02-zp00/HOME                      /home                   system_u:object_r:home_root_t
node02-zp00/HOME/root                 /root                   root:object_r:user_home_dir_t
node02-zp00/ROOT                      none                    default
node02-zp00/ROOT/opt                  /opt                    system_u:object_r:usr_t
node02-zp00/ROOT/rootfs               legacy                  system_u:object_r:root_t
node02-zp00/test-vol                  -                       default
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Selinux Policy&lt;/h2&gt;
&lt;p&gt;I am working on getting this upstream, but for now this is needed.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;mkdir -p ~/selinux/zfs
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/selinux/zfs
curl http://dev.gentoo.org/~prometheanfire/patches/zfs/zfs.fc -o zfs.fc
curl http://dev.gentoo.org/~prometheanfire/patches/zfs/zfs.te -o zfs.te

&lt;span class="c1"&gt;#make and insert the module&lt;/span&gt;
make -f /usr/share/selinux/strict/include/Makefile zfs.pp
semodule -i zfs.pp

&lt;span class="c1"&gt;#when it becomes needed (upstream support) run &amp;#39;semodule -r zfs&amp;#39; to remove the module.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;The rest&lt;/h2&gt;
&lt;p&gt;You will need to relabel most likely (since this adds support for selinux markings on directories and the like).&lt;/p&gt;
&lt;p&gt;Treat this like a non-selinux system and follow the migration guide &lt;a href="http://www.gentoo.org/proj/en/hardened/selinux/selinux-handbook.xml?part=2&amp;amp;chap=1" title="here"&gt;here&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Thu, 07 Nov 2013 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2013-11-07:/of-zfs-and-selinux.html</guid><category>zfs</category><category>Gentoo</category><category>SELinux</category></item><item><title>Gentoo Hardened ZFS rootfs with dm-crypt/luks 0.6.2</title><link>http://blog.mthode.org/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-062.html</link><description>&lt;h1&gt;Disclaimer&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Keep in mind that ZFS on Linux is supported upstream, for differing values of support&lt;/li&gt;
&lt;li&gt;I do not care much for hibernate, normal suspending works.&lt;/li&gt;
&lt;li&gt;This is for a laptop/desktop, so I choose multilib.&lt;/li&gt;
&lt;li&gt;IANAL&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If you patch the kernel to add in ZFS support directly, you cannot share the binary, the cddl and gpl2 are not compatible in that way.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Initialization&lt;/h2&gt;
&lt;p&gt;Make sure your installation media supports zfs on linux and installing whatever bootloader is required (uefi needs media that supports it as well).
I uploaded an iso that works for me at &lt;a href="http://cdn.mthode.org/install-amd64-nomultilib-hardened-13.0-08052013.iso" title="Gentoo Hardened minimal iso with ZFS"&gt;this link&lt;/a&gt;
Live DVDs newer then 12.1 should also have support, but the previous link has a stable version of zfsonlinux (not 0.6.2 yet, but good enough for install!).
If you need to install the bootloader via uefi, you can use one of the latest Fedora CDs, though the gentoo media should be getting support 'soon'.  You can install your system normally up until the formatting begins.&lt;/p&gt;
&lt;h2&gt;Formatting&lt;/h2&gt;
&lt;p&gt;I will be assuming the following.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;/boot on /dev/sda1&lt;/li&gt;
&lt;li&gt;cryptroot on /dev/sda2&lt;/li&gt;
&lt;li&gt;An optional bios_boot partition for grub (gpt stuff)&lt;/li&gt;
&lt;li&gt;swap inside cryptroot OR not used.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;When using GPT for partitioning, create the first partition at 1M, just to make sure you are on a sector boundry&lt;/em&gt;
&lt;em&gt;Most newer drives are 4k advanced format drives.  Because of this you need ashift=12, some/most newer SSDs need ashift=13&lt;/em&gt;
&lt;em&gt;compression set to lz4 will make your system incompatible with upstream (oracle) zfs, if you want to stay compatible then just set compression=on&lt;/em&gt;
&lt;em&gt;due to linux not having the best memory management, zfs on luks can be kinda unstable, I have not had a problem on my laptop, but my servers have been sad&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;General Setup&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#setup encrypted partition&lt;/span&gt;
&lt;span class="c1"&gt;#aes-xts-plain64 was chosen due to speed, xts-essiv SHOULD be more secure, but about half as slow, on aes-ni I was getting about 200MBps&lt;/span&gt;
cryptsetup luksFormat -l &lt;span class="m"&gt;512&lt;/span&gt; -c aes-xts-plain64 -h sha512 /dev/sda2
cryptsetup luksOpen /dev/sda2 cryptroot

&lt;span class="c1"&gt;#setup ZFS&lt;/span&gt;
zpool create -f -o &lt;span class="nv"&gt;ashift&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt; -o &lt;span class="nv"&gt;cachefile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/zpool.cache -O &lt;span class="nv"&gt;normalization&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;formD -m none -R /mnt/gentoo mypool /dev/mapper/cryptroot
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;lz4 mypool/ROOT
&lt;span class="c1"&gt;#rootfs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/ mypool/ROOT/rootfs
&lt;span class="c1"&gt;#system mountpoints were seperated so that we can set nodev and nosuid as mount options&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt mypool/ROOT/rootfs/OPT
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr mypool/ROOT/rootfs/USR
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/src -o &lt;span class="nv"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;disabled mypool/ROOT/rootfs/USR/SRC
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var mypool/ROOT/rootfs/VAR
&lt;span class="c1"&gt;#portage&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none mypool/GENTOO
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage mypool/GENTOO/portage
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/distfiles -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off mypool/GENTOO/distfiles
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/packages -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off mypool/GENTOO/packages
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/tmp/portage -o &lt;span class="nv"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;disabled mypool/GENTOO/build-dir
&lt;span class="c1"&gt;#homedirs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home mypool/HOME
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/root mypool/HOME/root
&lt;span class="c1"&gt;#replace user with your username&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/USER mypool/HOME/USER

&lt;span class="nb"&gt;cd&lt;/span&gt; /mnt/gentoo

&lt;span class="c1"&gt;#Download the latest stage3 and extract it.&lt;/span&gt;
wget ftp://gentoo.osuosl.org/pub/gentoo/releases/amd64/autobuilds/current-stage3-amd64-hardened/stage3-amd64-hardened-*.tar.bz2
tar -xf /mnt/gentoo/stage3-amd64-hardened-*.tar.bz2 -C /mnt/gentoo

&lt;span class="c1"&gt;#get the latest portage tree&lt;/span&gt;
emerge --sync

&lt;span class="c1"&gt;#copy the zfs cache from the live system to the chroot&lt;/span&gt;
mkdir -p /mnt/gentoo/etc/zfs
cp /tmp/zpool.cache /mnt/gentoo/etc/zfs/zpool.cache
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Kernel Config&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;If you are compiling the modules into the kernel staticly, then keep these things in mind.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When configuring the kernel, make sure that CONFIG_SPL and CONFIG_ZFS are set to 'Y'.&lt;/li&gt;
&lt;li&gt;Portage will want to install sys-kernel/spl when &lt;code&gt;emerge sys-fs/zfs&lt;/code&gt; is run because of dependencies. Also, sys-kernel/spl is still necessary to make the sys-fs/zfs configure script happy.&lt;/li&gt;
&lt;li&gt;You do not need to run or install module-rebuild.&lt;/li&gt;
&lt;li&gt;There have been some updates to the kernel/userspace ioctl since 0.6.0-rc9 was tagged.&lt;ul&gt;
&lt;li&gt;An issue occurs if newer userland utilities are used with older kernel modules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Install as normal up until the kernel install.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-kernel/genkernel-3.4.40 ~amd64       #needed for zfs and encryption support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
emerge sys-kernel/genkernel
emerge sys-kernel/gentoo-sources                &lt;span class="c1"&gt;#or hardned-sources&lt;/span&gt;

&lt;span class="c1"&gt;#patch the kernel&lt;/span&gt;

&lt;span class="c1"&gt;#If you want to build the modules into the kernel directly, you will need to patch the kernel directly.  Otherwise, skip the patch commands.&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-kernel/spl/spl-0.6.2.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-kernel/spl-0.6.2/work/spl-spl-0.6.2 &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--with-spl=/usr/src/linux --enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-fs/zfs-kmod/zfs-kmod-0.6.2.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-fs/zfs-kmod-0.6.2/work/zfs-zfs-0.6.2/ &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
mkdir -p /etc/portage/profile
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs -kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/profile/package.use.mask
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.use

&lt;span class="c1"&gt;#finish configuring, building and installing the kernel making sure to enable dm-crypt support&lt;/span&gt;

&lt;span class="c1"&gt;#if not building zfs into the kernel, install module-rebuild&lt;/span&gt;
emerge module-rebuild

&lt;span class="c1"&gt;#install SPL and ZFS stuff zfs pulls in spl automatically&lt;/span&gt;
mkdir -p /etc/portage/profile
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs -kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/profile/package.use.mask
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.use
emerge sys-fs/zfs

&lt;span class="c1"&gt;# Add zfs to the correct runlevel&lt;/span&gt;
rc-update add zfs boot

&lt;span class="c1"&gt;#initrd creation, add &amp;#39;--callback=&amp;quot;module-rebuild rebuild&amp;quot;&amp;#39; to the options if not building the modules into the kernel&lt;/span&gt;
genkernel --luks --zfs --disklabel initramfs
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Finish installing as normal, your kernel line should look like this, and you should also have a the initrd defined.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#kernel line for grub2, libzfs support is not needed in grub2 because you are not mounting the filesystem directly.&lt;/span&gt;
linux  /kernel-3.5.0-gentoo &lt;span class="nv"&gt;real_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ZFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mypool/ROOT/rootfs &lt;span class="nv"&gt;crypt_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sda2 &lt;span class="nv"&gt;dozfs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;force ro
initrd /initramfs-genkernel-x86_64-3.5.0
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In /etc/fstab, make sure BOOT, ROOT and SWAP lines are commented out and finish the install.&lt;/p&gt;
&lt;p&gt;You should now have a working encryped zfs install.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Tue, 10 Sep 2013 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2013-09-10:/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-062.html</guid><category>zfs</category><category>Gentoo</category><category>encryption</category></item><item><title>Gentoo Hardened ZFS rootfs with dm-crypt/luks stable edition</title><link>http://blog.mthode.org/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-stable-edition.html</link><description>&lt;h1&gt;Disclaimer&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Keep in mind that ZFS on Linux is supported upstream, for differing values of support&lt;/li&gt;
&lt;li&gt;I do not care much for hibernate, normal suspending works.&lt;/li&gt;
&lt;li&gt;This is for a laptop/desktop, so I choose multilib.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If you patch the kernel to add in ZFS support directly, you cannot share the binary, the cddl and gpl2 are not compatible in that way.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Initialization&lt;/h2&gt;
&lt;p&gt;Make sure your installation media supports zfs on linux and installing whatever bootloader is required (uefi needs media that supports it as well).
I uploaded an iso that works for me at &lt;a href="http://cdn.mthode.org/install-amd64-hardened-minimal-13.0.ZFS-r3.iso" title="Gentoo Hardened minimal iso with ZFS"&gt;this link&lt;/a&gt;
Live DVDs newer then 12.1 should also have support, but the previous link has the stable version of zfsonlinux.
If you need to install the bootloader via uefi, you can use one of the latest Fedora CDs, though the gentoo media should be getting support 'soon'.  You can install your system normally up until the formatting begins.&lt;/p&gt;
&lt;h2&gt;Formatting&lt;/h2&gt;
&lt;p&gt;I will be assuming the following.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;/boot on /dev/sda1&lt;/li&gt;
&lt;li&gt;cryptroot on /dev/sda2&lt;/li&gt;
&lt;li&gt;swap inside cryptroot OR not used.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;When using GPT for partitioning, create the first partition at 1M, just to make sure you are on a sector boundry&lt;/em&gt;
&lt;em&gt;Most newer drives are 4k advanced format drives.  Because of this you need ashift=12, some/most newer SSDs need ashift=13&lt;/em&gt;
&lt;em&gt;compression set to lz4 will make your system incompatible with upstream (oracle) zfs, if you want to stay compatible then just set compression=on&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;General Setup&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#setup encrypted partition&lt;/span&gt;
cryptsetup luksFormat -l &lt;span class="m"&gt;512&lt;/span&gt; -c aes-xts-plain64 -h sha512 /dev/sda2
cryptsetup luksOpen /dev/sda2 cryptroot

&lt;span class="c1"&gt;#setup ZFS&lt;/span&gt;
zpool create -f -o &lt;span class="nv"&gt;ashift&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt; -o &lt;span class="nv"&gt;cachefile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/zpool.cache -O &lt;span class="nv"&gt;normalization&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;formD -m none -R /mnt/gentoo rpool /dev/mapper/cryptroot
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;lz4 rpool/ROOT
&lt;span class="c1"&gt;#rootfs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/ rpool/ROOT/rootfs
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt rpool/ROOT/rootfs/OPT
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr rpool/ROOT/rootfs/USR
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var rpool/ROOT/rootfs/VAR
&lt;span class="c1"&gt;#portage&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none rpool/GENTOO
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage rpool/GENTOO/portage
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/distfiles -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off rpool/GENTOO/distfiles
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/packages -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off rpool/GENTOO/packages
&lt;span class="c1"&gt;#homedirs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home rpool/HOME
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/root rpool/HOME/root

&lt;span class="nb"&gt;cd&lt;/span&gt; /mnt/gentoo

&lt;span class="c1"&gt;#Download the latest stage3 and extract it.&lt;/span&gt;
wget ftp://gentoo.osuosl.org/pub/gentoo/releases/amd64/autobuilds/current-stage3-amd64-hardened/stage3-amd64-hardened-*.tar.bz2
tar -xf /mnt/gentoo/stage3-amd64-hardened-*.tar.bz2 -C /mnt/gentoo

&lt;span class="c1"&gt;#get the latest portage tree&lt;/span&gt;
emerge --sync

&lt;span class="c1"&gt;#copy the zfs cache from the live system to the chroot&lt;/span&gt;
mkdir -p /mnt/gentoo/etc/zfs
cp /tmp/zpool.cache /mnt/gentoo/etc/zfs/zpool.cache
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Kernel Config&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;If you are compiling the modules into the kernel staticly, then keep these things in mind.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When configuring the kernel, make sure that CONFIG_SPL and CONFIG_ZFS are set to 'Y'.&lt;/li&gt;
&lt;li&gt;Portage will want to install sys-kernel/spl when &lt;code&gt;emerge sys-fs/zfs&lt;/code&gt; is run because of dependencies. Also, sys-kernel/spl is still necessary to make the sys-fs/zfs configure script happy.&lt;/li&gt;
&lt;li&gt;You do not need to run or install module-rebuild.&lt;/li&gt;
&lt;li&gt;There have been some updates to the kernel/userspace ioctl since 0.6.0-rc9 was tagged.&lt;ul&gt;
&lt;li&gt;An issue occurs if newer userland utilities are used with older kernel modules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Install as normal up until the kernel install.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-kernel/genkernel-3.4.40 ~amd64       #needed for zfs and encryption support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
emerge sys-kernel/genkernel
emerge sys-kernel/gentoo-sources                &lt;span class="c1"&gt;#or hardned-sources&lt;/span&gt;

&lt;span class="c1"&gt;#patch the kernel&lt;/span&gt;

&lt;span class="c1"&gt;#If you want to build the modules into the kernel directly, you will need to patch the kernel directly.  Otherwise, skip the patch commands.&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-kernel/spl/spl-0.6.1.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-kernel/spl-0.6.1/work/spl-0.6.1 &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--with-spl=/usr/src/linux --enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-fs/zfs-kmod/zfs-kmod-0.6.1.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-fs/zfs-kmod-0.6.1/work/zfs-zfs-0.6.1/ &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
mkdir -p /etc/portage/profile
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs -kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/profile/package.use.mask
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.use

&lt;span class="c1"&gt;#finish configuring, building and installing the kernel making sure to enable dm-crypt support&lt;/span&gt;

&lt;span class="c1"&gt;#if not building zfs into the kernel, install module-rebuild&lt;/span&gt;
emerge module-rebuild

&lt;span class="c1"&gt;#install SPL and ZFS stuff zfs pulls in spl automatically&lt;/span&gt;
mkdir -p /etc/portage/profile                                                   
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs -kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/profile/package.use.mask      
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.use                    
emerge sys-fs/zfs

&lt;span class="c1"&gt;# Add zfs to the correct runlevels&lt;/span&gt;
rc-update add zfs boot
rc-update add zfs-shutdown shutdown

&lt;span class="c1"&gt;#initrd creation, add &amp;#39;--callback=&amp;quot;module-rebuild rebuild&amp;quot;&amp;#39; to the options if not building the modules into the kernel&lt;/span&gt;
genkernel --luks --zfs --disklabel initramfs
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Finish installing as normal, your kernel line should look like this, and you should also have a the initrd defined.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#kernel line for grub2, libzfs support is not needed in grub2 because you are not mounting the filesystem directly.&lt;/span&gt;
linux  /kernel-3.5.0-gentoo &lt;span class="nv"&gt;real_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ZFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rpool/ROOT/rootfs &lt;span class="nv"&gt;crypt_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sda2 &lt;span class="nv"&gt;dozfs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;force ro
initrd /initramfs-genkernel-x86_64-3.5.0
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In /etc/fstab, make sure BOOT, ROOT and SWAP lines are commented out and finish the install.&lt;/p&gt;
&lt;p&gt;You should now have a working encryped zfs install.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Wed, 03 Apr 2013 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2013-04-03:/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-stable-edition.html</guid><category>zfs</category><category>Gentoo</category><category>encryption</category></item><item><title>Openstack on Gentoo</title><link>http://blog.mthode.org/openstack-on-gentoo.html</link><description>&lt;h2&gt;Just a simple announcement for now.  It's a bit messy, but should work :D&lt;/h2&gt;
&lt;p&gt;I have packaged Openstack for Gentoo and it is now in tree, the most complete packaging is probably for Openstack Swift.  Nova and some of the others are missing init scripts (being worked on).  If you have problems or bugs, report as normal.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Mon, 28 Jan 2013 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2013-01-28:/openstack-on-gentoo.html</guid></item><item><title>Gentoo Hardened ZFS rootfs with dm-crypt/luks updated 2012-12-12</title><link>http://blog.mthode.org/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-updated-2012-12-12.html</link><description>&lt;h1&gt;Disclaimer&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Keep in mind that ZFS on Linux is not fully supported, for differing values of support&lt;/li&gt;
&lt;li&gt;I don't care much for hibernate, normal suspending works.&lt;/li&gt;
&lt;li&gt;This is for a laptop/desktop, so I choose multilib.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If you patch the kernel to add in ZFS support directly, you cannot share the binary, the cddl and gpl2 are not compatible in that way.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Initialization&lt;/h2&gt;
&lt;p&gt;Make sure your installation media supports zfs on linux and installing whatever bootloader is required (uefi needs media that supports it as well).
You can use the &lt;a href="http://gentoo.mirrors.tds.net/pub/gentoo/releases/" title="Gentoo LiveDVD"&gt;Gentoo LiveDVD&lt;/a&gt;, look for 12.1 or newer. If you need to install the bootloader via uefi, you can use one of the latest Fedora CDs, though the gentoo media should be getting support 'soon'.  You can install your system normally up until the formatting begins.&lt;/p&gt;
&lt;h2&gt;Formatting&lt;/h2&gt;
&lt;p&gt;I will be assuming the following.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;/boot on /dev/sda1&lt;/li&gt;
&lt;li&gt;cryptroot on /dev/sda2&lt;/li&gt;
&lt;li&gt;swap inside cryptroot OR not used.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;When using GPT for partitioning, create the first partition at 1M, just to make sure you are on a sector boundry&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;General Setup&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#setup encrypted partition&lt;/span&gt;
cryptsetup luksFormat -l &lt;span class="m"&gt;512&lt;/span&gt; -c aes-xts-plain64 -h sha512 /dev/sda2
cryptsetup luksOpen /dev/sda2 cryptroot

&lt;span class="c1"&gt;#setup ZFS&lt;/span&gt;
zpool create -f -o &lt;span class="nv"&gt;ashift&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt; -o &lt;span class="nv"&gt;cachefile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; -O &lt;span class="nv"&gt;normalization&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;formD -m none -R /mnt/gentoo rpool /dev/mapper/cryptroot
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;on rpool/ROOT
&lt;span class="c1"&gt;#rootfs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/ rpool/ROOT/rootfs
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt rpool/ROOT/rootfs/OPT
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr rpool/ROOT/rootfs/USR
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var rpool/ROOT/rootfs/VAR
&lt;span class="c1"&gt;#portage&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none rpool/GENTOO
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage rpool/GENTOO/portage
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/distfiles -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off rpool/GENTOO/distfiles
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/packages -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off rpool/GENTOO/packages
&lt;span class="c1"&gt;#homedirs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home rpool/HOME
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/root rpool/HOME/root

&lt;span class="nb"&gt;cd&lt;/span&gt; /mnt/gentoo

&lt;span class="c1"&gt;#Download the latest stage3 and extract it.&lt;/span&gt;
wget ftp://gentoo.osuosl.org/pub/gentoo/releases/amd64/autobuilds/current-stage3-amd64-hardened/stage3-amd64-hardened-*.tar.bz2
tar -xf /mnt/gentoo/stage3-amd64-hardened-*.tar.bz2 -C /mnt/gentoo

&lt;span class="c1"&gt;#get the latest portage tree&lt;/span&gt;
emerge --sync

&lt;span class="c1"&gt;#copy the zfs cache from the live system to the chroot&lt;/span&gt;
mkdir -p /mnt/gentoo/etc/zfs
cp /etc/zfs/zpool.cache /mnt/gentoo/etc/zfs/zpool.cache
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Kernel Config&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;If you are compiling the modules into the kernel staticly, then keep these things in mind.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When configuring the kernel, make sure that CONFIG_SPL and CONFIG_ZFS are set to 'Y'.&lt;/li&gt;
&lt;li&gt;Portage will want to install sys-kernel/spl when &lt;code&gt;emerge sys-fs/zfs&lt;/code&gt; is run because of dependencies. Also, sys-kernel/spl is still necessary to make the sys-fs/zfs configure script happy.&lt;/li&gt;
&lt;li&gt;You do not need to run or install module-rebuild.&lt;/li&gt;
&lt;li&gt;There have been some updates to the kernel/userspace ioctl since 0.6.0-rc9 was tagged.&lt;ul&gt;
&lt;li&gt;An issue occurs if newer userland utilities are used with older kernel modules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Install as normal up until the kernel install.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-kernel/genkernel-3.4.40 ~amd64       #needed for zfs and encryption support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
emerge sys-kernel/genkernel
emerge sys-kernel/gentoo-sources

&lt;span class="c1"&gt;#patch the kernel&lt;/span&gt;

&lt;span class="c1"&gt;#If you want to build the modules into the kernel directly, you will need to patch the kernel directly.  Otherwise, skip the patch commands.&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-kernel/spl/spl-9999.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-kernel/spl-9999/work/spl-9999 &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
env &lt;span class="nv"&gt;EXTRA_ECONF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;--with-spl=/usr/src/linux --enable-linux-builtin&amp;#39;&lt;/span&gt; ebuild /usr/portage/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild clean configure
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/tmp/portage/sys-fs/zfs-kmod-9999/work/zfs-/ &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;amp&lt;span class="p"&gt;;&lt;/span&gt; ./copy-builtin /usr/src/linux&lt;span class="o"&gt;)&lt;/span&gt;
mkdir -p /etc/portage/profile
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs -kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/profile/package.use.mask
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sys-fs/zfs kernel-builtin&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.use

&lt;span class="c1"&gt;#finish configuring, building and installing the kernel making sure to enable dm-crypt support&lt;/span&gt;

&lt;span class="c1"&gt;#if not building zfs into the kernel, install module-rebuild&lt;/span&gt;
emerge module-rebuild

&lt;span class="c1"&gt;#install SPL and ZFS stuff zfs pulls in spl automatically&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-kernel/spl-0.6.0_rc12 ~amd64       #needed for zfs support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-fs/zfs-0.6.0_rc12-r1 ~amd64           #needed for zfs support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
emerge sys-fs/zfs

&lt;span class="c1"&gt;# Add zfs to the correct runlevels&lt;/span&gt;
rc-update add zfs boot
rc-update add zfs-shutdown shutdown

&lt;span class="c1"&gt;#initrd creation, add &amp;#39;--callback=&amp;quot;module-rebuild rebuild&amp;quot;&amp;#39; to the options if not building the modules into the kernel&lt;/span&gt;
genkernel --luks --zfs --disklabel initramfs
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Finish installing as normal, your kernel line should look like this, and you should also have a the initrd defined.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#kernel line for grub2, libzfs support is not needed in grub2 because you are not mounting the filesystem directly.&lt;/span&gt;
linux  /kernel-3.5.0-gentoo &lt;span class="nv"&gt;real_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ZFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rpool/ROOT/rootfs &lt;span class="nv"&gt;crypt_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sda2 &lt;span class="nv"&gt;dozfs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;force ro
initrd /initramfs-genkernel-x86_64-3.5.0
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In /etc/fstab, make sure BOOT, ROOT and SWAP lines are commented out and finish the install.&lt;/p&gt;
&lt;p&gt;You should now have a working encryped zfs install.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Tue, 11 Dec 2012 00:00:00 -0600</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2012-12-11:/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-updated-2012-12-12.html</guid><category>zfs</category><category>Gentoo</category><category>encryption</category></item><item><title>VLAN trunking to KVM VMs</title><link>http://blog.mthode.org/vlan-trunking-to-kvm-vms.html</link><description>&lt;h2&gt;Why this is needed&lt;/h2&gt;
&lt;p&gt;In testing linux bridging I noticed a problem that took me much longer then I feel comfortable admitting.
You cannot break out the VLANs to from a physical device and also use that physical device (attached to a bridge) to forward forward the entire trunk to a set of VMs.
The reason this occurs is that once linux starts inspecting for vlans on an interface to split them out it discards all those you do not have defined, so you have to trick it.&lt;/p&gt;
&lt;h2&gt;Setup&lt;/h2&gt;
&lt;p&gt;I had my Trunk on eth1.  What you need to do is directly attach eth1 to a bridge (vmbr1).  This bridge now has the entire trunk associated with it.
Here's the fun part, you can break out vlans on the bridge, so you would have an interface for vlan 13 named vmbr1.13 and then attach that to a brige, allowing you to have a group of machines only exposed to vlan 13.&lt;/p&gt;
&lt;p&gt;The networking goes like this.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;               /-&amp;amp;gt; vmbr1.13 -&amp;amp;gt; vmbr13 -&amp;amp;gt; VM2
eth1 -&amp;amp;gt; vmbr1 ---&amp;amp;gt; VM1
               \-&amp;amp;gt; vmbr1.42 -&amp;amp;gt; vmbr42 -&amp;amp;gt; VM3
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Example&lt;/h2&gt;
&lt;p&gt;Here is the script I used with proxmox (you can set up the bridge in proxmox, but not the source for the bridges data (the 'input').
This is for VLANs 1-13 and assumes you have vyatta set up the target bridges.  I had this start at boot (via rc.local).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;vconfig add vmbr1 &lt;span class="m"&gt;2&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;3&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;4&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;5&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;6&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;7&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;9&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;10&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;11&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;12&lt;/span&gt;
vconfig add vmbr1 &lt;span class="m"&gt;13&lt;/span&gt;
ifconfig eth1 up
ifconfig vmbr1 up
ifconfig vmbr1.2 up
ifconfig vmbr1.3 up
ifconfig vmbr1.4 up
ifconfig vmbr1.5 up
ifconfig vmbr1.6 up
ifconfig vmbr1.7 up
ifconfig vmbr1.8 up
ifconfig vmbr1.9 up
ifconfig vmbr1.10 up
ifconfig vmbr1.11 up
ifconfig vmbr1.12 up
ifconfig vmbr1.13 up
brctl addif vmbr1 eth1
brctl addif vmbr2 vmbr1.2
brctl addif vmbr3 vmbr1.3
brctl addif vmbr4 vmbr1.4
brctl addif vmbr5 vmbr1.5
brctl addif vmbr6 vmbr1.6
brctl addif vmbr7 vmbr1.7
brctl addif vmbr8 vmbr1.8
brctl addif vmbr9 vmbr1.9
brctl addif vmbr10 vmbr1.10
brctl addif vmbr11 vmbr1.11
brctl addif vmbr12 vmbr1.12
brctl addif vmbr13 vmbr1.13
&lt;/pre&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Sun, 14 Oct 2012 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2012-10-14:/vlan-trunking-to-kvm-vms.html</guid><category>virtualization</category><category>Gentoo</category><category>kvm</category></item><item><title>Gentoo Hardened ZFS rootfs with dm-crypt/luks</title><link>http://blog.mthode.org/gentoo-hardened-zfs-rootfs-with-dm-cryptluks.html</link><description>&lt;h1&gt;Disclaimer&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Keep in mind that ZFS on Linux is not fully supported and stuff...&lt;/li&gt;
&lt;li&gt;I don't care much for hibernate, normal suspending works.&lt;/li&gt;
&lt;li&gt;This is for a laptop/desktop, so I choose multilib.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If you patch the kernel to add in ZFS support directly, you cannot share the binary, the cddl and gpl2 are not compatible in that way.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;updated howto is &lt;a href="https://mthode.org/posts/2012/Dec/gentoo-hardened-zfs-rootfs-with-dm-cryptluks-updated-2012-12-12/"&gt;here&lt;/a&gt;&lt;/h1&gt;
&lt;h2&gt;Initialization&lt;/h2&gt;
&lt;p&gt;Make sure your installation media supports zfs on linux and installing whatever bootloader is required (uefi needs media that supports it as well).
You can use the &lt;a href="http://gentoo.mirrors.tds.net/pub/gentoo//releases/" title="Gentoo LiveDVD"&gt;Gentoo LiveDVD&lt;/a&gt;, look for 12.1 or newer for the zfs portion of it, then, if you need to install the bootloader via uefi, you can use one of the latest fedora CDs.  This is the method I used on my 2011 MacBook Pro, because Apple hardware is 'special'.  You can install your system normally up until the formatting begins.&lt;/p&gt;
&lt;h2&gt;Formatting&lt;/h2&gt;
&lt;p&gt;I will be assuming the following.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;/boot on /dev/sda1&lt;/li&gt;
&lt;li&gt;cryptroot on /dev/sda2&lt;/li&gt;
&lt;li&gt;swap inside cryptroot OR not used.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;When using GPT for partitioning, create the first partition at 1M, just to make sure you are on a sector boundry&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;General Setup&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#setup encrypted partition&lt;/span&gt;
cryptsetup luksFormat -l &lt;span class="m"&gt;512&lt;/span&gt; -c aes-xts-plain64 -h sha512 /dev/sda2
cryptsetup luksOpen /dev/sda2 cryptroot

&lt;span class="c1"&gt;#setup ZFS&lt;/span&gt;
zpool create -f -o &lt;span class="nv"&gt;ashift&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;12&lt;/span&gt; -o &lt;span class="nv"&gt;cachefile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; -O &lt;span class="nv"&gt;normalization&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;formD -m none -R /mnt/gentoo rpool /dev/mapper/cryptroot
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;on rpool/ROOT
&lt;span class="c1"&gt;#rootfs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/ rpool/ROOT/rootfs
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt rpool/ROOT/rootfs/OPT
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr rpool/ROOT/rootfs/USR
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var rpool/ROOT/rootfs/VAR
&lt;span class="c1"&gt;#portage&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;none rpool/GENTOO
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage rpool/GENTOO/portage
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/distfiles -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off rpool/GENTOO/distfiles
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/portage/packages -o &lt;span class="nv"&gt;compression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off rpool/GENTOO/packages
&lt;span class="c1"&gt;#homedirs&lt;/span&gt;
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home rpool/HOME
zfs create -o &lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/root rpool/HOME/root

&lt;span class="nb"&gt;cd&lt;/span&gt; /mnt/gentoo

&lt;span class="c1"&gt;#Download the latest stage3 and extract it.&lt;/span&gt;
wget ftp://gentoo.osuosl.org/pub/gentoo/releases/amd64/autobuilds/current-stage3-amd64-hardened/stage3-amd64-hardened-*.tar.bz2
tar -xf /mnt/gentoo/stage3-amd64-hardened-*.tar.bz2 -C /mnt/gentoo

&lt;span class="c1"&gt;#get the latest portage tree&lt;/span&gt;
emerge --sync

&lt;span class="c1"&gt;#copy the zfs cache from the live system to the chroot&lt;/span&gt;
mkdir -p /mnt/gentoo/etc/zfs
cp /etc/zfs/zpool.cache /mnt/gentoo/etc/zfs/zpool.cache
&lt;/pre&gt;&lt;/div&gt;


&lt;h2&gt;Kernel Config&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;If you are compiling the modules into the kernel staticly, then keep these things in mind.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You will need to use vanilla or gentoo sources because there is no 3.5 for hardened sources as of 2012-08-07.&lt;/li&gt;
&lt;li&gt;When configuring the kernel, make sure that CONFIG_SPL and CONFIG_ZFS are set to 'Y'.&lt;/li&gt;
&lt;li&gt;Portage will want to install sys-kernel/spl when &lt;code&gt;emerge sys-fs/zfs&lt;/code&gt; is run because of dependencies. Also, sys-kernel/spl is still necessary to make the sys-fs/zfs configure script happy.&lt;/li&gt;
&lt;li&gt;You do not need to run or install module-rebuild.&lt;/li&gt;
&lt;li&gt;There have been some updates to the kernel/userspace ioctl since 0.6.0-rc9 was tagged.&lt;ul&gt;
&lt;li&gt;An issue occurs if newer userland utilities are used with older kernel modules.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Install as normal up until the kernel install.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-kernel/genkernel-3.4.40 ~amd64       #needed for zfs and encryption support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-apps/openrc-0.9.9.3 ~amd64           #needed for zfs support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-kernel/gentoo-sources-3.5.0 ~amd64   #needed for non-module zfs&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
emerge sys-kernel/genkernel
emerge sys-kernel/gentoo-sources

&lt;span class="c1"&gt;#patch the kernel&lt;/span&gt;
wget http://dev.gentoo.org/~prometheanfire/dist/kernel-patches/linux-3.5.0-gfp-vmalloc.patch -O - &lt;span class="p"&gt;|&lt;/span&gt; patch -p1 -d /usr/src/linux

&lt;span class="c1"&gt;#If you want to build the modules into the kernel directly, you will need to patch the kernel directly.  Otherwise, skip the patch commands.&lt;/span&gt;
wget http://dev.gentoo.org/~ryao/dist/linux-3.5.0-zfs.patch -O - &lt;span class="p"&gt;|&lt;/span&gt; patch -p1 -d /usr/src/linux
wget http://dev.gentoo.org/~prometheanfire/dist/kernel-patches/linux-3.5.0-zfs-builtin.patch -O - &lt;span class="p"&gt;|&lt;/span&gt; patch -p1 -d /usr/src/linux

&lt;span class="c1"&gt;#finish configuring, building and installing the kernel making sure to enable dm-crypt support&lt;/span&gt;

&lt;span class="c1"&gt;#if not building zfs into the kernel, install module-rebuild&lt;/span&gt;
emerge module-rebuild

&lt;span class="c1"&gt;#install SPL (needed for ZFS) and ZFS (also aparently needed for zfs), zfs pulls in spl automatically&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-kernel/spl-0.6.0_rc9-r2 ~amd64       #needed for zfs support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;=sys-fs/zfs-0.6.0_rc9-r6 ~amd64           #needed for zfs support&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&amp;amp;&lt;/span&gt;gt&lt;span class="p"&gt;;&lt;/span&gt; /etc/portage/package.accept_keywords
emerge sys-fs/zfs

&lt;span class="c1"&gt;# Add zfs to the correct runlevels&lt;/span&gt;
rc-update add zfs boot
rc-update add zfs-shutdown shutdown

&lt;span class="c1"&gt;#initrd creation, add &amp;#39;--callback=&amp;quot;module-rebuild rebuild&amp;quot;&amp;#39; to the options if not building the modules into the kernel&lt;/span&gt;
genkernel --luks --zfs --disklabel initramfs
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Finish installing as normal, your kernel line should look like this, and you should also have a the initrd defined.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;#kernel line for grub2, libzfs support is not needed in grub2 because you are not mounting the filesystem directly.&lt;/span&gt;
linux  /kernel-3.5.0-gentoo &lt;span class="nv"&gt;real_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ZFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rpool/ROOT/rootfs &lt;span class="nv"&gt;crypt_root&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sda2 &lt;span class="nv"&gt;dozfs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;force ro
initrd /initramfs-genkernel-x86_64-3.5.0
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In /etc/fstab, make sure BOOT, ROOT and SWAP lines are commented out and finish the install.&lt;/p&gt;
&lt;p&gt;You should now have a working encryped zfs install.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Tue, 31 Jul 2012 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2012-07-31:/gentoo-hardened-zfs-rootfs-with-dm-cryptluks.html</guid><category>zfs</category><category>Gentoo</category><category>encryption</category></item><item><title>Well, here we go again.</title><link>http://blog.mthode.org/well-here-we-go-again.html</link><description>&lt;p&gt;Well, here we go again, I think (hope) to actually keep this blog more up to date with the little projects I do.  Going to be writing about selinux zfsonlinux the 'cloud' and whatever strikes my fancy.&lt;/p&gt;
&lt;p&gt;I supose I should introduce myself, name's Matthew Thode, I currently work for Rackspace as a Linux Admin with a current focus on Big Data, I am also a Gentoo Developer on the hardened project, helping mostly with virtualization, selinux and testing.  I know enough python to get by (it's in github actually) and that's about it for now.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Thode (prometheanfire)</dc:creator><pubDate>Fri, 20 Jul 2012 00:00:00 -0500</pubDate><guid isPermaLink="false">tag:blog.mthode.org,2012-07-20:/well-here-we-go-again.html</guid></item></channel></rss>