123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <!DOCTYPE html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><meta name="keywords" content="GNU, Emacs, Libre Software, Hurd, Guile, Guix" /><meta name="description" content="GNUcode.me is a website focusing on libre software projects, especially the GNU project." /><link type="application/atom+xml" rel="alternate" title="GNUcode.me -- Feed" href="/feed.xml" /><a rel="me" href="https://fosstodon.org/@thegnuguy"></a><link type="text/css" href="css/footer.min.css" rel="stylesheet"></link><link type="text/css" href="css/header.min.css" rel="stylesheet"></link><link type="text/css" href="css/main.min.css" rel="stylesheet"></link><title>The Hurd on Bare Metal — GNUcode.me</title></head><body><header><nav><ul><li><a href="index.html">GNUcode.me</a></li><li><a href="services.html">Services</a></li><li><a href="about.html">About</a></li><li><a href="business-ideas.html">Business-ideas</a></li></ul></nav></header><h1>The Hurd on Bare Metal</h1><main><section class="basic-section-padding"><article><h3>by Joshua Branson — August 13, 2023</h3><div><p>This blog post was written on a Debian GNU/Hurd system on a IBM ThinkPad T43
- with 1.5 GB of RAM. (It was edited on Guix System (running linux)). Apparently
- running Emacs on the hurd in the console is actually quite stable. This post
- will describe my attempt to make this T43 be my daily laptop. Let’s see
- how far I can get with that eh?</p><p>tl;dr Debian GNU/Hurd is shockingly stable. If you are an emacs wiz,
- then you will feel right at home.</p><p>The first thing to notice after you login to the Hurd is that you can
- easily switch virtual consoles via <code>Alt-<right-arrow></code>. It is
- actually pretty awesome that you can do this. I know literally every
- other OS has this, but it is cool to have Emacs open in one console,
- and have another program running on another console; switching
- between them feels beautiful.</p><p>Another thing to notice is that <code>mount</code> does not work. Let's explore that shall
- we?</p><pre><code>cat /etc/mtab | awk '{ print $1 " " $2 " " $3 }'
- /dev/hd0s1 / ext2fs
- none /run /hurd/tmpfs
- none /run/lock /hurd/tmpfs
- /dev/hd0s6 /home /hurd/ext2fs
- proc /proc /hurd/procfs</code></pre><p>Actually <code>/etc/mtab</code> is a symlink to <code>/proc/mounts</code>.</p><pre><code>ls -lha /etc/mtab
- lrwxr-xr-x 1 root root 12 Apr 10 12:14 /etc/mtab -> /proc/mounts</code></pre><p>It looks like the Hurd labels MBR partitions slightly differently from Linux. It
- appears that the Hurd uses <code>/dev/hd0s1</code>, <code>dev/hd0s2</code>, and so on.</p><pre><code>echo $pw | sudo -S fdisk -l /dev/hd0
- Disk /dev/hd0: 37.26 GiB, 40007761920 bytes, 78140160 sectors
- Units: sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 512 bytes
- Disklabel type: dos
- Disk identifier: 0x1ab32a1b
- Device Boot Start End Sectors Size Id Type
- /dev/hd0s1 2048 26681343 26679296 12.7G 83 Linux
- /dev/hd0s2 26683390 78139391 51456002 24.5G 5 Extended
- /dev/hd0s5 26683392 28682239 1998848 976M 82 Linux swap / Solaris
- /dev/hd0s6 28684288 78139391 49455104 23.6G 83 Linux</code></pre><p>It looks like a good place to start learning how to use the Hurd is
- via <code>https://www.debian.org/ports/hurd/hurd-install</code>.</p><p>So the file that describes my network interfaces is here:</p><pre><code>cat /etc/network/interfaces
- # This file describes the network interfaces available on your system
- # and how to activate them. For more information, see interfaces(5).
- source /etc/network/interfaces.d/*
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The primary network interface
- auto /dev/eth0
- iface /dev/eth0 inet dhcp</code></pre><p>So it looks like i should definitely read <code>man 5 interfaces</code> at some
- point. And the Debian Hurd guide mentions that I should add name
- servers to my /etc/resolv.conf file. I am not certain why it says
- that I should do that though, but I went ahead and added OpenDNS’ name
- servers.</p><pre><code>cat /etc/resolv.conf
- nameserver 172.16.112.1
- cat /etc/resolv.conf
- nameserver 172.16.112.1
- nameserver 208.67.222.222
- nameserver 208.67.220.220</code></pre><p>Ok, so it seems like <code>pfinit</code> is still the default GNU Hurd <code>TPC/IP</code>
- translator, which is based on an old Linux TCP/IP driver (<code>lwip</code> or
- <code>rumpkernel</code> may one day replace it). Apparently my internet
- connectivity can be found by quering <code>/servers/socket/2</code> (for IPv4)
- and <code>/servers/socket/26</code> (for IPv6).</p><pre><code># fsysopts /servers/socket/2</code></pre><p>If you run the above command you will see that the ethernet device
- that the Hurd uses is <code>/dev/eth0</code>.</p><p>The Hurd has a stateless (stateful is better) ethernet filter. For example, here
- is how to disable ssh access:</p><pre><code># settrans -c /dev/eth0f /hurd/eth-filter \
- -i /dev/eth0 -r "not port 22"</code></pre><p>I could then, tell the pfinit translator to use <code>/dev/eth0f</code> instead
- of <code>/dev/eth0</code> via (I think this how you would do it):</p><pre><code># fsysopts /server/socket/2 --interface=/dev/eth0f</code></pre><p>This is course is not persistant across reboots. I would probably
- need to replace <code>/dev/eth0</code> in <code>/etc/network/interfaces</code> with
- <code>/dev/eth0f</code>.</p><p>The Hurd lets you mount cd drives as a regular user. I should be able
- to look at the files in my CD drive via:</p><pre><code>cd /dev
- # ./MAKEDEV cd0
- # settrans /media/cdrom0 /hurd/is09660fs /dev/cd0
- $ cd /media/cdrom0</code></pre><p>Apparently the Hurd does have a network filesystem translator
- (<code>/hurd/nfs</code>), but I believe that that translator only supports
- NFSv2. So it may not be as performanent as one might want or support
- the latest NSF features.</p><p>Since I installed the stable Hurd release from 2021, the guide
- recommends that if I want a stable environment, then I can just
- configure apt to use the apt sources from 2021. That should let me
- have a fairly stable Hurd distro. So let’s try that.</p><pre><code>cat /etc/apt/apt.conf.d/99ignore-valid-until
- Acquire::Check-Valid-Until "false";
- cat /etc/apt/sources.list
- deb [trusted=yes] https://snapshot.debian.org/archive/debian-ports/20210812T100000Z sid main
- deb [trusted=yes] https://snapshot.debian.org/archive/debian-ports/20210812T100000Z unreleased main
- deb-src [trusted=yes check-valid-until=no] https://snapshot.debian.org/archive/debian/20210812T100000Z sid main</code></pre><p>This mostly worked, but apt gave a warning about the debian gpg key
- had expired.</p><p>Well let’s try to upgrade anyway.</p><pre><code># apt update && apt upgrade</code></pre><p>That seemed to work.</p><pre><code># apt install debian-ports-archive-keyring
- # apt update
- # apt upgrade
- # apt install git git-email
- $ git config --global user.name "Joshua Branson"
- $ git config --global user.email "jbranso@dismail.de"
- $ cd; git clone https://notabug.org/jbranso/prog</code></pre><p>Now I suppose that it is time to follow <a href="https://drewdevault.com/2019/12/30/dotfiles.html">Drew Devault’s guide</a> on how to
- manage your home directory’s configuration files as a git repository.</p><p>I should also read the <a href="https://www.debian.org/ports/hurd/hurd-doc-translator">hurd-doc-translator</a> webpage.</p><p>Apparently, the Hurd’s translators transform data into different data.
- The usual case, is that a translator translates bits of the filesystem
- into different data, and what is awesome is that translators run in
- userspace. Most of the time translators will need to get data from
- hardware, and they will request the kernel to help them get this data.
- There are some exceptions: <code>/dev/zero</code> does not need hardware data, so
- a read from <code>dev/zero</code> is entirely run in userspace.</p><p>There are two kinds of translators: active and passive. An active
- translator is currently running. You can change its settings or kill
- it via the <code>settrans -a</code> command. The <code>-a</code> refers to the <strong>active</strong>
- translator. So <code>settrans -a file.txt</code> will try to kill the userspace
- translator process. If you start a translator via the <code>-a</code> option,
- then the translator is not persistant accross reboot. For that reason,
- most of the time you do not want the <code>-a</code> option, which is what
- settrans by default does.</p><p>If you are ever curious to know if a filesystem node has an attached translator,
- then you can find out via this command:<code>showtrans NODE</code>. It will tell you what
- passive translators are set at a filesystem node.</p><p>Let's take a walk through some basic Hurd translators.</p><pre><code>settrans [OPTIONS...] NODE [TRANSLATOR ARGS...]</code></pre><p>For example, I can have a text file like so:</p><pre><code>cat ~/Documents/hello.txt
- boring text document.</code></pre><p>Now let’s set the <code>hello</code> translator on that filesystem node.</p><pre><code>settrans -a ~/Documents/hello.txt /hurd/hello
- cat ~/Documents/hello.txt
- Hello, world!</code></pre><p>Now let’s see that the file system options are for the <code>/hurd/hello</code>
- translator:</p><pre><code>fsysopts ~/Documents/hello.txt
- /hurd/hello --contents='Hello, world!
- '</code></pre><p>I can modify the <code>contents</code> of the hello translator via:</p><pre><code>fsysopts ~/Documents/hello.txt --contents="Hello Joshua
- "
- cat ~/Documents/hello.txt
- Hello Joshua</code></pre><p>Notice that we changed the options for that translator without having
- to restart it with normal user privledges.</p><p>Now let’s make the hello translator go away:</p><pre><code>settrans -a ~/Documents/hello.txt
- cat ~/Documents/hello.txt
- boring text document.</code></pre><p>Now let’s try to stack these translators eh?</p><pre><code>settrans gnucode.me /hurd/httpfs http://gnucode.me
- ls gnucode.me/installing-wordpress.html
- gnucode.me/installing-wordpress.html
- settrans -c xml /hurd/xmfls ~/gnucode.me/feed.xml
- cd
- ls</code></pre><p>Here the ls command apparently hanged. <code>C-c</code> ended said hanging, but
- the Hurd locked up on me. I actually saw an error message that said
- something like “kbd queue full.” And then my keyboard become
- unresponsive. After a few hours, I pressed “Ctrl-Alt-Del,” and that
- saved my bacon. That killed the hurd console, and it let me switch to
- a virtual console. That enabled me to shut down the hurd gracefully.
- BUT…What went wrong? Why did <code>ls</code> hang?</p><p>Well here is a clue:</p><pre><code>ls ~/gnucode.me/feed.xml
- ls: cannot access feed.xml': No such file or directory</code></pre><p>Well, httpfs does not expose feed.xml. It does not recognize that as part of the
- gnucode.me website. <code>httpfs</code> only lists webpages that are listed on
- <code>index.html</code>. So <code>~/gnucode.me/feed.xml</code> does not translate to the local the
- filesystem. If I had to guess, I would say that xmlfs tries to run but does not
- check if its underlying file exists.</p><p>I should also mention that I am using a very minimal <code>.emacs.d/init.el</code>. It is
- possible to get doom emacs to run on the Hurd, but the last time that I tried
- it, emacs locked up on me. I was forced to do a hard shutdown, which resulted in
- filesystem corruption and I had to re-install. So for now, I am using a very
- simple and minimal emacs. You can actually install some emacs packages via apt.
- Just search for <code>apt search magit</code> to get you started.</p><p>I would like to try running i3 on the hurd at some point, because that
- is a very light-weight window manager, but I have not yet tried
- setting up X to run. Partly because I only have 1.5GB of RAM, and I
- have heard that X tends to lock up or be really slow on the Hurd.</p><p>Surprizingly the Hurd only uses about <code>161MB</code> of RAM, when I run emacs
- on the console.</p><ul><li><p>What I have done so far</p><ul><li><p>Emacs
- I would love to remap control and caps, but I am not certain how
- to do that in the console.</p></li><li><p>Irc (via Erc)</p></li><li><p>Gnus my email client
- But I still need to set up the ability to send email.</p></li></ul></li></ul><p>Packages to install (glibc-doc-reference) requires enabling non-free
- packages:</p><pre><code># apt install gnupg emacs surfraw msmtp glibc-doc glibc-doc-reference</code></pre><p>Trying to create/open a file in emacs that ends in *.gpg crashes
- Emacs. I have no idea why.</p><p>Currently, msmtp cannot securely send email, because it cannot decrypt
- the encrypted file that has my password.</p><p>My Hurd machine also has my “jbranso@dismail.de” gpg key. I was able
- to import the data via an ssh session.</p><p>I was actually surprized that the debian wiki mentioned this command:
- <code>service ssh restart</code> and not a systemd specific command, but
- apparently <code>man service</code> is the manual that I want to read.
- Apparently ssh is already running. I verified this with:</p><pre><code>echo $pw1 | sudo -S service --status-all | grep ssh
- [ + ] ssh</code></pre><p>I really should set up Sergey's terrible MDNS responder, so that I can ssh in
- the Hurd more easily, but that is a task that I will set for a later date. I
- should also possibly update my hard drive to a larger drive. I think the current
- one has 100GB or so. Maybe less. And it might not be a bad idea to set up an SSD
- or DVD drive via the CD-ROM bay and try the rumpdisk out. I would also like to
- be able to publish my blog from the Hurd too, but I have been unsuccessful to
- install Haunt on my Hurd box. I should also try to install Guix on it, but I am
- concerned about hard drive space at the moment.</p><p>Anyway, you can take a look at my <a href="https://notabug.org/jbranso/hurd-home">hurd
- home</a> git directory if you like. Safe
- travels!</p></div></article></section></main><footer><p>© 2020 Joshua Branson. The text on this site is free culture under the Creative Commons Attribution Share-Alike 4.0 International license.</p><p>This website is build with Haunt, a static site generator written in Guile Scheme. Source code is <a href="https://notabug.org/jbranso/gnucode.me">available.</a></p><p>The color theme of this website is based off of the famous <a href="#3f3f3f" target="_blank">zenburn</a> theme.</p></footer></body>
|