Advertise with Googlier.com tag/linux https://blog.liw.fi/tag/linux/ blog.liw.fi ikiwiki Sun, 08 Dec 2024 10:11:53 +0000 A QEMU question regarding user mode networking https://blog.liw.fi/posts/2024/qemu-network/ https://blog.liw.fi/posts/2024/qemu-network/ ambient linux qemu Sun, 08 Dec 2024 09:40:51 +0000 2024-12-08T10:11:53Z <p>Solved: this works: <code>-net nic,model=virtio -net user</code></p> <h2>My goal</h2> <p>I want to run a Debian cloud image with <code>qemu-system-x86_64</code> so that the guest operating system has network access using user mode networking.</p> <h2>Context</h2> <p>I want to use this as part of my CI system (Ambient). I would prefer to not use TUN/TAP networking, or to set up a bridge on the host. I'm aware that user mode networking with QEMU is constrained and limited, and I'm OK with that.</p> <p>I will explore the other options if user mode networking proves to be impossible.</p> <h2>What I've done</h2> <p>I've attached the script I've been experimenting with. To run, give it two arguments: the URL to the cloud image published by Debian, and the local filename where to store that.</p> <p>You'll need the following installed:</p> <ul> <li><code>wget</code></li> <li><code>qemu-img</code></li> <li><code>qemu-system-x86_64</code></li> <li><code>genisoimage</code></li> </ul> <p>You can run the script as an unprivileged user. If will run faster if you can use the Linux kernel <code>kvm</code> module, but it isn't required. On my laptop the device takes about three minutes to run, assuming the image has been downloaded already.</p> <p>What the script does is set up cloud-init to run <code>ip a</code>, and then run a VM with the cloud image and the cloud-init configuration, with two virtual serial ports directed to files <code>console.log</code> and <code>run.log</code>. The <code>ip</code> command output goes to the second one.</p> <p>What I want is for there to be a virtual Ethernet device. I've not been able to make that happens. The <code>ip</code> output in <code>run.log</code>, for me, is:</p> <pre><code>xyzzy from bootcmd to ttyS1 xyzzy from runcmd to ttyS1 1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever </code></pre> <p>This lists only the <code>lo</code> or loopback network interface. I'd like that to list <code>eth0</code> or another device via which the guest operating system can connect to the public Internet. For now, I'd be happy just to have the device: once I have that, I can tackle the problem of getting to have an IP address and outgoing Internet connectivity.</p> <p>(The <code>xyzzy</code> lines are just for debugging. You can ignore them.)</p> <h2>My specific request</h2> <p>How should I change the script so that the <code>ip</code> output lists the network device I want?</p> <p>I've tried many different variations of network related QEMU options, but nothing seems to give me what I want. I'm sure I'm doing something wrong, and I'm hoping it's obvious to someone else.</p> <p>Can you help me?</p> <p>You can respond to by email (<code>liw@liw.fi</code>), or on <a href="https://toot.liw.fi/@liw/113616546205333833">this fediverse thread</a>, or in any other way you can reach me.</p> <h2>The script</h2> <pre><code>#!/bin/bash # # Usage: scripts/qemu.sh https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2 /tmp/debian12.qcow2 set -euo pipefail # I use the generic Debian 12 image from # https://cloud.debian.org/images/cloud/bookworm/latest/ url="$1" image="$2" if [ ! -e "$image" ]; then wget -c "$url" -O "$image" chmod a-w "$image" fi tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT # Make a copy-on-write image, on top of the base image. This allows us # to modify things in the file system inside the running VM, without # affecting the base image. qemu-img create -b "$image" -F qcow2 -f qcow2 "$tmp/vm.qcow2" # Create a cloud-init local data source: an ISO image of a specific # form. The user-data runcmd writes to the run log (ttyS1) what # network interfaces are known, with the ip command. mkdir "$tmp/cloud-init" cat &lt;&lt;EOF &gt;"$tmp/cloud-init/user-data" #cloud-config bootcmd: - echo xyzzy from bootcmd to ttyS0 &gt; /dev/ttyS0 - echo xyzzy from bootcmd to ttyS1 &gt; /dev/ttyS1 runcmd: - echo xyzzy from runcmd to ttyS0 &gt; /dev/ttyS0 - echo xyzzy from runcmd to ttyS1 &gt; /dev/ttyS1 - ip a &gt; /dev/ttyS1 - poweroff EOF cat &lt;&lt;EOF &gt;"$tmp/cloud-init/meta-data" hostname: ambient EOF cat &lt;&lt;EOF &gt;"$tmp/cloud-init/network-config" network: version: 2 ethernets: eth0: dhcp4: true EOF genisoimage -quiet -volid CIDATA -joliet -rock -output "$tmp/cloud-init.iso" "$tmp/cloud-init" # Run the VM. qemu-system-x86_64 \ -m 2048 \ -display none \ -serial file:console.log \ -serial file:run.log \ -drive format=qcow2,if=virtio,file="$tmp/vm.qcow2" \ -cdrom "$tmp/cloud-init.iso" \ -nic user </code></pre> Framework 13 AMD, first impressions https://blog.liw.fi/posts/2024/framework/ https://blog.liw.fi/posts/2024/framework/ framework laptop linux system-administration Sun, 08 Sep 2024 16:52:36 +0000 2024-09-08T17:51:21Z <p>I've bought a new laptop to more efficiently work when I'm away from home. It's a <a href="https://frame.work/fi/en">Framework</a> <a href="https://frame.work/fi/en/products/laptop-diy-13-gen-amd?tab=specs">13 AMD</a>, with plenty of RAM and storage. Some first impressions:</p> <ul> <li>I bought the DIY version, which meant some assemble was required. I've built desktop PCs from parts and I wasn't scared. The laptop came with the necessary screwdriver, and the Framework website has an excellent <a href="https://guides.frame.work/Guide/Framework+Laptop+13+(AMD+Ryzen%E2%84%A2+7040+Series)+DIY+Edition+Quick+Start+Guide/211?lang=en">guide</a>. With barely a quiver, I started the quest. The assembly consisted of: <ul> <li>install RAM modules (easy, just snap in)</li> <li>install m.2 SSD (easy, one screw)</li> <li>connect touch pad cable (easy, unless you get confused about 3D geometry or only have two arms)</li> <li>install the keyboard/touch pad (easy, magnets)</li> <li>install the display bezel (easy, magnets)</li> <li>screw in the back plate (easy, five screws)</li> <li>install extension modules (easy, push into slot)</li> </ul> </li> <li>The whole assembly took less than fifteen minutes. It would've been faster if I hadn't taken photographs of every step.</li> <li>The hardware seems nice. It's thin and lightweight, so it should be easy to travel with.</li> <li>I quite like the screen. It's bright.</li> <li>I don't like the keyboard, but I don't like any laptop keyboards. (I'm spoiled by a <a href="https://shop.keyboard.io/products/model-100">Keyboardio Model100</a>, which comes with a travel case.).</li> <li>The touch pad seems OK.</li> <li>The lid hinge seems OK, and general build quality is fine. It doesn't feel as solid as the ones in the ThinkPads that have been my only personal laptops since 2009, but few things do.</li> <li>The extension modules seem great. I got a selection.</li> </ul> <p>After that, I installed Linux on it. The Debian <a href="https://cdimage.debian.org/cdimage/weekly-builds/amd64/iso-cd/">in-development installer</a> works, but I used my own installer (<a href="https://v-i.liw.fi/">v-i</a>), because I'm an old and grumpy and like my own toys. I'm prepared to re-install at the drop of a hat.</p> <p>The Debian installation passes my <a href="https://blog.liw.fi/posts/2024/laptop-checklist/">checklist</a> for my primary laptop. WiFi, suspend, graphics, it all works so far. (I may make a more detailed review once I've used the machine a while, like <a href="https://anarc.at/hardware/laptop/framework-12th-gen/">anarcat</a> has done. I'll collect my notes and links on my <a href="https://liw.fi/framework">own page</a>.)</p> <p>The biggest hurdle I had was this isn't a ThinkPad. I had to learn things about Linux configuration I've not had to think about in fifteen years: the WiFi driver isn't called <code>iwlwifi</code>, and the GPU needs a firmware blob.</p> <p>I specifically needed to install Debian <code>trixie</code> (which will become Debian 13), not Debian 12 (<code>bookworm</code>), because the laptop hardware is sufficiently new that it needs newer kernel and device drivers than what the current Debian stable release has. The <code>trixie</code> version is expected to be released next year, and I can cope with running an in-development version of my operating system until then.</p> <p>(Those who prefer other Linux distributions that make more frequent releases than Debian does can just use a recent release of their preferred distribution. I like Debian, but I don't judge your for your preference; please don't judge me for mine. I got tired to distro hopping in 1995.)</p> <p>I've got the laptop basically working, and haven't really used it yet for real. I expect I'll be doing a lot of tweaking to its setup in the coming weeks. For those interested, I've published the <a href="https://app.radicle.xyz/nodes/radicle.liw.fi/rad:z3sckw1Xm8j5URDJz1zeESHfFYDEc/tree/v-i/cantata-spec.yml">v-i spec</a> and Ansible <a href="https://app.radicle.xyz/nodes/radicle.liw.fi/rad:z3sckw1Xm8j5URDJz1zeESHfFYDEc/tree/ansible/cantata.yml">playbook</a>, though given they're peculiar to my way of doing things, they may not be all that useful for others.</p> <p>I call the machine <code>cantata</code>, after <a href="https://www.youtube.com/results?search_query=cantata+sangui">Cantata Sangui</a>, a former Finnish heavy metal band that a friend of mine used to be part of. (My naming theme for my computers is <a href="https://en.wikipedia.org/wiki/Category:Finnish_heavy_metal_musical_groups">Finnish heavy metal bands</a>).</p> Rant: year of Linux on the desktop https://blog.liw.fi/posts/2022/goalposts/ https://blog.liw.fi/posts/2022/goalposts/ linux rant retrospective Thu, 29 Dec 2022 17:45:39 +0000 2022-12-29T17:45:39Z <p>A rant about "year of Linux on the desktop" from a tired old man. I've been part of the Linux community since before Linux was called Linux. Over the years there's been many people telling me directly that Linux is silly or wrong or imperfect, or that free and open source software is foolish or pointless. A lot more people have, of course, pontificated along those lines in public, and not directed it at me. I'm not claiming to be targeted at that, but I've been around and active for long enough that things accumulate. It's the end of a long year for me, and I though I'd let off some steam myself. Hence this rant.</p> <p>Over time, the goal posts of success keep being moved by the naysayers. I'm too tired to dig up all important milestones and dates, or references, but here's highlights of the timeline as I have experienced it (years may be a little off):</p> <ul> <li>1991: It's not possible for a hobbyist to write their own operating system kernel.</li> <li>1992: Well OK, you have a kernel, but there's no networking or a graphical desktop, so it's not actually useful. Anyway, ain't nobody got time to compile all their software.</li> <li>1993: Fine, there's some kind of desktop, but it doesn't support drag and drop so it's a toy. Also, it won't go anywhere unless it fully and equally supports every graphics card ever made for the PC. Oh, and these pre-build distributions are insecure. Don't download code from the Internet and run that, that's just stupid.</li> <li>1994: Linux is pointless, since it only runs on the PC and not on any other kind of computer.</li> <li>1997: All these Linux users are just hobbyists, nobody will use it for anything important.</li> <li>1998: Corporations will never put money into developing this free software thing.</li> <li>2000: Linux and free software are a cancer on the IT industry.</li> <li>2001: The dotcom bubble burst, so Linux will now die, since nobody can afford to continue to develop it, as there's no profit in free software.</li> <li>2003: Uh, okay, Linux didn't die. But it's too hard to install.</li> <li>2005: Ubuntu is just a toy.</li> <li>2006: So Linux is used a lot, but only on servers. It will never work on phones or embedded devices.</li> </ul> <p>(skipping ahead so I don't drag up too many bad memories)</p> <ul> <li>2022: Linux runs all top 500 super computers, billions of personal devices, most servers on the Internet, on all continents, on all oceans, in the air, in orbit, and on Mars. Oh, and in the air on Mars. All big corporations use open source in some form.</li> <li>Also 2022: Linux will always be a hobbyist toy, unless solves all these new problems we've just thought about.</li> </ul> <p>Next year, 2023, will be my thirtieth year of Linux on the desktop, and the thirtieth year of being told it's not possible to use Linux on the desktop, or to only use Linux on the desktop. Some of the people telling me this weren't born when I started using Linux on the desktop.</p> <p>Despite everything, it's been fun. I've been lucky to have been able to take part of this journey.</p> A billion files https://blog.liw.fi/posts/2020/10/01/a_billion_files/ https://blog.liw.fi/posts/2020/10/01/a_billion_files/ file-system linux Thu, 24 Sep 2020 08:04:00 +0000 2022-08-22T04:52:09Z <p>I'm sometimes cruel to my tools to learn how they behave in unusual circumstances. For example, what is the fastest way to delete a very large number of files?</p> <p>If the circumstances are just right, the answer may be <code>mkfs</code> to create a new, empty file system. But it's not always the appropriate answer.</p> <p>The more obvious answer is <code>sudo rm -rf</code>&mdash;or so you'd think. It turns out, however, that sometimes <code>find -delete</code> is a lot faster, or so I learned when I did a little speed testing some years ago. I've been told that <code>rsync -delete</code> is even faster than that. What is the current situation?</p> <p>How would you test that? I would start by creating a large number of files in a directory tree, and then delete them. How many should I create?</p> <p>Performance tends to only be interesting for large values of N. Thus, I've created a file system billion files. Since I pay for my own storage, I created empty files.</p> <p>I did this twice: once using ext4, once with btrfs. Those are the file systems I currently care about. The disks were overwritten with zeroes first, and afterwards I stashed a way a copy compressed with xzip. The ext4 one is 11 GiB, the btrfs one 31 GiB.</p> <p>I've unpacked the disk images to an LV attached to a VM, then run various commands to delete the file.</p> <table> <thead> <tr> <th>command </th> <th> ext4 (s) </th> <th> btrfs (s)</th> </tr> </thead> <tbody> <tr> <td>rm -rf </td> <td> 18647 </td> <td> 19783</td> </tr> <tr> <td>find -delete </td> <td> 18964 </td> <td> 19702</td> </tr> <tr> <td>rsync --del </td> <td> 24279 </td> <td> 53516</td> </tr> </tbody> </table> <p>Based this entirely unscientific benchmark, the fastest way to delete files is either rm of find, with not much difference between them. rsync seems to be significantly slower.</p> <p>I didn't measure memory use or other factors. If someone knows of a CS student who could do this more formally for class, I'm sure it'd be a fascinating project. Have at it.</p> <p>Links:</p> <ul> <li><a href="https://events.static.linuxfound.org/slides/2010/linuxcon2010_wheeler.pdf">https://events.static.linuxfound.org/slides/2010/linuxcon2010_wheeler.pdf</a> <ul> <li>slides of talk from 2010 about creating file systems with a billion files: back then it was a challenge to do that, now it's not</li> </ul> </li> <li><a href="https://lwn.net/Articles/400629/">https://lwn.net/Articles/400629/</a> <ul> <li>LWN article about the talk</li> </ul> </li> <li><a href="http://git.liw.fi/billion-files/">http://git.liw.fi/billion-files/</a> <ul> <li>the scripts I used for this</li> <li>they're stupid, but simple so they can be easily reviewed</li> <li>they run during my work day or overnight</li> </ul> </li> </ul> Linux 25 jubilee symposium https://blog.liw.fi/posts/linux25/ https://blog.liw.fi/posts/linux25/ linux Mon, 22 Aug 2016 15:03:38 +0000 2016-08-22T15:03:38Z <p>I gave a talk about the early days of Linux at the <a href="https://linux25.cs.helsinki.fi/en/">jubilee symposium</a> arranged by the University of Helsinki CS department. Below is an outline of what I meant to speak about, but the actual talk didn't follow it exactly. You can compare these to the video once it comes online.</p> <ul> <li>Linus and I met at uni, the only 2 Swedish speaking new students that year, so we naturally migrated towards each other.</li> <li>After a year away for military service, got back in touch, summer of <ol> <li></li> </ol> </li> <li>C &amp; Unix course fall of 1990; Minix.</li> <li>Linus didn't think atime updates in real time were plausible, but I showed him; funnily enough, atime updates have been an issue in Linux until fairly recently, since they slow things down (without being particularly useful)</li> <li>Jan 5, 1991 bought his first PC (i386 + i387 + 4 MiB RAM and a small hard disk); he had a Sinclair QL before that.</li> <li>Played Prince of Persia for a couple of months.</li> <li>Then wanted to learn i386 assembly and multitasking.</li> <li>A/B threading demo.</li> <li>Terminal emulation, Usenet access from home.</li> <li>Hard disk driver, mistaking hard disk for a modem.</li> <li>More ambition, announced Linux to the world for the first time</li> <li>first ever Linux installation.</li> <li>Upload to ftp.funet.fi, directory name by Ari Lemmke.</li> <li>Originally not free software, licence changed early 1992.</li> <li>First mailing list was created and introduced me to a flood of email (managed with VAX/VMS MAIL and later mush on Unix).</li> <li>I talked a lot with Linus about design at this time, but never really participated in the kernel work (partly because disagreeing with Linus is a high-stress thing).</li> <li>However, I did write the first sprintf for the kernel, since Linus hadn't learnt about varargs functions in C; he then ruined it and added the comment "Wirzenius wrote this portably..." (add google hit count for wirzenius+fucked).</li> <li>During 1992 Linux grew fast, and distros happened, and a lot of packaging and porting of software; porting was easier because Linus was happy to add/change things in the kernel to accomodate software</li> <li>A lot of new users during 1992 as well.</li> <li>End of 1992 I and a few others founded the Linux Documentation Project to help all the new users, some of who didn't come from a Unix background.</li> <li>In fact, things progressed so fast in 1992 that Linus thought he'd release 1.0 very soon, resulting in a silly sequence of version numbers: 0.12, 0.95, 0.96, 0.96b, 0.96c, 0.96c++2.</li> <li>X server ported to Linux; almost immediate prediction of the year of the Linux desktop never happening unless ALL the graphics cards were supported immediately.</li> <li>Linus was of the opinion that you needed one process (not thread) per window in X; I taught him event driven programming.</li> <li>Bug in network code, resulting in ban on uni network.</li> <li>Pranks in the shared office room.</li> <li>We released 1.0 in an event at the CS dept in March, 1994; this included some talks and a ritual compilation of the release version during the event.</li> </ul> Matthew Garret and Intel and the so-called gamergate https://blog.liw.fi/posts/mjg59-vs-intel/ https://blog.liw.fi/posts/mjg59-vs-intel/ decorum linux politics Fri, 03 Oct 2014 13:55:38 +0000 2014-10-03T13:55:38Z <p>Kudos to Matthew for <a href="http://mjg59.dreamwidth.org/32778.html">taking a stance</a>. It has, not surprisingly, provoked a lot of comments and feedback, most of it unpleasant.</p> <p>If I did anything that was directly related to Intel, I'd join him, but I do very, very little architecture dependent stuff anymore.</p> <p>I will, however, say this: Even if the "gamergate" were actually about good journalism and ethics (and it's clear it isn't), if your reaction to a differing opinion is abuse, harrassment, and other kinds of psychological violence, you're not making anything better, you're making it all worse.</p> <p>Reasonable people can handle disagreement without any kind of violence.</p> Thinkpad X200s scroll wheel emulation https://blog.liw.fi/posts/scroll-wheel-emulation/ https://blog.liw.fi/posts/scroll-wheel-emulation/ linux Mon, 11 Mar 2013 20:50:59 +0000 2013-03-11T20:50:59Z <p><a href="http://www.digital-scurf.org/">Daniel</a> told me how to set up scroll wheel emulation on a Thinkpad. Presumably it works on other systems as well, but the magic numbers for xinput may be different. I wrote a script to set it up, and configure my GNOME session to run it upon login.</p> <p>The result: pressing the middle mouse button and moving the trackpoint up/down or left/right results in the applications receiving events as if a scroll wheel had been used.</p> <p>Very, very handy. Thanks, Daniel.</p> <pre><code>#!/bin/sh set -eu id=$(xinput list | sed -n '/TPPS\/2 IBM TrackPoint/s/.*id=\([0-9]\+\).*/\1/p') emu=$(xinput list-props "$id" | sed -n '/Evdev Wheel Emulation (/s/.*(\([0-9]\+\)).*/\1/p') but=$(xinput list-props "$id" | sed -n '/Evdev Wheel Emulation Button (/s/.*(\([0-9]\+\)).*/\1/p') axs=$(xinput list-props "$id" | sed -n '/Evdev Wheel Emulation Axes (/s/.*(\([0-9]\+\)).*/\1/p') xinput set-int-prop "$id" "$emu" 8 1 xinput set-int-prop "$id" "$but" 8 2 #xinput set-int-prop "$id" "$axs" 8 6 7 4 5 </code></pre> What is a Linux distribution? https://blog.liw.fi/posts/what-is-a-distro/ https://blog.liw.fi/posts/what-is-a-distro/ debian linux Sun, 08 Apr 2012 12:15:00 +0000 2012-04-08T12:15:00Z <p>I got into a discussion recently about what a Linux distribution actually is. To some people, a distro is just a convenient way of source of binaries from which to pick what you install, either on your own computer or when creating an embedded system, or some other specific kind of system. To others it's a way of life, and the realization of the ideals of software freedom. To yet others, a distro is an outdated concept that will go away in the near-ish future, to be replaced by ... something.</p> <p>Here's my take: a Linux distribution is defined by the following things:</p> <ul> <li>It's a specific, chosen set of upstream projects. The selection criteria vary wildly between distros, and may be based on things like purpose, quality, licenses, etc. Debian, for example, chooses pretty much everything that is free software, but a distro targeted at providing NAS devices would choose a much smaller set.</li> <li>It's a set of changes made to the upstream code, and specific configurations of the upstream code, in order make all the software work well together. For example, if the distro supports multiple mail transport agents, they might all need to be patched and configured to store incoming mail the same way by default.</li> <li>It's the tools, processes, policies, and workflows used to develop the distribution.</li> <li>It's the tools provided to the people using the distribution to install and manage their systems.</li> <li>It's the people and companies who develop the distribution and support its users, and their shared values and purpose. This may be a real community, or just the kind of community that exists as a web page.</li> </ul> <p>Historically, there has been a lot of variation in all aspects mentioned above. Some of this variation may today be unnecessary. For example, it might be helpful for more distributions to share work on common tools, so that not everyone needs to re-invent and re-implement the same kinds of tools. However, my gut feeling is that due to the inherent interconnectedness of all things, it may be very difficult to have one set of tools to support well all workflows, policies, processes, and communities.</p> <p>The most important differentiating factors between the various distros are not the tools, but the community values, the perceived purpose of the distro, and the resultant criteria for choosing what to include and the workflow for developing the distro.</p> <p>Even when two distros use the same tools, there can be a lot of difference in the end result. Fedora and RHEL, for example, use a lot of the same infrastructure, but their purpose is entirely different. Debian and Ubuntu use mostly the same packages, even, and still there's a huge difference between the two distros: one aims at a high quality system based on free software, the other aims to support the business of one particular company.</p> <p>For this reason, there will always be a lot of Linux distributions around, and that is good.</p> On the future of Linux distributions https://blog.liw.fi/posts/future-of-linux-distros/ https://blog.liw.fi/posts/future-of-linux-distros/ baserock debian linux Fri, 28 Oct 2011 19:17:05 +0000 2011-10-28T19:17:05Z <h2>Executive summary</h2> <p>Debian should consider:</p> <ul> <li>less fine-grained software packaging for overall simplification of the system and its development</li> <li>less flexibility at the lower levels of the software stack, again for overall simplicity</li> <li>reducing friction in the development workflow, especially by making it possible to branch and merge at the whole system level</li> </ul> <h2>Introduction</h2> <p>I've taken a job with <a href="http://www.codethink.co.uk/">Codethink</a>, as part of a team to develop a new embedded Linux system, called <a href="http://wiki.baserock.org/">Baserock</a>. Baserock is not a distribution as such, but deals with many of the same issues. I thought it might be interesting to write out my new thoughts related to this, since they might be useful for proper distributions to think about too.</p> <p>I'll hasten to add that many of these thoughts are not originally mine. I shamelessly adopt any idea that I think is good. The core ideas for Baserock come from Rob Taylor, Daniel Silverstone, and Paul Sherwood, my colleagues and bosses at Codethink. At the recent GNOME Summit in Montreal, I was greatly influenced by Colin Walters.</p> <p>This is also not an advertisment for Baserock, but since my of my current thinking come from that project, I'll discuss things in the context of Baserock.</p> <p>Finally, I'm writing this to express my personal opinion and thoughts. I'm not speaking for anyone else, least of all Codethink.</p> <h2>On the package abstraction</h2> <p>Baserock abandons the idea of packages for all individual programs. In the early 1990s, when Linux was new, and the number of packages in a distribution could be counted on two hands in binary, packages were a great idea. It was feasible to know at least something about every piece of software, and pick the exact set of software to install on a machine.</p> <p>It is still feasible to do so, but only in quite restricted circumstances. For example, picking the packages to install a DNS server, or an NFS server, or a mail server, by hand, without using meta packages or tasks (in Debian terminology), is still quite possible. On embedded devices, there's also usually only a handful of programs installed, and the people doing the install can be expected to understand all of them and decide which ones to install on each specific device.</p> <p>However, those are the exceptions, and they're getting rarer. For most people, manually picking software to install is much too tedious. In Debian, we've realised this a great many years ago, and developed meta packages (whose only purpose is to depend on other packages) and tasks (solves the same problem, but differently). These make it possible for a user to say "I want to have the GNOME desktop environment", and not have to worry about finding every piece that belongs in GNOME, and install that separately.</p> <p>For much of the past decade, computers have had sufficient hard disk space that it is no longer necessary to be quite so picky about what to install. A new cheap laptop will now typically come with at least 250 gigabytes of disk space. An expensive one, with an SSD drive, will have at least 128 gigabytes. A fairly complete desktop install uses less than ten gigabytes, so there's rarely a need to pick and choose between the various components.</p> <p>From a usability point of view, choosing from a list of a dozen or two options is much easier than from a list of thirty five thousand (the number of Debian packages as I write this).</p> <p>This is one reason why Baserock won't be using the traditional package abstraction. Instead, we'll collect programs into larger collections, called strata, which form some kind of logical or functional whole. So there'll be one stratum for the core userland software: init, shell, libc, perhaps a bit more. There'll be another for a development environment, one for a desktop environment, etc.</p> <p>Another, equally important reason, to move beyond packages is the problems caused by the combinatorial explosion of packages and versions. Colin Walters talks about this very well. When every system has a fairly unique set of packages, and versions of them, it becomes much harder to ensure that software works well for everyone, that upgrades work well, and that any problems get solved. When the number of possible package combinations is small, getting the interactions between various packages right is easier, QA has a much easier time to test all upgrade paths, and manual test coverage improves a lot when everyone is testing the same versions. Even debugging gets easier, when everyone can easily run the same versions.</p> <p>Grouping software into bigger collections does reduce flexibility of what gets installed. In some cases this is important: very constrainted embedded devices, for example, still need to be very picky about what software gets installed. However, even for them, the price of flash storage is low enough that it might not matter too much, anymore. The benefit of a simpler overall system may well outweigh the benefit of fine-grained software choice.</p> <h2>Everything in git</h2> <p>In Baserock, we'll be building everything from source in git. It will not be possible to build anything, unless the source is committed. This will allow us to track, for each binary blob we produce, the precise sources that were used to bulid it.</p> <p>We will also try to achieve something a bit more ambitious: anything that affects any bit in the final system image can be traced to files committed to git. This means tracking also all configuration settings for the build, and the whole build environment, in git.</p> <p>This is important for us so that we can reproduce an image used in the field. When a customer is deploying a specific image, and needs it to be changed, we want to be able to make the change with the minimal changes compared to the previous version of the image. This requires that we can re-create the original image, from source, bit for bit, so that when we make the actual change, only the changes we need to make affect the image.</p> <p>We will make it easy to branch and merge not just individual projects, but the whole system. This will make it easy to do large changes to the system, such as transitioning to a new version of GNOME, or the toolchain. Currently, in Debian, such large changes need to be serialised, so that they do not affect each other. It is easy, for example, for a GNOME transition to be broken by a toolchain transition.</p> <p>Branching and merging has long been considered the best available solution for concurrent development within a project. With Baserock, we want to have that for the whole system. Our build servers will be able to build images for each branch, without requiring massive hardware investment: any software that is shared between branches only gets built once.</p> <p>Launchpad PPAs and similar solutions provide many of the benefits of branching and merging on the system level. However, they're much more work than "git checkout -b gnome-3.4-transition". I believe that the git based approach will make concurrent development much more efficient. Ask me in a year if I was right.</p> <h2>Git, git, and only git</h2> <p>There are a lot of version control systems in active use. For the sake of simplicity, we'll use only git. When an upstream project uses something else, we'll import their code into git. Luckily, there are tools for that. The import and updates to it will be fully automatic, of course.</p> <p>Git is not my favorite version control system, but it's clearly the winner. Everything else will eventually fade away into obscurity. Or that's what we think. If it turns out that we're wrong about that, we'll switch to something else. However, we do not intend to have to deal with more than one at a time. Life's too short to use all possible tools at the same time.</p> <h2>Tracking upstreams closely</h2> <p>We will track upstream version control repositories, and we will have an automatic mechanism of building our binaries directly from git. This will, we hope, make it easy to follow closely upstream development, so that when, say, GNOME developers make commits, we want to be able to generate a new system image which includes those changes the same day, if not within minutes, rather than waiting days or weeks or months.</p> <p>This kind of closeness is greatly enhanced by having everything in version control. When upstream commits changes to their version control system, we'll mirror them automatically, and this then triggers a new system image build. When upstream makes changes that do not work, we can easily create a branch from any earlier commit, and build images off that branch.</p> <p>This will, we hope, also make it simpler to make changes, and give them back to upstream. Whenever we change anything, it'll be done in a branch, and we'll have system images available to test the change. So not only will upstream be able to easily get the change from our git repository, they'll also be easily verify, on a running system, that the change fixes the problem.</p> <h2>Automatic testing, maybe even test driven development</h2> <p>We will be automatically building system images from git commits for Baserock. This will potentially result in a very large number of images. We can't possibly test all of them manually, so we will implement some kind of automatic testing. The details of that are still under discussion.</p> <p>I hope to be able to start adding some test driven development to Baserock systems. In other words, when we are requested to make changes to the system, I want the specification to be provided as executable tests. This will probably be impossible in real life, but I can hope.</p> <p>I've talked about doing the same thing for Debian, but it's much harder to push through such changes in an established, large project.</p> <h2>Solving the install, upgrade, and downgrade problems</h2> <p>All mainstream Linux distributions are based on packages, and they all, pretty much, do installations and upgrades by unpacking packages onto a running system, and then maybe running some scripts from the packages. This works well for a completely idle system, but not so well on systems that are in active use. Colin Walters again talks about this.</p> <p>For installation of new software, the problem is that someone or something may invoke it before it is fully configured by the package's maintainer script. For example, a web application might unpack in such a way that the web server notices it, and a web browser may request the web app to run before it is configured to connect to the right database. Or a GUI program may unpack a <code>.desktop</code> file before the executable or its data files are unpacked, and a user may notice the program in their menu and start it, resulting in an error.</p> <p>Upgrades suffer from additonal problems. Software that gets upgraded may be running during the upgrade. Should the package manager replace the software's data files with new versions, which may be in a format that the old program does not understand? Or install new plugins that will cause the old version of the program to segfault? If the package manager does that, users may experience turbulence without having put on their seat belts. If it doesn't do that, it can't install the package, or it needs to wait, perhaps for a very long time, for a safe time to do the upgrade.</p> <p>These problems have usually been either ignored, or solved by using package specific hacks. For example, plugins might be stored in a directory that embeds the program's version number, ensuring that the old version won't see the new plugins. Some people would like to apply installs and upgrades only at shutdown or bootup, but that has other problems.</p> <p>None of the hacks solve the downgrade problem. The package managers can replace a package with an older version, and often this works well. However, in many cases, any package maintainer scripts won't be able to deal with downgrades. For example, they might convert data files to a new format or name or location upon upgrades, but won't try to undo that if the package gets downgraded. Given the combinatorial explosion of package versions, it's perhaps just as well that they don't try.</p> <p>For Baserock, we absolutely need to have downgrades. We need to be able to go back to a previous version of the system if an upgrade fails. Traditionally, this has been done by providing a "factory reset", where the current version of the system gets replaced with whatever version was installed in the factory. We want that, but we also want to be able to choose other versions, not just the factory one. If a device is running version X, and upgrades to X+1, but that version turns out to be a dud, we want to be able to go back to X, rather than all the way back to the factory version.</p> <p>The approach we'll be taking with Baserock relies on btrfs and subvolumes and snapshots. Each version of the system will be installed in a separate subvolume, which gets cloned from the previous version, using copy-on-write to conserve space. We'll make the bootloader be able to choose a version of the system to boot, and (waving hands here) add some logic to be able to automatically revert to the previous version when necessary. We expect this to work better and more reliably than the current package based one.</p> <h2>Making choices</h2> <p>Debian is pretty bad at making choices. Almost always, when faced with a need to choose between alternative solutions for the same problem, we choose all of them. For example, we support pretty much every <code>init</code> implementation, various implementations of <code>/bin/sh</code>, and we even have at least three entirely different kernels.</p> <p>Sometimes this is non-choice is a good thing. Our users may need features that only one of the kernels support, for example. And we certainly need to be able to provide both mysql and postresql, since various software we want to provide to our uses needs one and won't work with the other.</p> <p>At other times, the inability to choose causes trouble. Do we really need to support more than one implemenation of <code>/bin/sh</code>? By supporting both dash and bash for that, we double the load on testing and QA, and introduce yet another variable to deal with into any debugging situation involving shell scripts.</p> <p>Especially for core components of the system, it makes sense to limit the flexibility of users to pick and choose. Combinatorial explosion déjà vu. Every binary choice doubles the number of possible combinations that need to be tested and supported and checked during debugging.</p> <p>Flexibility begets complexity, complexity begets problems.</p> <p>This is less of a problem at upper levels of the software stack. At the very top level, it doesn't really matter if there are many choices. If a user can freely choose between vi and Emacs, and this does not add complexity at the system level, since nothing else is affected by that choice. However, if we were to add a choice between glibc, eglibc, and uClibc for the system C library, then everything else in the system needs to be tested three times rather than once.</p> <h2>Reducing the friction coefficient for system development</h2> <p>Currently, a Debian developer takes upstream code, adds packaging, perhaps adds some patches (using one of several methods), builds a binary package, tests it, uploads it, and waits for the build daemons and the package archive and user-testers to report any problems.</p> <p>That's quite a number of steps to go through for the simple act of adding a new program to Debian, or updating it to a new version. Some of it can be automated, but there's still hoops to jump through.</p> <p>Friction does not prevent you from getting stuff done, but the more friction there is, the more energy you have to spend to get it done. Friction slows down the crucial hack-build-test cycle of software development, and that hurts productivity a lot. Every time a developer has to jump through any hoops, or wait for anything, he slows down.</p> <p>It is, of course, not just a matter of the number of steps. Debian requires a source package to be uploaded with the binary package. Many, if not most, packages in Debian are maintained using version control systems. Having to generate a source package and then wait for it to be uploaded is unnecessary work. The build daemon could get the source from version control directly. With signed commits, this is as safe as uploading a tarball.</p> <p>The above examples are specific to maintaining a single package. The friction that really hurts Debian is the friction of making large-scale changes, or changes that affect many packages. I've already mention the difficulty of making large transitions above. Another case is making policy changes, and then implementing them. An excellent example of that is in Debian is the policy change to use <code>/usr/share/doc</code> for documentation, instead of <code>/usr/doc</code>. This took us many years to do. We are, I think, perhaps a little better at such things now, but even so, it is something that should not take more than a few days to implement, rather than half a decade.</p> <h2>On the future of distributions</h2> <p>Occasionally, people say things like "distributions are not needed", or that "distributions are an unnecessary buffer between upstream developers and users". Some even claim that there should only be one distribution. I disagree.</p> <p>A common view of a Linux distribution is that it takes some source provided by upstream, compiles that, adds an installer, and gives all of that to the users. This view is too simplistic.</p> <p>The important part of developing a distribution is choosing the upstream projects and their versions wisely, and then integrating them into a whole system that works well. The integration part is particularly important. Many upstreams are not even aware of each other, nor should they need to be, even if their software may need to interact with each other. For example, not every developer of HTTP servers should need to be aware of every web application, or vice versa. (It they had to be, it'd be a combinatorial explosion that'd ruin everything, again.)</p> <p>Instead, someone needs to set a policy of how web apps and web servers interface, what their common interface is, and what files should be put where, for web apps to work out of the box, with minimal fuss for the users. That's part of the integration work that goes into a Linux distribution. For Debian, such decisions are recorded in the Policy Manual and its various sub-policies.</p> <p>Further, distributions provide quality assurance, particularly at the system level. It's not realistic to expect most upstream projects to do that. It's a whole different skillset and approach that is needed to develop a system, rather than just a single component.</p> <p>Distributions also provide user support, security support, longer term support than many upstreams, and port software to a much wider range of architectures and platforms than most upstreams actively care about, have access to, or even know about. In some cases, these are things that can and should be done in collaboration with upstreams; if nothing else, portability fixes should be given back to upstreams.</p> <p>So I do think distributions have a bright future, but the way they're working will need to change.</p> Linux at 20 https://blog.liw.fi/posts/linux20/ https://blog.liw.fi/posts/linux20/ history linux Thu, 18 Aug 2011 10:37:03 +0000 2011-08-18T10:37:03Z <p>Wrote up some of my memories about the early history of Linux. See <a href="http://liw.fi/linux20/">http://liw.fi/linux20/</a>, but be warned that it's long and rambling.</p> Linux 20 years: anecdotes from 1998 https://blog.liw.fi/posts/linux-anecdotes/ https://blog.liw.fi/posts/linux-anecdotes/ anecdote history linux Wed, 10 Aug 2011 19:34:00 +0000 2011-08-10T19:34:00Z <p>Linux will be 20 years old this year. I've been drafting an outline for an article of my memories of the early days, but that's going to take a lot of writing before it is ready.</p> <p>Just in case I don't finish the article, I'll point at <a href="http://liw.fi/linux-anecdotes/">Linux Anecdotes</a>, the transcript of a talk I gave in 1998, when Linux was only seven years old. It might still be entertaining to some. If nothing else, you can laugh at my naivete about the future, now our past.</p> rm is too slow https://blog.liw.fi/posts/rm-is-too-slow/ https://blog.liw.fi/posts/rm-is-too-slow/ linux rant Sun, 17 Jul 2011 08:42:02 +0000 2011-07-17T08:42:02Z <p>Some weeks ago I noticed that one of my backup servers was not removing the old backup generations it was making. It had over 18 months worth of daily backups, done with rsync and "cp -al". This is not the world's greatest backup system, but that's entirely irrelevant for this rant.</p> <p>The cron job that would do that did not exist: I had forgotten to enable it.</p> <p>So I ran it by hand. Then fixed it, when I noticed it was buggy, and didn't remove any old generations prior to 2010. After that I removed years-old backups of machines that haven't existed for years.</p> <p>Disk usage:</p> <pre><code> Size Used Avail Use% before 5.4T 2.6T 2.6T 51% after 5.4T 892G 4.3T 18% </code></pre> <p>Inodes:</p> <pre><code> Inodes IUsed IFree IUse% before 732577792 77645915 654931877 11% after 732577792 16871789 715706003 3% </code></pre> <p>That's about 61 million files removed, over the course of three weeks, of which the machine was down due to crashes for about one week.</p> <p>It should not take two weeks to copy a couple of terabytes (it's less than two megabytes per second). It should definitely not take two weeks to delete it. Almost all the time it was up, it was removing files. There were a couple of times when it finished one run and was idle until I woke up and started the next run. Say a day in total.</p> <p>Why is "sudo rm -rf" on a large directory tree, or set of large directory trees, so slow? I suspect part of the problem is that the system call API is beautiful, but simplistic: you need to call unlink or rmdir on every file separately, and that means doing an inode lookup separately for each file. Having a system call to delete everything in a directory would have a chance of removing things more efficiently, I suspect. However, since I've not done any profiling, nor even analyzed the relevant source code in the kernel, I might be entirely wrong.</p> <p>I wonder if anyone else needs to remove large directory trees frequently? I do that a lot, because of my backup software development hobby. But I may be in a unique position, and nobody else would benefit from fast removal.</p> <p>(I'll note that my backup server is using ext3, and that ext4 is much faster at removing files, particularly large files, but it's still not fast enough.)</p> Beep be gone https://blog.liw.fi/posts/beepless/ https://blog.liw.fi/posts/beepless/ debian linux Sat, 07 May 2011 11:35:49 +0000 2011-05-07T11:35:49Z <p>It is a fundamental part of my belief structure that computers should be silent, unless told otherwise. A default install of the operating system should not make any sounds, unless there is a really good reason to. Thus, I object to the following:</p> <ul> <li>GDM beeping when it is ready to let me log in</li> <li>login sounds</li> <li>sound effects whenever I do anything, such as open or close windows</li> <li>sound effects whenever the computer wants to tell me something that isn't particularly important, such as new e-mail, IRC or IM messages to me, the networking going up or down, or a hard disk going missing</li> <li>a beep when I reboot or shutdown the computer</li> </ul> <p>I'm sure there are situations when it would be OK for my computer to make noise to alert me. For example, supposed I'm asleep, and a zombie has penetrated my defensive perimeters and is about to chop off the top of my skull so it can devour my brain. In that case, I would be OK with my computer beeping. Once.</p> <p>Some remedies:</p> <ul> <li>With gdm3, edit <code>/etc/gdm3/greeter.gconf-defaults</code> to set <code>/desktop/gnome/sound/event_sounds</code> to <code>false</code></li> <li>Configure GNOME's sound theme to be "No sounds". (It should not be necessary to set "alert sounds" to muted, but it won't hurt either.)</li> <li>Run <code>amixer -q sset Beep off</code> to shut up <code>wall</code> and other such tools. (I made an init.d script to make that happen automatically, and to make sure I don't forget it when I install new machines for myself.)</li> </ul> <p>Now, it's possible that other people might like or need their computer to make sounds. I imagine, for example, that the GDM login-ready beep is to help people with vision problems. I'm all for that. However, I wish it be easier to shut things up in one simple place for those of us who don't need it.</p> <p>Edit: Thanks to <code>NP237</code>, <code>noshadow</code>, <code>lindi-</code>, <code>flightplan</code>, and others on <code>#debian-devel</code> with help on shutting up <code>wall</code>.</p> Linux-tekijä 2008 https://blog.liw.fi/posts/linux-tekija-2008/ https://blog.liw.fi/posts/linux-tekija-2008/ linux planet-debian Mon, 29 Nov 2010 09:18:04 +0000 2010-11-29T09:18:04Z <p>I'm on the jury for the "Linux-tekijä 2008" award. Roughly translated that means "Linux maker 2008". It's an award for a person or organization who has significantly advanced Linux development or improvided the conditions for Linux users in Finland.</p> <p>I'm on the jury as a Debian person, since the Finnish Debian community received an <a href="http://lists.debian.org/debian-project/2006/02/msg00002.html">honorary mention</a> two years ago.</p> <p>The <a href="http://www.flug.fi/linuxtekija/2008/">nomination form</a> is open, so anyone who has any a suggestion, send it in.</p> Manuaalisivujen kirjoittaminen – esitelmä Linux-teemaillassa https://blog.liw.fi/posts/manuaalisivujen-kirjoittaminen-linux-teemailta/ https://blog.liw.fi/posts/manuaalisivujen-kirjoittaminen-linux-teemailta/ in-finnish linux presentation Mon, 29 Nov 2010 09:18:04 +0000 2010-11-29T09:18:04Z <p>Pidin 19.2. esitelmän FLUGin ja muiden järjestämässä Linux-teemaillassa, Helsingin Kumpulassa. Käyttämäni <a href="http://files.liw.fi/2009-02-19-manuaalisivujen-tekeminen-linux-teemailta.pdf">kalvot</a> eivät ole järin hyödyllisiä ilman esitystä, mutta ehkä niistä on iloa jollekulle paikalla olleelle.</p> RAID0 on gytha https://blog.liw.fi/posts/raid0-on-gytha/ https://blog.liw.fi/posts/raid0-on-gytha/ linux mdadm Mon, 29 Nov 2010 09:18:04 +0000 2010-11-29T09:18:04Z <p>I've just more than doubled my desktop's disk I/O speed. Neat, eh?</p> <p>My desktop machine has four identical hard disks. I keep backups of anything I care about, and I run some disk-intensive things from time to time. Thus, I want the disk subsystem to be as fast as possible, and I don't care about using RAID to recover from disk problems.</p> <p>When I initially installed the system, however, I couldn't coax the Ubuntu installer to create a <a href="http://en.wikipedia.org/wiki/RAID0#RAID_0">RAID0</a> for me, so it used plain <a href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29">LVM</a> only. Yesterday I spent a day to re-install the system, and got it done. Not entirely straightforward, though.</p> <p>The alternate installer lets you create RAID systems. However, it fails to install a boot loader if you do that on the entire disks. The final partitioning scheme I ended up with uses LVM for the root and swap partitions, and then RAID0 for a big scratch partition. I also have /boot on a separate partition, to get the boot loader (GRUB or LILO) to work.</p> <p>In other words, every disk has three partitions:</p> <ul> <li>a 10 GiB LVM physical volume</li> <li>a 500 MiB volume</li> <li>the rest as a RAID0 physical volume</li> </ul> <p>The 500 MiB volume on the first disk is used for /boot, and is unused on the three other disks, wasting 1.5 GiB, but that's small enough that I don't care.</p> <p>Was this worth it? I think so. Russell Coker's <a href="http://www.coker.com.au/bonnie++/">bonnie++</a> gives me the following results for the non-striped LVM volume, i.e., essentially for one disk:</p> <pre><code> ------Sequential Output------ --Sequential Input- --Random- -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP 16G 54932 78 58243 14 28037 6 58412 67 61662 6 261.2 0 </code></pre> <p>In comparison, the RAID0 gets the following results:</p> <pre><code> ------Sequential Output------ --Sequential Input- --Random- -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP 16G 68732 95 143030 29 65331 14 76887 97 152345 17 394.6 1 </code></pre> <p>That's a speedup of about 2.5 times. I'm sure it could be better: in theory, a speedup of 4 times would be possible, but that's the theory. I'm going to be satisified with this, for now.</p> Renaming a Linux host https://blog.liw.fi/posts/renaming-a-linux-host/ https://blog.liw.fi/posts/renaming-a-linux-host/ linux note-to-self Mon, 29 Nov 2010 09:18:04 +0000 2010-11-29T09:18:04Z <p>I wanted to set up a virtual machine running Ubuntu jaunty (which is undergoing heavy development right now). In order to avoid having to install one from scratch, I copied an existing virtual machine running intrepid, and upgrading that.</p> <p>Upgrading from release to release (even to one under development) is, of course, one of the things Debian and Ubuntu do very well. The hitch here was that was I wanted to keep the original virtual machine, since I also want to have somewhere to test things on intrepid.</p> <p>In the end I did this:</p> <ul> <li><code>virt-clone --connect=qemu:///system -o achmed -n brutha -f VM/brutha.img</code></li> <li>Change the hostname of the new machine.</li> </ul> <p>I wrote down the steps to rename the host as a <a href="http://liw.fi/rename-host/">checklist</a>. If I find the list if incomplete, I'll to it. (It's a wiki page, so if you find something to add, please do.)</p> <p>(Obviously, those steps probably apply to most Unix based operating systems, but I only have Linux to test them on. Perhaps I should set up a few virtual machines with various BSD flavors, some day.)</p> Screensavers are evil https://blog.liw.fi/posts/screensavers-are-evil/ https://blog.liw.fi/posts/screensavers-are-evil/ gnome linux rant Mon, 29 Nov 2010 09:18:04 +0000 2010-11-29T09:18:04Z <p>A screensaver is, in theory, a program to prevent a static image to burn onto a screen. This was could happen with CRT screens. What would happen is that when the same image is displayed for a long time, it would "burn" into the phosphor.</p> <p>To prevent that, screensavers were invented. They blanked the screen if the computer hasn't been used for a while, and unblanked it when the user pressed a key or moved the mouse.</p> <p>One day someone came up with the idea of putting an animation on the screen instead of just blanking it.</p> <p>Turns out, this is evil. It makes the computer use more power. Screensavers cause pollution without having any benefit than a very minor amusement effect.</p> <p>Also, amusingly, the more a screen is powered on, the shorter it lasts. Thus, screensaver animations actually do the opposite from saving screens.</p> <p>To prevent that, modern desktop environments have controls to specify how long the screensaver animation works before the screen is turned off. That's an unnecessary bit of complexity.</p> <p>If I had my way, screensaver animations would be removed from all operating systems. People running their computers off of solar power could add them, if they wanted, but everyone else would be better off without them.</p> Brother P-touch QL-550 with Ubuntu 9.10 (karmic) https://blog.liw.fi/posts/brother-ql-550/ https://blog.liw.fi/posts/brother-ql-550/ debian linux ubuntu Fri, 13 Nov 2009 13:40:57 +0000 2009-11-13T13:40:57Z <p>I recently set up my Brother P-touch QL-550 label printer to work with CUPS on my laptop, which runs Ubuntu 9.10 (karmic). This required installing <a href="http://www.diku.dk/hjemmesider/ansatte/panic/P-touch/">ptouch-driver</a>, with some patches, and then hand-editing the PPD file that gets created.</p> <p>I made a very crude .deb package to install the ptouch-driver. I have no idea how to package CUPS stuff properly, so I didn't even try. I don't intend to maintain this in Debian or Ubuntu, I just needed it for myself, so I didn't go to much effor, I'm afraid. Perhaps it's useful anyway. I filed a "Request for Package" bug in Debian (<a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=555892">555892</a>) and talked with Till Kamppeter from Ubuntu about this, and he has taken a look at this (see comments in the bug).</p> <p>With my package, the generated PPD has some margins that make it almost impossible to fit anything on the label. The margins are only a few millimeters, but on labels that matters a lot. I fixed this by hand-editing the PPD, Till seems to have fixed in a better way.</p> <p>I hope this is useful to someone. The printer itself is pretty nice, too bad Brother doesn't provide free drivers.</p> Kernel oops message compression https://blog.liw.fi/posts/kernel-oops-compression/ https://blog.liw.fi/posts/kernel-oops-compression/ idea linux Tue, 11 Aug 2009 07:22:52 +0000 2009-08-11T07:22:52Z <p>I recently attended a talk where a kernel hacker told about debugging techniques when the Linux kernel is having problems. One of the things he mentioned was that kernel oops messages can sometimes be so long they won't fit on a screen. When users submit them, e.g. by photographing the screen, they don't show enough information to be useful.</p> <p>It struck me that it might be possible to encode the message in various ways to make them use less space so they don't scroll off the screen. My first idea was a 2D bar graph, but those can be difficult in a text-only situation. A second idea is to use gzip and base64 encoding, and a refinement of that is to use base85 encoding.</p> <p>This has probably been thought of before, but I thought it'd be fun to prototype it anyway. I used a free <a href="http://sourceforge.net/projects/pyascii85/">ascii85 library</a> for Python:</p> <pre><code>#!/usr/bin/python import zlib, bz2, base64, sys, tempfile, os, ascii85 msg = sys.stdin.read() print "msg:", len(msg) compressed = zlib.compress(msg, 9) print "compressed:", len(compressed) fd, compressed_name = tempfile.mkstemp() os.write(fd, compressed) os.close(fd) compressed_f = file(compressed_name) ascii85.encode(compressed_f, sys.stdout) </code></pre> <p>The output looks like this:</p> <pre><code>msg: 1634 compressed: 875 &lt;~GhS.A&gt;Ar7S'Z],0.1WSK(0_bV2p94FTa66f6^JQWJ.4:CK&amp;Xc39T^5bfu^_\Tq&amp;&amp;u&lt;XaD\6 lu::c_'C[5Mge#qt9CE#'^1ebXmM5]cY70)&gt;\-TVY0RhHe#H5XE"-6f[R9^fc!k:qXQdpBILR 6-RZ.C_!]`gG]i0_,]6jbo(CuY*or^o"ci=l"*@htS%n/RF(:Jgj&lt;5p6&amp;:F5]&amp;dboUE&amp;elsfd (Q&gt;r9iZ[&lt;&lt;TZLdD7flXWfQDgJ!O=E[hn,#9sJ0_F*M9!*pLQ#:GL4bWjmeR!dh="[NORpL"BF OgCfThPUJ&gt;0e2C=Obgq4J@,HKB#6Wr!Z+@=_@(ucapa-?HiFl=c"6F,Qo2QK(X'kRhemB#?^r pBRcu?kXCBo9UdEqEaUhnW/r!4.oagXhWh)9Y&gt;RZ?M=[Db_+)Nb88)_KecZ61*?GU=10IDTNZ @h3T&lt;[tqqj4&lt;[3j+[I6!?OXO0qBWQ0&lt;YT-K+]1e.[N,Q?6$4F(pQ7kcUCJ69(R48PNhTQ6LQR &gt;;[?u=6M!-4PRrFlO$PJ_&gt;td@h^!-H"HZk_&gt;Z8a9\I:.%7"s6[U+.X)e]4M\-ARjM!0-D:&gt;%0 eFfc3Fc1&lt;$sYqHgbA#+hOK6k9X1*BWOX^I.!.@D^OAsXk&lt;XOUm9]JB3hYYDPjok,F&amp;KuVOYo5 jUn!'=jNq-Rp8b0dr+]li21&gt;EeIRagC'/t^Y_UQY+,XX9/EmmP;VEaUW0^]7@VM:&gt;=akU:$fB @N%:0J2YqsmA!S\\"W@G`pph9sm23(,kcah7N#Oi3NDUm^]nM8!#ZV&lt;8R#ljg^o/XkT9)5(r\ khNf&lt;p3Dg0*6OunTq%DR]IEL_Yc1L7C%^bPTs@&gt;Rr-QcRu_Kqr#bmu/*cGH&lt;O?:W;@fbN1SiY `R&amp;"a&gt;KcXOi6kW\+ee9JqMiUWW&gt;UPW.UjWGIh/ipoFIX()/L'M$-9&gt;&gt;k4*gN[&lt;-8@B2460k.l p,KdJ7&gt;F,O&lt;%]=$A=5.lEMZ-bl[@Hmt&amp;XFYRkrm]9bjOF2f6ZKNWKW[)b)c:,H4.6h+2CCuDa T@DIM&amp;oI6i'nj&amp;5G9Lqf&lt;F@4K@"0@kZh1P/&gt;[:WP!J_E\T:#c;Y)"?g.\t#.Xt&amp;'IYkT##I2] T~&gt; </code></pre> <p>Gzip seems to compress things to about half the original size, and ascii85 inflates that by about 25%. However, the result is then all mashed up on long lines, so use of vertical space if fairly small. Thus, this might be acceptable, perhaps as an optional feature.</p> <p>Decoding that using OCR from a digital photograph should be possible, and is left as an excercise for the reader, as is an implementation of the encoder that is actually suitable for the kernel. (Read: not in Python.)</p> <p>It might be possible to write a custom compressor: oops messages seem fairly regular in shape, after all.</p> <p>There you are. If this is useful for anyone, at any time, please do use the idea.</p> On mono https://blog.liw.fi/posts/on-mono/ https://blog.liw.fi/posts/on-mono/ linux Wed, 01 Jul 2009 08:47:16 +0000 2009-07-01T08:47:16Z <p>There is a fair bit of controversy on Mono, the free software implementation of Microsoft's .NET stack. See, for example, <a href="http://www.fsf.org/news/dont-depend-on-mono">RMS</a> and <a href="https://lists.ubuntu.com/archives/ubuntu-devel-announce/2009-June/000584.html">Ubuntu position statement</a> for two contradicting opinions.</p> <p>To me, the patent issue is moot. All interesting software violates some patent, I am sure, since the USPTO and EPO conspire to ruin innovation by granting ridiculous patents to megacorporations and patent trolls. Basically, anything and everything can be patented, even if it is patented already.</p> <p>(The reality is better than that, but not in a significant way.)</p> <p>The real problem with Mono is that it implements .NET, and needs to be compatible with .NET. This means it needs to follow what Microsoft does, and cannot innovate freely.</p> <p>Microsoft leads, free software follows. That is not the way to go.</p> <p>I'm personally fine with people writing software using Mono, and with those apps being included in Linux distributions by default. I think it's stupid to do that, but not so stupid it needs to be stopped, as long as only very few important programs are using Mono. What we cannot allow is to make Mono an essential part of the free software experience, with much of the software requiring it.</p> <p>That's why I won't write any software in Mono myself, and why I'm wary of using any such software.</p> Time machine for logging https://blog.liw.fi/posts/time-machine-for-logging/ https://blog.liw.fi/posts/time-machine-for-logging/ idea linux Fri, 22 May 2009 16:51:58 +0000 2009-05-22T16:51:58Z <p>Log files from servers and other programs can be an invaluable debugging tool. Really good and detailed logging can make it very easy to pin-point the trigger for a bug.</p> <p>Unless there is a bug, log files are a useless waste of computing resources. A colleague told me that an app he uses produces 20+ megabytes of log files <strong>per day</strong> in normal use. That's insane.</p> <p>What is needed is a way to have log files have happened when a bug manifests itself, but otherwise not.</p> <p>I should perhaps become a quantum physicist to solve this problem properly, but meanwhile it might be enough to have really fast rotation of debug logs. Say, once an hour.</p> Libc is broken. What now? https://blog.liw.fi/posts/broken-libc-what-now/ https://blog.liw.fi/posts/broken-libc-what-now/ linux planet-debian Tue, 05 May 2009 18:10:18 +0000 2022-08-22T06:07:24Z <p>Today I woke up and read the news that the Ubuntu hardy C library (libc6) had <a href="https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/201673">been broken</a>. The bug is so bad that the system no longer boots. Tempers are running high. What to do?</p> <p>There is a discussion thread on the ubuntu-devel mailing list, where someone flames the person who did the broken upload, and someone else flames the first flamer, and then other people flame the second flamer. It's a regular flamefest. It's not the most constructive reaction from any of the involved people (which is why I'm not linking to it).</p> <p>This is not Ubuntu specific in any way. Any system that is being developed is going to have bugs of various sorts, some really bad like this. When that happens, people are going to be annoyed.</p> <p>I'd like to offer the following as lessons to be learned from these kinds of episodes:</p> <ul> <li><p>Developers must have the <strong>freedom to make mistakes</strong> without retaliation. Flaming counts as retaliation. Fear makes people less productive.</p></li> <li><p>People who suffer from the bug need to <strong>vent</strong>. Preferably they will do this in private rather than in public, and without aiming it at specific people, but the need is real, and suppressing it won't improve things. Back in the old days, alt.flame worked pretty well for Usenet, perhaps that's a model that could still apply.</p></li> <li><p>Many problems can be found via <strong>automatic testing</strong>. Perhaps testing all uploads with, say, piuparts, before they are installed into the package archive could catch some future problems. (Disclaimer: piuparts can't currently test libc or other essential packages.)</p></li> <li><p>Even with rigorous testing, there will be catastrophic bugs. Linux could benefit from a <strong>way to recover</strong> from them that is easier than fiddling with installation media and tweaking stuff manually. There's various approaches that could apply, perhaps we should pick one and push it. "We" being not just Ubuntu, but also Debian and other distributions.</p></li> </ul>