<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux on Chris J Arges</title><link>https://chrisarges.net/tags/linux/</link><description>Recent content in Linux on Chris J Arges</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 26 Apr 2021 00:00:00 +0000</lastBuildDate><atom:link href="https://chrisarges.net/tags/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>playing piano in linux</title><link>https://chrisarges.net/posts/2021-04-26-playing-piano-in-linux/</link><pubDate>Mon, 26 Apr 2021 00:00:00 +0000</pubDate><guid>https://chrisarges.net/posts/2021-04-26-playing-piano-in-linux/</guid><description>&lt;p&gt;While on vacation I brought my small MIDI &lt;a href="https://www.akaipro.com/lpk25"&gt;keyboard&lt;/a&gt; along so that the kids could easily practice piano. This keyboard does not generate sounds on its own, so it requires some other device to generate the sounds based on the MIDI output. I used my laptop running Linux to accomplish this with some minimal setup.&lt;/p&gt;&#10;&lt;p&gt;First you must plug the keyboard in via USB. If you launch the program and get sounds, great! If not you may have to manually connect MIDI via &lt;code&gt;aconnect&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>tracing linux</title><link>https://chrisarges.net/posts/2020-12-11-tracing-on-linux/</link><pubDate>Fri, 11 Dec 2020 12:31:49 -0600</pubDate><guid>https://chrisarges.net/posts/2020-12-11-tracing-on-linux/</guid><description>&lt;p&gt;I&amp;rsquo;ve written up about some of my work at Confluera here:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;a href="https://medium.com/confluera-engineering/tracing-linux-fast-compatible-complete-19cee89b3cf6"&gt;medium&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.confluera.com/post/tracing-linux-fast-compatible-complete"&gt;confluera&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;</description></item><item><title>setting up a Minecraft server</title><link>https://chrisarges.net/posts/2020-09-04-setting-up-a-minecraft-server/</link><pubDate>Fri, 04 Sep 2020 10:22:46 -0500</pubDate><guid>https://chrisarges.net/posts/2020-09-04-setting-up-a-minecraft-server/</guid><description>&lt;p&gt;We&amp;rsquo;ve been spending a lot of time at home lately due to the current pandemic.&#10;Because of this the kids have really enjoyed playing Minecraft together.&#10;Initially I set up a LAN server for them to play together, but wanted to set up&#10;a community server that their friends could also access. Here I&amp;rsquo;ll describe&#10;some approaches to this with the goal of keeping things automated, low cost,&#10;secure and easy for friends to play.&lt;/p&gt;</description></item><item><title>bpf for linux tracing</title><link>https://chrisarges.net/posts/2019-03-21-bpf-for-tracing/</link><pubDate>Thu, 21 Mar 2019 11:54:37 -0500</pubDate><guid>https://chrisarges.net/posts/2019-03-21-bpf-for-tracing/</guid><description>&lt;h2 id="overview"&gt;Overview&lt;/h2&gt;&#10;&lt;p&gt;Originally called eBPF for extended Berkeley Packet Filter, BPF is an in-kernel&#10;bytecode interpreter that is very multi-purpose. In this post, I&amp;rsquo;m going to&#10;focus on its tracing capabilities.&lt;/p&gt;&#10;&lt;p&gt;To use BPF one can use the bpf &lt;a href="http://man7.org/linux/man-pages/man2/bpf.2.html"&gt;syscall&lt;/a&gt;. This provides a way to both load&#10;BPF bytecode programs and also create memory maps for sharing data between&#10;kernel and user space.&lt;/p&gt;&#10;&lt;p&gt;Because of the complexity, using bpf in a DIY method becomes a bit complex.&#10;There are many ready to use tools such as &lt;a href="https://github.com/iovisor/bcc"&gt;BCC&lt;/a&gt; and libbpf that make usage&#10;way easier.&lt;/p&gt;</description></item><item><title>the magic of linux clone</title><link>https://chrisarges.net/posts/2019-01-14-the-magic-of-linux-clone/</link><pubDate>Mon, 14 Jan 2019 12:44:27 -0600</pubDate><guid>https://chrisarges.net/posts/2019-01-14-the-magic-of-linux-clone/</guid><description>&lt;p&gt;Processes and threads are concepts that have been used across many operating&#10;systems and programming languages. While we tend to think of &amp;lsquo;process&amp;rsquo; as a&#10;heavy thing and &amp;rsquo;thread&amp;rsquo; as a light thing, how they are implemented and handled&#10;depends on context. This article will focus on how the Linux operating system&#10;handles these concepts and the mechanisms used.&lt;/p&gt;&#10;&lt;h2 id="creating-a-new-process"&gt;Creating a new process&lt;/h2&gt;&#10;&lt;p&gt;Generally in Linux if you want to create a new process in C you can do the following:&lt;/p&gt;</description></item><item><title>tracing in linux</title><link>https://chrisarges.net/posts/2018-10-04-tracing-in-linux/</link><pubDate>Thu, 04 Oct 2018 09:39:10 -0500</pubDate><guid>https://chrisarges.net/posts/2018-10-04-tracing-in-linux/</guid><description>&lt;p&gt;Tracing in Linux is robust, flexible and has many options. So what mechanisms&#10;exist both in kernel and user space for instrumenting the kernel? In addition&#10;what is available in which kernel version, and what requirements does each&#10;technology require? Here we&amp;rsquo;ll mostly focus on syscall tracing.&lt;/p&gt;&#10;&lt;h2 id="overview"&gt;Overview&lt;/h2&gt;&#10;&lt;p&gt;A great overview on Linux tracing systems can be found &lt;a href="https://jvns.ca/blog/2017/07/05/linux-tracing-systems/"&gt;here&lt;/a&gt;. Overall&#10;thinking about tracing systems as data sources (in kernel), and frontends help&#10;explain why there are so many tools. Some data sources are &amp;rsquo;tracepoints&amp;rsquo; while&#10;other are &amp;lsquo;probes&amp;rsquo;. Tracepoints are low-overhead and can be activated or&#10;deactivated, they are compiled into the kernel so they cannot be dynamically&#10;instrumented. Probes are very flexible, but require larger overhead as you are&#10;replacing a &amp;rsquo;nop&amp;rsquo; instruction with a branch in order to redirect execution of&#10;probed function. In addition you must know the function name and can only&#10;instrument &amp;lsquo;real&amp;rsquo; (non-inlined) functions. Some good slides describing this are&#10;&lt;a href="https://blog.linuxplumbersconf.org/2014/ocw/system/presentations/1773/original/ftrace-kernel-hooks-2014.pdf"&gt;here&lt;/a&gt;. Other overviews of tracing technologies can be found &lt;a href="http://www.brendangregg.com/blog/2015-07-08/choosing-a-linux-tracer.html"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>using sed encryption on harddrives</title><link>https://chrisarges.net/posts/2018-02-15-using-sed-encryption-on-disks/</link><pubDate>Thu, 15 Feb 2018 21:42:03 -0600</pubDate><guid>https://chrisarges.net/posts/2018-02-15-using-sed-encryption-on-disks/</guid><description>&lt;p&gt;Disk encryption can be accomplished on Linux in many ways depending on your&#10;hardware. &lt;a href="https://gitlab.com/cryptsetup/cryptsetup/"&gt;LUKS&lt;/a&gt; provides block-layer level encryption, and most modern&#10;Linux distros provide easy ways to use and setup keys with the device. The&#10;&lt;a href="http://ecryptfs.org/"&gt;eCryptFS&lt;/a&gt; project provides filesystem level encryption which gives a bit&#10;more flexibility.&lt;/p&gt;&#10;&lt;p&gt;However, many new disks have encryption built-in to the drive&amp;rsquo;s controller and&#10;can be interfaced with utilities such as &lt;a href="https://wiki.archlinux.org/index.php/hdparm"&gt;hdparm&lt;/a&gt; and &lt;a href="https://github.com/Drive-Trust-Alliance/sedutil"&gt;sedutil-cli&lt;/a&gt;.&#10;This built in encryption is called FDE (Full Disk Encryption) or SED (Self&#10;Encrypting Drives). When these disks have encryption keys enabled, upon power&#10;loss they become locked and must be unlocked before they are used. Different&#10;protocols can be used for disks, here I&amp;rsquo;ll cover OPAL and ATA type commands.&lt;/p&gt;</description></item><item><title>signed kernel modules using an auxiliary key</title><link>https://chrisarges.net/posts/2016-03-25-signed-kernel-modules-using-an-auxiliary-key/</link><pubDate>Fri, 25 Mar 2016 14:55:59 -0500</pubDate><guid>https://chrisarges.net/posts/2016-03-25-signed-kernel-modules-using-an-auxiliary-key/</guid><description>&lt;p&gt;This post explains how to build a kernel and corresponding modules with the&#10;following criteria:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;CONFIG_MODULE_SIG_KEY&lt;/code&gt; is set to default and we destroy the private part of&#10;the signing key after the initial build&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;CONFIG_SYSTEM_TRUSTED_KEYS&lt;/code&gt; contains an additional certificate we can use to&#10;sign modules built afterwards or out of tree&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Module signing enforcement is turned on&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;By having a separate key for signing modules, one could potentially revoke the&#10;&amp;lsquo;out of tree&amp;rsquo; module signing key; but keep the built-in key for modules built&#10;during the initial build time.&lt;/p&gt;</description></item><item><title>a simple robotic car</title><link>https://chrisarges.net/posts/2016-03-18-a-simple-robotic-car/</link><pubDate>Fri, 18 Mar 2016 22:56:12 -0500</pubDate><guid>https://chrisarges.net/posts/2016-03-18-a-simple-robotic-car/</guid><description>&lt;p&gt;Here is a really cool car robot I built:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="https://chrisarges.net/images/robotv1.jpg" alt="Image of Robot"&gt;&lt;/p&gt;&#10;&lt;p&gt;This post will document roughly how I put it together. If you want to build&#10;your own you can read this guide for an outline and perhaps share or improve&#10;the code.&lt;/p&gt;&#10;&lt;h1 id="setup-board"&gt;Setup Board&lt;/h1&gt;&#10;&lt;p&gt;For my car robot I&amp;rsquo;m using a Raspberry Pi Zero since it is small and uses low&#10;power. First go to this &lt;a href="https://www.raspberrypi.org/downloads/raspbian/"&gt;link&lt;/a&gt;, download and install Raspbian Lite and&#10;ensure you can boot into it on your Pi. Expand your filesystem and ensure you&#10;can connect wirelesly to your board.&lt;/p&gt;</description></item><item><title>building ubuntu kernels with debug symbols</title><link>https://chrisarges.net/posts/2015-10-02-building-ubuntu-kernels-with-debug-symbols/</link><pubDate>Fri, 02 Oct 2015 08:53:52 -0500</pubDate><guid>https://chrisarges.net/posts/2015-10-02-building-ubuntu-kernels-with-debug-symbols/</guid><description>&lt;p&gt;Occasionally it is useful to be able to build a kernel the Ubuntu way with&#10;debug symbols. The following is how to install dependencies, clone the tree,&#10;and finally build in such a way that ddeb packages get generated.&lt;/p&gt;&#10;&lt;p&gt;Here&amp;rsquo;s how:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get build-dep linux-image-&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;uname -r&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install fakeroot pkg-config-dbgsym git&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/wily &#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd wily&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;fakeroot debian/rules clean&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;debian/rules build-generic&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;fakeroot debian/rules binary-generic binary-headers skipdbg&lt;span style="color:#f92672"&gt;=&lt;/span&gt;false&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Wait a bit and you should see a -dbgsym package get generated.&lt;/p&gt;</description></item><item><title>using linux livepatch on ubuntu</title><link>https://chrisarges.net/posts/2015-09-21-livepatch-on-ubuntu/</link><pubDate>Mon, 21 Sep 2015 13:03:26 -0500</pubDate><guid>https://chrisarges.net/posts/2015-09-21-livepatch-on-ubuntu/</guid><description>&lt;p&gt;Livepatching was &lt;a href="https://lkml.org/lkml/2014/11/6/387"&gt;introduced&lt;/a&gt; in the v4.0 kernel, and now Ubuntu 15.10 has&#10;a kernel capable of using this new and exciting feature. This works by using&#10;ftrace to redirect kernel function calls to the newly patched functions. In&#10;addition mechanisms for hooking into module insertion and removal are used for&#10;patching loadable modules. This feature also has sysfs directories for tracking&#10;which patches are applied and which functions they modify. With the basics&#10;aside, this blog post will show some simple examples of how to livepatch your&#10;kernel.&lt;/p&gt;</description></item><item><title>linux make deb-pkg speedup</title><link>https://chrisarges.net/posts/2015-07-30-linux-make-deb-pkg-speedup/</link><pubDate>Thu, 30 Jul 2015 15:20:31 -0500</pubDate><guid>https://chrisarges.net/posts/2015-07-30-linux-make-deb-pkg-speedup/</guid><description>&lt;p&gt;Because I&amp;rsquo;ve run &lt;code&gt;make deb-pkg&lt;/code&gt; so many times, I&amp;rsquo;ve started to see exactly where&#10;it starts to slow down even with really large machines. Observing cpu usage, I&#10;noticed that many parts of the build were serialized on a single core. Upon&#10;further investigation I found the following.&lt;/p&gt;&#10;&lt;h3 id="upstream-packaging"&gt;Upstream Packaging&lt;/h3&gt;&#10;&lt;p&gt;Module installation takes a really long time, and when building with&#10;&lt;code&gt;make deb-pkg -jN&lt;/code&gt;, you&amp;rsquo;ll see output like the following:&lt;/p&gt;</description></item><item><title>accessing maas database directly</title><link>https://chrisarges.net/posts/2015-05-27-accessing-maas-db-directly/</link><pubDate>Wed, 27 May 2015 13:02:46 -0500</pubDate><guid>https://chrisarges.net/posts/2015-05-27-accessing-maas-db-directly/</guid><description>&lt;p&gt;Let&amp;rsquo;s say you&amp;rsquo;ve messed up your MAAS installation and have no idea how to&#10;recover data about your nodes. Have no fear, you can access the django managed&#10;database directly.&lt;/p&gt;&#10;&lt;p&gt;Just use the following as root:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;maas-region-admin dbshell --installed&#10;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now you have access to an SQL command line interface.&lt;/p&gt;&#10;&lt;p&gt;For example if I want to see all hostnames and power_parameters for my servers,&#10;I can do the following:&lt;/p&gt;&#10;&lt;pre tabindex="0"&gt;&lt;code&gt;select hostname,power_parameters from maasserver_node;&#10;&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>using gcov/lcov with the linux kernel</title><link>https://chrisarges.net/posts/2014-11-13-using-gcovlcov-with-linux-kernel/</link><pubDate>Thu, 13 Nov 2014 09:45:00 -0800</pubDate><guid>https://chrisarges.net/posts/2014-11-13-using-gcovlcov-with-linux-kernel/</guid><description>&lt;p&gt;GCOV/LCOV are amazing tools to figure out code coverage in the Linux kernel. It&#10;is fairly trivial to setup on your own machine. First, enable the following in&#10;your kernel configuration:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CONFIG_GCOV_KERNEL&lt;span style="color:#f92672"&gt;=&lt;/span&gt;y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CONFIG_GCOV_PROFILE_ALL&lt;span style="color:#f92672"&gt;=&lt;/span&gt;y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CONFIG_GCOV_FORMAT_AUTODETECT&lt;span style="color:#f92672"&gt;=&lt;/span&gt;y&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Build the kernel and install headers/debug/images to your machine. Note there&#10;may be issues if you run this on a separate machine so consult the official&#10;&lt;a href="https://www.kernel.org/doc/Documentation/gcov.txt" title="gcov docs"&gt;documentation&lt;/a&gt; for additional information.&lt;/p&gt;&#10;&lt;p&gt;Boot the machine with the instrumented kernel and use the following to verify&#10;GCOV_KERNEL was setup properly:&lt;/p&gt;</description></item><item><title>getting kernel crashdumps for hung machines</title><link>https://chrisarges.net/posts/2014-10-31-getting-kernel-crashdumps-for-hung/</link><pubDate>Fri, 31 Oct 2014 13:53:00 -0700</pubDate><guid>https://chrisarges.net/posts/2014-10-31-getting-kernel-crashdumps-for-hung/</guid><description>&lt;p&gt;Debugging hung machines can be a bit tricky. Here I&amp;rsquo;ll document methods to&#10;trigger a crashdump when these hangs occur. What exactly does it mean when a&#10;machine &amp;lsquo;hangs&amp;rsquo; or &amp;lsquo;freezes-up&amp;rsquo;? More information can be found in the kernel&#10;&lt;a href="https://www.kernel.org/doc/Documentation/lockup-watchdogs.txt"&gt;documentation&lt;/a&gt;, but overall there are really a few types of hangs.&lt;/p&gt;&#10;&lt;p&gt;A &amp;ldquo;Soft Lock-Up&amp;rdquo; is when the kernel loops in kernel mode for a duration without&#10;giving tasks a chance to run. A &amp;ldquo;Hard Lock-Up&amp;rdquo; is when the kernel loops in kernel&#10;mode for a duration without letting other interrupts run. In addition a&#10;&amp;ldquo;Hung Task&amp;rdquo; is when a userspace task has been blocking for a duration.&lt;/p&gt;</description></item></channel></rss>