May 1st, 2020

Hard Stare

Not one but 𝘁𝘄𝗼 complete, working, & 𝙪𝙨𝙚𝙛𝙪𝙡 Raspberry Pi projects!

I have several RasPis lying around the place. I sold my π2 when I got a π3, but then that languished largely unused for several years, after the fun interlude of getting it running RiscOS in an old ZX Spectrum case.

Then I bought myself a π3+ in a passive-cooling heatsink/case for Yule 2018, which did get used for some testing at work, and since then, has also been gathering dust. I am sure this is the fate of many a π.

The sad thing about the RasPi is that it's a bit underpowered. Not unreasonable for a £30 computer. The π1 was a single rather gutless ARM6 core. The π2 at least had 4 cores, but still weedy ones. The π3 had faster cores and wifi, but all still only have 1GB of non-upgradable RAM. They're not really up to running a full Linux desktop. What's worse, the Ethernet and wifi are USB devices, sharing the single USB2 bus with any external storage – badly throttling the bandwidth for server stuff. The π3+ is a bit less gutless but all the other limitations apply – and it needs more power and some form of cooling.

But then a chap on FesseBouc offered an official π touchscreen, used and a bit cheaper than new. That gave me an idea. I listen to a lot of BBC 6music – I am right now, in fact – but it needs a computer. Czech radio seems to mainly play a lot of bland pop which isn't my thing, and of course I can't understand a useful amount of Czech yet. It's at about the level of my Swedish in 1993 or so: if I listen intently and concentrate very hard, I may be able to work out the subject being discussed, but not follow the discussion.

But I don't want to leave a laptop on 24×7 and I definitely don't want a big computer with a separate screen, keyboard and mouse doing it. What I want is something the size of a radio but which can connect to wifi and stream music to simple old-fashioned wired speakers, without listening to me. I most definitely do not want a spy basestation for a dot-com listening to my home, thank you.
So I bought the touchscreen, connected it to my old π3, powered them both off a couple of old phone chargers, bunged in a spare µSD card, and started playing with software. I know where I am with software.

First I tried OSMC. It worked, detected and used the touchscreen, and could connect to my wifi... but it doesn't directly support streaming audio, as far as I can tell, and I could not work out how to install add-ins, nor how to update the underlying Linux.

I had a look at LibreElec but it looked very similar. While I don't really want the bloat of an entire general-purpose Linux distro, I just want this to work, and I had 8GB to play with, which is plenty.

So next I tried XBian. This is a cut-down Debian, running on Btrfs, which boots straight to Kodi. Kodi used to be called XBox Media Centre, and that's where I first met it – I softmodded an old original black XBox that my friend Dop gave me and put XBMC on it. It streamed movies off my server and played DVDs through my TV set, which is all I needed.

XBian felt a lot more familiar. It has a settings page through which I could update the underlying OS. It worked with the touchscreen out of the box. It has a UI for connecting to wifi. It too didn't include streaming Internet radio support, but it had a working add-ons browser, in which I found both BBC iPlayer and Internet Radio extensions.

Soon I was in business. It connected to wifi, it was operable with the touchscreen, connected to some old Altec Lansing speakers I had lying around. So I bought a case from Mironet, my friendly local electronics store. (There is a veritable Aladdin's Cave even closer to my office, GM electronic – but I'm afraid they're not very friendly. Sort of the opposite, in fact.)

I assembled the touchscreen and π3 into my case, and hit a problem. Only one available opening for a µUSB lead, but the screen needs its own. Some Googling later, it emerges than you can power the touchscreen from the π's GPIO pins, but I don't have the cables.

So off to GME it was, and some tricky negotiations later, I bought a strip of a dozen jumper cables. Three of them got me in business, but since it was £1 for all of them, I can't really complain about the wastage.

So now, there's a little compact unit in my bedroom which plays the radio whenever I want, on the power usage of a lightbulb. No fans, no extra cooling, nothing. I've had to use my single Official Raspberry Pi PSU brick, as all my phone chargers gave me the lightning-bolt icon undervoltage warning.

This emboldened me for Project 2.

Some years ago, Morgan's had a cheap offer on 2TB hard disks. I bought all their remaining stock, 5 mismatched drives. One went into an external case for my Mac mini and later died. The other four were in a box, pending installation into my old HP Microserver G1, which currently has 4×300GB drives in it, in a Linux software RAID controlled by Ubuntu. (Thanks to hobnobs!) However, this only has 2GB of RAM, and I figured that wasn't enough for a 5TB RAID. I may have accidentally killed it trying to fit more RAM, and the job of troubleshooting and fixing it has been waiting for, um, a couple of years now.

Meanwhile, the iMac's 1TB Fusion Drive was at 97.5% full and I don't have any drives big enough to back up everything on it.

I slowly and reluctantly conceded to myself that it might be quicker and easier to build a new server than fix and upgrade the old one.

The Raspberry Pi 4 is quite a different beast. Apart from a beefier 64-bit ARM7 quad-core, it has 2GB and 4GB RAM options, and it has much faster I/O. Its wifi and Ethernet are directly attached to the CPU, not on the USB bus, and it has 2 of those: the old USB2 bus (480Mb/s) and a new, separate 5Gb/s USB3 bus. This is useful power. It can also drive dual monitors via twin µHDMI ports.

But the π4 runs quite hot. The Flirc case my π3+ is in is only meant for home theatre stuff. A laden π4 needs something beefier, and sadly, my local mail-order electronics place, Alza, doesn't offer anything that appealed. I found the Maouii case on Amazon Germany and that fit the bill. (It also gave me a good excuse to buy the entire Luna trilogy by Ian McDonald in order to qualify for free shipping.)

So, from Alza I ordered a 4GB π4 and 4 USB3 desktop drive cases. From Mall CZ I ordered a USB3 hub with a fairly healthy 2.5A power output, thinking this would be enough to power a headless π4. USB C cables and µSD cards I have, and I figured all the USB 3 cables would come with the enclosures, which they did. In these quarantine lockdown times, the companies deliver to electronically-controlled mailboxes in shopping malls and so on, where you enter a code and pick up your package without ever interacting with a potentially-infectious human being.

It was all with me within days.

Now, I place some trust in those techies that I know who are more skilled and experienced than I, especially if they are jaded, cynical ones. File systems are one of the few significant differentiating factors between modern Linux server distros. Unfortunately, a few years ago, the kernel maintainers refused to integrate EVMS and picked the far simpler LVM instead. This has left something of a gap, with enterprise UNIXes still having more sophisticated storage tech than Linux. On the upside, though, this is driving differentiation.

SUSE favours Btrfs, although there's less enthusiasm outside the company. It is stable, but even now, you're recommended not to try to repair a Btrfs filesystem, and it can't give a reliable answer to the 'df' command – in other words, the basic question "how much free space have I got left?"

I love SUSE's YaST admin tool, and for other server stuff, especially on x86, I would probably recommend it, but it's not ideal for what I wanted in this role. Its support for the π4 is a bit preliminary so far, too.

Red Hat has officially deprecated Btrfs, but that left it with the problem that LVM with filesystems placed on top is a complex solution which still leaves something lacking, so with its typical galloping NIH syndrome, it is in the process of inventing an entirely new disk management layer, Stratis. Stratis integrates SGI's tried-and-tested, now-FOSS XFS filesystem with LVM into a unified disk management system.

Yeah, no thanks. Not just yet. I am not fond of Fedora, anyway. No stable or LTS versions (because that's RHEL's raison d'etre). CentOS is a different beast, and also not really my thing. And Fedora is also a bit more bleeding-edge than I like. I do not consider Fedora a server OS; it's more of a rolling tech testbed for RHEL.

Despite some dissenting opinions, the prevailing opinion seems to be that Sun's ZFS is the current state of the art. Ubuntu has decided to go with ZFS, although its license is incompatible with the Linux kernel's GPL. Ubuntu is, to be honest, my preferred distro for desktop stuff, and I've run it on πs before. It works well – better than Fedora, which like Debian eschews non-free drivers completely. It doesn't have Raspian's hardware acceleration but then everyone uses Raspbian on the π so it's an obvious target.

So, Ubuntu Server. Modern versions include ZFS built-in.

I tested this in a VM. Ubuntu Server 18.04 on its own ext4 boot drive... then add a bunch of 20GB drives to the VM... then tell it to create a RAIDZ. One very short time later, it has not only partitioned my drives, created an array, and formatted it, it's also created a mount point and mounted the new array on it. In seconds.

This is quite impressive and far more automatic than the many manual steps involved in doing this with the old Linux built-in 'mdraid' subsystem, as used in my old home server.

Conveniently – it was totally unplanned – by the time all my π4 bits were here, a new Ubuntu LTS was out, 20.04.

I installed all my drives into their new enclosures, plugged them one-by-one into my one of iMac's USB3 ports, and checked that they registered as 2TB drives. They did. Result. Oh, and yes, the cables were in the boxes. USB3 cables are entertainingly fat with shielding, but 5Gb/s is not to be sniffed at.

So, I put my new π4 in its case, put the latest Ubuntu Server on a µSD card – and hit a problem. I can't connect a display. I only have one HDMI monitor and nothing that will connect to a π4's micro-HDMI ports. And I don't really want to try to set this all up headless.

So off to Alza's actual physical shop I trogged to buy a µHDMI to HDMI convertor. Purchasing under quarantine is tricky, so it took a while, but I got it.

Fired up the π4 and it ran fine. No undervoltage warning running off the hub. So I hooked up all the drives, and sure enough, all were visible to the 'lsusb' command.

I referred to various howtos. Hmm. Apparently, you need to put partition records on them. Odd; I thought ZFS subsumed partitioning. Oh, well. I put an empty GUID disklabel on each drive. Then I added them to a RAIDZ, ZFS' equivalent of a RAID5 array.

Well, it wasn't as quick as in an VM, but only a minute or so of heavy disk activity later, the array is created, formatted, its mountpoint created and it's online. This is quite impressive stuff.

Then came the usual joys of Linux' fairly poor subsystem integration: Samba is a separate, different program, Samba user accounts are not Linux user accounts so passwords are different. Mounted filesystems inherit the permissions of their mountpoint. Macs still favour the old Apple protocol, so you need Netatalk as well. It, of course, doesn't integrate with Samba. NFS has two alternatives, and neither, of course, integrate with either Samba or Netatalk. There are good reasons NT caught on, which Apple successfully imitated and even exceeded in Mac OS X – and the Linux world remains as blindly indifferent to them as it has for a quarter of a century.

But some hours of swearing later, it all works. I can connect from Windows, Linux or Mac. It's all passively-cooled so it runs almost completely silently. It does need five power sockets, which is a snag, and there's a bit of cable spaghetti, but for an outlay of about £150 I have a running server which can sustain write speeds of about a gigabyte per second to the array.

I've put my old friend Webmin on it for a friendly web GUI.

So there you are.

While the π3 is a little bit underpowered, for a touchscreen Internet radio, it's great, and I'm very pleased with the result.

But the π4 is very different. It's a thoroughly capable little machine, perfectly usable as a general-purpose desktop PC, or as a server with quite decent bandwidth.

No, the setup has not been a beginner-friendly process. Apparently OpenMediaVault has versions for some single-board computers, including the π3, but not for the π4 yet. I am sure wider support will come.

But overall I'm impressed with how easy this was, without vast expert knowledge, and I'm delighted with the result. I will keep you posted on how it works longer-term.