Thursday, February 6, 2020

Setting up a Samba server on NetBSD

Let’s make the files on your NetBSD machine browseable via Samba!

There’s already a HOWTO article on the NetBSD wiki but it’s super old and the instructions don’t apply anymore. Here’s a more up-to-date tutorial. I just confirmed these instructions work on NetBSD/amd64 9.0 RC 2, which is… pretty dang recent.

First, install Samba. I suppose you could use pkgin but I built it with pkgsrc instead.

$ cd /usr/pkgsrc/net/samba
$ make && make install clean clean-depends

Now we need to enable a bunch of daemons in /etc/rc.conf.


Now in order to be able to enable those services, we need to add them to /etc/rc.d.

$ sudo ln -sf /usr/pkg/share/examples/rc.d/smbd /etc/rc.d/smbd
$ sudo ln -sf /usr/pkg/share/examples/rc.d/nmbd /etc/rc.d/nmbd
$ sudo ln -sf /usr/pkg/share/examples/rc.d/winbindd /etc/rc.d/winbindd
$ sudo ln -sf /usr/pkg/share/examples/rc.d/samba /etc/rc.d/samba

Before we start the server, let’s very quickly tune the Samba configuration file, /usr/pkg/etc/samba/smb.conf. There’s a pre-defined section called [homes] which we can edit. I made mine browseable and read-only.

   comment = Home Directories
   browseable = yes
   writable = no

There are several daemons involved, but in order to actually get everything running, you only need to start the ‘samba’ service.

$ sudo service samba start

A Samba server can maintain its own set of credentials, which can be different from your ordinary user credentials. If you like, you can even create a dedicated ‘samba’ user and limit Samba access to only that user (look up the ‘valid users’ config option). But at a minimum, let’s set up a username/password.

$ sudo smbpasswd -a -U <username>

The smbpasswd program will invite you to provide a password for this new Samba user.

And that’s it! In my experience, you don’t need to restart the samba service in order for the new credentials to be recognized by clients.

I confirmed stuff was set up OK because my MacBook could connect to it! In the Finder, you can visit “Go > Connect to Server…” (or hit Command-K) and then type in the address of the NetBSD machine, with the smb:// protocol.

My initial (and very simple) configuration clearly isn’t optimized. Both of these options seem to be the same. I’ll deal with that later.

And there we go! I can browse the files just fine in the Finder. Of course, the real test is seeing if you can access the files from a Windows machine. Let me know if that works out for you!

Sunday, November 17, 2019

RubyData - Ruby for Data Science

This is kinda cool. We're so used to seeing Python and Julia being used in technical and scientific computing, but my preferred scripting language Ruby has made a little bit of a splash in this area, too. is a little resource which shows us where to look in case we want Ruby interfaces to scientific computing needs. Good to keep in our back pocket.

Sunday, August 18, 2019

Experimenting with streaming setups on NetBSD

Ever since OBS was successfully ported to NetBSD, I’ve been trying it out, seeing what works and what doesn’t. I’ve only just gotten started, and there’ll definitely be a lot of tweaking going forward.

Capturing a specific application’s windows seems to work okay. Capturing an entire display works, too. I actually haven’t tried streaming to Twitch or YouTube yet, but in a previous experiment a few weeks ago, I was able to run a FFmpeg command line and that could stream to Twitch mostly OK.

My laptop combined with my external monitor allows me to have a dual-monitor setup wherein the smaller laptop screen can be my “broadcasting station” while the bigger screen is where all the action takes place. I can make OBS visible on all Xfce workspaces, but keep it tucked away on that display only. Altogether, the setup should let me use the big screen for the fun stuff but I can still monitor everything in the small screen.

Saturday, June 1, 2019

dressupgeekout is on Mastodon!

A few things:

  1. I’m not dead.
  2. I still do use BSD sometimes.
  3. I just got myself an account on the Mastodon instance. I’m @dressupgeekout!

Sunday, December 2, 2018

Using the installers for Linux, on NetBSD prefers that you use their GOG Galaxy desktop app to download, install and manage all of your GOG games. But customers always have the option to install the game on their own terms, with a platform-specific installer.

GOG offers these installers for Mac, Windows and/or Linux, depending on which platforms the game is available for. The installers truly are platform-specific:

  • macOS games are distributed in a standard .pkg
  • Windows games are distributed in a setup wizard .exe
  • Linux games are distributed in a goofy shell archive

Of course, none of those are NetBSD. So, if I wanted to even attempt to play a game distributed by on NetBSD, which one should I pick? The obvious choice is the Linux installer, since Linux is the most similar to NetBSD, right? Au contraire! In practice, I found that it is easier to download the Windows installer.

Here’s what I mean. For example, I ported the open source version of Aquaria to pkgsrc, but that package is only the game’s engine, not the multimedia data. The multimedia data is still copyrighted. Therefore, you need to get it from somewhere else. GOG is usually a good choice, because they distribute their games without DRM. And as mentioned earlier, picking the Linux installer seemed like a natural choice.

But I quickly discovered that the Linux installer, that goofy shell archive, is not portable.

charlotte@sakuracity:~/games$ sh ./
Verifying archive integrity... All good.
Uncompressing Pyre (     0% gzip: unknown compression format
Extraction failed.
 100%  Signal caught, cleaning up

Ah, maybe you just need a different shell…

charlotte@sakuracity:~/games$ bash ./ 
Verifying archive integrity... All good.
Uncompressing Pyre (     0% gzip: unknown compression format
Extraction failed.
 100%  Signal caught, cleaning up

Lol no? OK fine whatever.

That’s when I discovered that GOG’s Windows installers are actually easier to deal with on NetBSD, with the help of the archivers/innoextract package. It really does Just Work. So, I’ve been using innoextract on GOG’s .exe files almost exclusively in order to obtain multimedia data for all sorts of games that have open source reimplementations of their game engines: Jazz Jackrabbit, Jade Empire, Grim Fandango, and more.

That was my only way forward, until I remembered that NetBSD has a Linux compatibility layer!

You just have to install one of the Linux compat packages. I’m on a 64-bit machine and I want the newest stuff, so I installed the emulators/suse_base package from pkgsrc.

When that package is done installing, it writes you a big fat note:

$NetBSD: MESSAGE.NetBSD,v 1.1 2013/12/05 11:42:14 obache Exp $

Do not forget to include COMPAT_LINUX in your kernel configuration file.
Linux binaries require this option in order to work.

Most Linux binaries also require procfs to be mounted with -o linux.
This can be automated by adding the following to your /etc/fstab:

procfs /emul/linux/proc procfs ro,linux

Some Linux binaries also require tmpfs to be mounted on /dev/shm.
This can be automated by adding the following to your /etc/fstab:

tmpfs /emul/linux/dev/shm tmpfs rw,-m1777


I’m not positive if those extra entries in fstab(5) are 100% necessary for the task at hand (run’s game installers for Linux), but it certainly doesn’t hurt. I have them enabled.

Alright, it’s go time!

charlotte@sakuracity:~/games$ bash 
Verifying archive integrity... All good.
Uncompressing Pyre (     0% gzip: unknown compression format
Extraction failed.
 100%  Signal caught, cleaning up

Oh, right, derp, I should put the Linux binaries in the front of my PATH.

charlotte@sakuracity:~/games$ LINUX=/usr/pkg/emul/linux

charlotte@sakuracity:~/games$ PATH=${LINUX}/bin:${LINUX}/sbin:${LINUX}/usr/bin:${LINUX}/usr/sbin:${PATH}
bash ./ 
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Verifying archive integrity... All good.
Uncompressing Pyre (  100%  
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Collecting info for this system...
Operating system: linux
CPU Arch: x86_64
trying mojosetup in bin/linux/x86_64
Error opening terminal: screen.
Error: Couldn't run mojosetup

It can’t run “mojosetup” (whatever that is) because it doesn’t like my $TERM? Also, what’s that deal about the locale, doesn’t know what en_US.UTF-8 is?

At this point I decided to use the simplest setup I could envision, and it worked! That means a locale of “C” and a TERM of “vt100”.

charlotte@sakuracity:~/games$ \
  PATH=${LINUX}/bin:${LINUX}/sbin:${LINUX}/usr/bin:${LINUX}/usr/sbin:${PATH} \
  TERM=vt100 \
  LC_ALL=C \
  bash ./ 

It’s this insane little setup wizard which has interesting curses support (??!!)

┌───────────────────────────────── Pyre ─────────────────────────────────┐
│                                                                        │
│ Pyre                                                                   │
│ Welcome to installer!                                          │
│                                                                        │
│ For technical support for this game, please visit our Support page at: │
│                                        │
│                          < Cancel > < Next >                           │

You use the arrow keys to highlight the option you want and hit SPACE and/or ENTER to select it.

┌──────────────────────────────────────────────────────────────── EULA ────────────────────────────────────────────────────────────────┐
│                                                                                                                                      │
│ End-User License Agreement                                                                                                   │
│ ========================================                                                                                             │
│                                                                                                                                      │
│ Your use of this product/service is subject to the GOG User Agreement. Copy and paste this link to your browser to check it out:     │
│                                                                               │
│                                                                                                                                      │
│                                                                                                                                      │
│ MojoSetup License Terms                                                                                                              │
│ ========================================                                                                                             │
│                                                                                                                                      │
│ Copyright (c) 2006-2010 Ryan C. Gordon and others.                                                                                   │
│                                                                                                                                      │
│ This software is provided 'as-is', without any express or implied warranty.                                                          │
│ In no event will the authors be held liable for any damages arising from                                                             │
│ the use of this software.                                                                                                            │
│                                                                                                                                      │
│ Permission is granted to anyone to use this software for any purpose,                                                                │
│ including commercial applications, and to alter it and redistribute it                                                               │
│ freely, subject to the following restrictions:                                                                                       │
│                                                                                                                                      │
│ 1. The origin of this software must not be misrepresented; you must not                                                              │
│ claim that you wrote the original software. If you use this software in a                                                            │
│ product, an acknowledgment in the product documentation would be                                                                     │
│ appreciated but is not required.                                                                                                     │
│                                                                                                                                      │
│ 2. Altered source versions must be plainly marked as such, and must not be                                                           │
│ misrepresented as being the original software.                                                                                       │
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────(  3%)──│
│                                                     < Cancel > < Back > < Next >                                                     │

Wow, incredible. I didn’t know you could do this in a shell archive?

The installer asks you if you’d like to install the game data to somewhere other than the default ~/GOG Games. I just left it at the default.

At a certain point, you’re invited to create a desktop shortcut and a “menu item” (most be some Ubuntu thing) and, well, I don’t know what happens with those options enabled on NetBSD, but I turned them off for safety.

┌──────────────── Options ─────────────────┐
│ [ ] Create a desktop shortcut            │
│ [ ] Create a menu item                   │
│ < Cancel > < Toggle > < Back > < Next >  │

And then the fun part, when the game is actually installed!

┌ Installing ─┐
│ Pyre        │
│     12%     │
│  Music...   │
│             │
│ < Cancel >  │

And sure enough, the game is installed in the place it said it would!

charlotte@sakuracity:~/GOG Games/Pyre$ ls -F
docs/                   gameinfo                support/
game/         *     *

I suspect that the uninstall script there would require Linux compatibility, too.

Now, actually PLAYING the games on NetBSD is a separate matter entirely. The game I’ve got here, though, my current obsession Pyre, is built with MonoGame and therefore could theoretically work on NetBSD, too, with the help of a library called FNA and a script for OpenBSD called fnaify. I do hope to create a pkgsrc package for FNA and port the fnaify script to NetBSD at some point.


So, lol, haha, it turns out that if you install the meta-pkgs/suse131 package, then we get a hold of the Linux version of glib2, which enables the GOG installer to spit out a GRAPHICAL SETUP WIZARD ON NETBSD

Sunday, November 11, 2018

Custom console fonts with wscons(4)

A very long time ago, I made a VGA or “console” font out of Leah Neukirchen’s font called “sq”. I even wrote a simple script which helped me do the conversion. The whole point of that exercise was to turn the “sq” font into a font for the console on my old NetBSD machine. I was successful all those years ago. But I couldn’t remember how I did it. So let me quickly show you what I had to do to get the font working on my current NetBSD box.

You could run several commands on the command line in order to achieve this effect, but it’s way simpler to simply edit wscons.conf(5) and restart the wscons system service.

First, towards the top of wscons.conf, we declare the existence of “sq” and the boldfaced version, “sqb”. It also ensures that the fonts will be loaded.

font  sq   - - iso /home/charlotte/fonts/sq.816
font  sqb  - - iso /home/charlotte/fonts/sqb.816

Then, towards the bottom of wscons.conf, we set the “font” variable for each tty to be “sq”.

setvar  ttyE0 font    sq
setvar  ttyE1 font    sq
setvar  ttyE2 font    sq
setvar  ttyE3 font    sq  

Then, we simply restart the wscons system service, and we’re all done!

charlotte@sakuracity:~$ sudo service wscons restart
wsconscfg: screen 1 is already configured
wsconscfg: screen 2 is already configured
wsconscfg: screen 3 is already configured
wsconscfg: screen 4 is already configured
Keyboard encoding -> us
ttyE0: font -> "sq"
ttyE1: font -> "sq"
ttyE2: font -> "sq"
ttyE3: font -> "sq"

Saturday, October 27, 2018

Attaching a Bluetooth keyboard to a NetBSD machine

I am FINALLY able to use my Apple Bluetooth keyboard with NetBSD! I am writing this blog post right now using it. The NetBSD Guide helped me a LOT with this, but I believe it requires a little bit of updating… so in the meantime, let me show you how I did it.

Overall strategy

  • Enable the Bluetooth system service.
  • Figure out what your machine’s Bluetooth device node is called.
  • Put your keyboard into discover mode.
  • Figure out what your keyboard’s Bluetooth address is.
  • Register a temporary PIN to be used when pairing the keyboard.
  • Type the PIN in with the keyboard.
  • Attach the device.

In detail:

Enable the Bluetooth system service.

This is simply adding “bluetooth=YES” in your rc.conf and then turning it on with sudo service bluetooth start.

Figure out what your machine’s Bluetooth device node is called.

That’s just a matter of dmesg. We are interested in finding out where a Bluetooth remote device hub (bthub(4)) has set itself up:

$ dmesg | grep bthub
[    15.588860] bthub0 at ubt0 local-bdaddr 48:45:20:52:f6:60

ubt0 is where our Bluetooth remote device hub is located. That’s the part we’re interested in. We’ll make a note of it.

Put your keyboard into discover mode.

In the case of my keyboard from Apple, that means pressing and holding the power button until the status light blinks. When that happens, the keyboard will be discoverable when my laptop’s Bluetooth device tries to discover it (and anything else in the vicinity).

Figure out what your keyboard’s Bluetooth address is.

Apparently, the technical term for “discover all the discoverables” is actually an “inquiry.”

$ btconfig ubt0 inquiry
Device Discovery from device: ubt0 ... 3 responses
  1: bdaddr e4:8b:7f:2e:bb:60
   : name "Apple Keyboard"
   : class [0x002540] Peripheral Keyboard <Limited Discoverable>
   : page scan rep mode 0x01
   : clock offset 31094
   : rssi 0

  2: bdaddr b0:67:2f:00:54:ff
   : name "Audio Device"
   : class [0x080428] HiFi Audio <Capturing>
   : page scan rep mode 0x01
   : clock offset 23232
   : rssi 0

  3: bdaddr 60:6b:bd:c2:89:de
   : name "DTVBluetooth"
   : class [0x08043c] Video Display and Loudspeaker <Capturing>
   : page scan rep mode 0x01
   : clock offset 24943
   : rssi 0

I’m interested in the first device, the keyboard with the BDADDR “e4:8b:7f:2e:bb:60”. At this stage, we can register an alias or “nickname” for this device, so that we don’t have remember the address:

 $ sudo echo e4:8b:7f:2e:bb:60 CharlotteAppleKeyboard >> /etc/bluetooth/hosts

Register a temporary PIN to be used when pairing the keyboard.

The btpin command sets up a number to be typed in. I typed the number on my Bluetooth keyboard and pressed ENTER.

$ btpin -d ubt0 -a CharlotteAppleKeyboard -r -P
PIN: (numbers)
Pairing.. done

Pairing is done. Nice!

Attach the device.

The btdevctl -A command will do that for us.

$ sudo btdevctl -d ubt0 -a CharlotteAppleKeyboard -s HID -A

You can confirm that the device has attached as a keyboard (rather than something else) by inspecting /var/log/messages or dmesg. This is the third keyboard attached to my laptop (my laptop’s own keyboard and a USB keyboard were already attached). So the fact that it’s wskbd2 makes sense:

Oct 27 10:26:53 sakuracity /netbsd: [ 510454.1260370] btkbd0 at bthidev0 reportid 1
Oct 27 10:26:53 sakuracity /netbsd: [ 510454.1260370] wskbd2 at btkbd0 mux 1
Oct 27 10:26:53 sakuracity /netbsd: [ 510454.1260370] wskbd2: connecting to wsdisplay0

At this point you can try typing! That’s what I’m doing right now!

Unfortunately, there are a few shortcomings with this keyboard. For example, The media keys don’t work. Volume up, volume down, you name it. Page up and page down, even. All of these nonworking keys are “function” keys (not F1-F12, but, like, “extended” functionality) and none of them work because every time you press the Fn key, this happens:

[ 512317.5222648] bthidev0: autoconfiguration error: report id 17, len = 1 ignored

Not sure what that’s all about, but I’m willing to dig deeper into it.


So, the instructions here are NOT exactly what is detailed in the NetBSD Guide. I (or someone) should fix that.

Also, I’ve been inspired to write a tool or two which makes this process A LOT simpler. I feel like this should be a task that requires 1 command rather than 3 or 4. I also believe it would be useful to automate maintaining /etc/bluetooth/hosts somehow.