FreeBSD Diaries – 14.0 Upgrade Man-Trap

Note to self:- Must get into the habit of re-installing the bootstrap loader when doing upgrades (will be happier in the end).

I thought I’d worked out a fairly safe path with my FreeBSD 14.0 upgrades. First of all, I installed a VM and explored the new release. Nothing exploded when I touched it. It looked like FreeBSD, quacked like FreeBSD and felt like FreeBSD (and it also seemed a little snappier than the 13.x releases, which is always a good thing). So following that, I went ahead and upgraded a couple of my existing VM systems (running actual application loads) and again had an almost painless journey (it seems as though the structure of one of the compiler packages has changed, so there is a slight hiccough where a file already exists where the new package expects a directory, but it doesn’t prevent the upgrade process from completing). The merge process (manual update of files) was definitely longer than with 13.x minor upgrades, but nothing too stressful.

After a few successful VM upgrades, I turned my attention to the smallest (and least important) of my servers and, once again, the upgrade process ran through with nothing I hadn’t already seen in the previous, VM upgrades. I rebooted it during the upgrade process and again a couple of times afterwards, just to make sure that everything was stable. Then I just left it alone for a few days while I got on with other things. The server was fine and the VMs running on it were also fine (both the upgraded, 14.0 ones and the older 13.1 and 13.2, yet-to-be-upgraded ones).

Emboldened by my success, I turned my attention to one of the busier servers on our network (another machine where I’d already upgraded a couple of VMs, without incident). Again, the upgrade went without major incident. I got through the reboots and everything was looked fine.

At this point, I unwittingly loaded and tamped the old flintlock (you know …the one I use to shoot myself in the foot every now and then). I remembered that this particular server is a little bit “iffy” and, if you actually touch it (as in plugging in the video cable so that you can see what’s going on), it tends to spit out a couple of disk errors. Years of painful experience have shown that this isn’t actually a problem, unless you try to fix it. So, taking a deep breath, I run “zpool status” and, as expected, see a couple of errors showing on one of the disks in the root pool. Knowing better than to start messing with the disk (or its cables), I run “zpool clear” and note that, as expected, the errors have gone and the resilver shows a measly 1.62MB updated. But wait! What’s this? There’s a nice little note tucked in there letting me know that the ZFS feature set has been updated, but I won’t be able to use those shiny, new features until I’ve run “zpool upgrade”. Okay, been there, done that, didn’t buy the crappy tee-shirt. I balk at doing all of the pools and choose a victim which won’t cause too much trouble if it falls off the edge of the world:- “zpool upgrade zstore02“.

The machine didn’t burst into flames, the dog didn’t throw up on the carpet (that’s unusual …I should have realized right then that something was up) and zstore02 still responded to gentle prodding. It also let me know that these new features had been added:-

  • edonr
  • zilsaxattr
  • head_errlog
  • blake3
  • block_cloning
  • vdev_zaps_v2

Being intrigued by the names, I actually took the time to go to “man zpool-features” to try and work out what they all did. No chance! (nice names, though …who wouldn’t want a zilsaxattr or a vdev_zaps_v2 on a wet Saturday afternoon?).

Having noted absolutely nothing untoward, I worked my way through the other pools on the machine and never even noticed the little extra message at the end of the output when I updated the root pool:-

Pool ‘zroot’ has the bootfs property set, you might need to update
the boot code. See gptzfsboot(8) and loader.efi(8) for details.

[Don’t be fooled by the “might“] I didn’t even notice the click as I (unknowingly) cocked the old flintlock.

Warmed by the knowledge that yet another upgrade was “in the bag”, I rebooted the system.

And you don’t need a commercial break, or even an over-long pause, to know that it didn’t. Instead, it threw out a goodly amount of console messages letting me know that it had no clue as to what the feature “com.klarasystems:vdev_zaps_v2” was (or any of the others in the list) and it most certainly wasn’t going to boot from the primary, secondary or tertiary disks, so there! 

Futtocks!!* What have you done to my system, Allan?!?!

Never a bootable floppy in sight when you need one. Let me just shout at you for a second, just in case you’ve missed the moral of this story so far:-

DON’T ASSUME THAT ALL ZFS UPDATES ARE BENIGN, ESPECIALLY WHEN THEY TELL YOU IN ADVANCE THAT IT MIGHT HURT!

In other words, always re-install the EFI/GPT/BIOS (or whatever else you might be using) on at least one of your designated boot disks after doing a “zpool upgrade“.

Okay, so apart from panicking, what did I do to get out of this self-inflicted mess? Luckily, since I know that all of my machines use UEFI, there wasn’t too much mucking around to get things going. I knew that I needed a bootable USB stick before anything else, so off I went to find a working machine and downloaded the FreeBSD 14.0 “bootonly” image (just because it’s smaller and quicker to pull over the skinny wires I have here). Booting that was easy (as far as the system was concerned, it was the only bootable media in the whole machine). Hit return to get a shell and away we go…

mount_msdosfs /dev/da5p1 /mnt

cp /boot/loader.efi /mnt/efi/boot/BOOTX64.EFI

Two things which you need to take notice of here. The da5p1 disk will need to be changed for your specific installation (assuming you didn’t take any notice of my shouting and got yourself into this mess, too), but do note that, because we booted from a USB device, all of the other USB drive numbers have been shuffled up by one. My USB thumb-drive is now da0 and the drive which I want to install the EFI bootstrap code on is normally drive da4, but (for this boot only) has become da5. I am (in this case) deliberately not changing either the primary or secondary boot disks, just in case I mess up again (they will be done later, once this change is proven good).

The second thing is that the EFI partition on disk is always quite small, so it is generally better to overwrite the existing file, rather than write a new file with a different name (running out of space when copying to the MSDOS UEFI partition will generate a general “I/O Error” message, which can be a bit confusing). Re-using the same name also ensures that the bootable drive description created by the efibootmgr command remains the same and doesn’t require updating.

That was it. I synced and shut down the system and it rebooted successfully from the tertiary boot disk.

So, did my foot hurt? Nope! The old flintlock misfired and the ball went sailing off across the room. It would probably have killed the dog, but she was hiding behind the sofa …puking on the carpet. All is back to normal (for the time being, anyway) in Schloss Puce.


*Futtocks – Sounds like a good, old-fashioned Anglo-Saxon swear word …but isn’t. Your homework for today is to find a dictionary and look it up.

Oh, and thanks for all the updates, Allan! :-)

Getting started with the LuckFox Pico Pro [Part II]

In the first part of this series, we looked at accessing our LuckFox Pico Pro using an RDNIS network connection over the USB port to connect with the minimal “busybox” Linux shipped from the factory. In this second part, we’ll explore replacing that minimal system with a much more capable release of Alpine Linux to access the full potential of this tiny board.

Before starting on our upgrade, we do need to make one small change to the hardware on the board. This is the addition of header pins for TX, RX and GND connections to UART2, to allow us to connect to the serial console of the device.

LuckFox Pico Pro with SD-Card, RTC-Battery, Console Adapter & Ethernet

While the bulk of the GPIO pins will probably be soldered to the bottom of the board (to allow mounting on a larger carrier board and thus access to the GPIOs), it makes sense to mount these three pins to the top of the board, for ease of connection of a serial-to-USB module (note that this board has 3v3 I/O pins, so you’ll need to use an appropriately rated serial-to-USB module, not a 5v one).

Flashing Alpine Linux

There is already an Alpine Linux image available for this board, linked to from the LuckFox Wiki page. User “walker2048” contributed two very good articles on the Chinese “EEWorld” forum giving a very good step-by-step description of building, installing and using an Alpine Linux image (these are the posts available in English on the LuckFox Wiki), but unfortunately the articles are Windows centric and assume that you’re going to be using the SocToolKit GUI to load the image to the board. The linked Alpine Linux image is a zip file and not the “.img”  format that we’d normally “dd” to an SD-card or memory under Linux. Although there is a command-line “upgrade_tool” available for Mac and Linux users, frustratingly it also assumes a target XXXX.img file (the same as the Windows GUI SocToolKit version), but as just mentioned, that’s not the format that the Alpine Linux zip file contains. What to do?!?

There are some hints in the Alpine Linux zip package. There are a couple of text files contained within it:- sd_update.txt & tftp_update.txt.

Unfortunately, neither of them is the hoped-for “how to” text for users, but they do turn out to be how to texts for some sort of assembler or builder program. That started me off on a search for the method used to build a modified distribution from the SDK and, lo and behold, sitting right there in the luckfox-pico SDK bundle is a /tools/linux/Linux_Pack_Firmware directory. Yes!! There are both mk-update_pack.sh and mk-update_unpack.sh scripts in that directory. A quick perusal of the pack script shows that it only needs to be passed a couple of options, which identify the target chip type and the input source location (also where the “update.img” output file will be written). I quickly un-zipped the Alpine-Linux.zip package into a new “alpine_test” directory and ran:-

./luckfox-pico-SDK/tools/linux/Linux_Pack_Firmware/mk-update_pack.sh --chip-id rv1106 --image ./alpine_test/

[Partially abbreviated output follows, below]

[mk-update_pack.sh:info] image input dir: ./alpine_test/
[mk-update_pack.sh:info] partition file name: env.img
[mk-update_pack.sh:info] start to package update.img...
[mk-update_pack.sh:info] partitions:
env env.img
idblock idblock.img
uboot uboot.img
boot boot.img
rootfs rootfs.img
package-file package-file
bootloader download.bin

TOOL_PATH=luckfox-pico-SDK/tools/linux/Linux_Pack_Firmware
Android Firmware Package Tool v2.2
------ PACKAGE ------
Add file: ./alpine_test/env.img
env,Add file: ./alpine_test/env.img done,offset=0x800,size=0x40000,userspace=0x80,flash_address=0x00000000
...
...
package-file,Add file: ./alpine_test/package-file done,offset=0x1365800,size=0x83,userspace=0x1
Add file: ./alpine_test/download.bin
bootloader,Add file: ./alpine_test/download.bin done,offset=0x1366000,size=0x3e9c0,userspace=0x7e
Add CRC...
Make firmware OK!
------ OK ------
********rkImageMaker ver 2.2********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
[mk-update_pack.sh:info] Making -RK1106 update.img OK.

…and was rewarded with a nice, shiny new alpine_test/update.img file. Okay, now we’re more than halfway to our objective. The next part is a little bit scary, in that we have to overwrite the existing “busybox” image in NAND flash with our untested Alpine image, which could leave us with a semi-bricked Pico Pro. The saving grace here is that, should this happen and the Pico cannot boot from flash, it should automatically try to boot from the SD, so we do have a plan B.

Loading the image to NAND flash is now fairly simple, as we just need to follow the Wiki instructions for Linux Burning for Linux/MacOS (before doing this, you should already have added the UART2 header pins as outlined above and connected your serial-USB adapter). The basic procedure is to grab the command-line upgrade_tool for Linux from the link on the Wiki page, hold down the “BOOT” button on the Pico Pro and then press and release the “RESET” button (to force the board into download mode) and then use the command:-

upgrade_tool uf upgrade.img

…to start the actual update process.

Running Alpine Linux on the LuckFox Pico Pro

Probably the first thing to note about running Alpine Linux is that there is no RNDIS connection started on the USB port, so you must use the serial console to configure the board from this point, until you enable ssh logins over ethernet.

This Alpine 3.18 build from “walker2048” uses a default ethernet address of 192.168.50.59, so in all probability, you’ll want to log in on the serial console to modify /etc/network/interfaces to match your own LAN configuration. 

You don’t have to remember any pesky user-ID/password combinations, as “walker2048” has also configured an auto-login for “root” on the console. You might want to change this configuration by editing the /etc/inittab file to comment-out this line (just a quick word of caution here …before you begin this change, you need to ensure that you have a valid password set and tested for the root account):-

ttyFIQ0::respawn:/sbin/agetty --autologin root ttyFIQ0 vt100

…and replace it with the following:-

ttyFIQ0::respawn:/sbin/getty -L ttyFIQ0 115200 vt100

The two things to notice with this replacement are the obvious, missing “--autologin” and the not so obvious change from “agetty” to just plain old “getty“ (“agetty” is “advanced getty” and has the magic sauce included to create automatic logins, which plain old-fashioned getty doesn’t).

If everything went according to plan, you should now have a very usable Alpine distribution on your tiny LuckFox board and should be able to log in over the network and use the apk package manager to search for and install standard packages.


FreeBSD Diaries – Expanding ZFS Pools

Have you ever wondered what that column header, “EXPANDSZ”, in the zpool list command actually refers to, or why it is always empty? Below is a short, real-world example of how it can help you (and did help me).

TL/DR; The manual page for “zpoolprops” tells us that EXPANDSZ is the “Amount of uninitialized space within the pool or device that can be used to increase the total capacity of the pool”. In other words, space that is not already being used by ZFS that might possibly be used to expand our pool into. The manual page also mentions “resizing in place”, which implies that we can expand the size of a ZFS pool on a live, running machine. This sounds, and is, incredibly useful, but there are caveats. For instance, if your pool is a mirror, then all of the sub-mirrors must have free space available. More on this below, where I’ll demonstrate that yes, we certainly can resize a filesystem on a live, running machine (in certain circumstances).

Back story — I have several low-cost, mini-pc systems which work together to provide network services on our LAN. Each of these machines came with some eMMC memory built in (the amount varies, depending mainly on how long ago the machine was purchased). Those machines were, in some cases, installed with the root partition on the internal eMMC and then later updated with external hard disks, using ZFS to mirror all partitions (including the original root partition). This was convenient at the time and also meant that it was easy to reuse the machine without having to do a full install.

Moving forward over the years, a couple of those machines have been upgraded through several versions of FreeBSD and, among other things, the lax management on my part of snapshots and boot-environments has resulted in a squeeze for space on the original root partitions along with (horror of horrors!) an exploding fragmentation level. As I’ve mentioned in these pages before, anything north of 80% fragmentation on a ZFS filesystem is very bad news and needs remedial work. I was hoping to hang on and re-install with a nice, squeaky-clean 14.0 release on the worst affected machine, but the fragmentation issue has forced my hand. So here’s what the fairly critical state of affairs on that machine looked like, before remediation:-

As you can see, we have 2.11GB of “free” space, but that 91% fragmentation figure means that the system is probably going to have to work exceptionally hard to squeeze any sizeable file in there. At this point, the machine becomes almost unusable.

There are a few things worth noting here. The first thing is that the space on the original eMMC partition, /dev/mmcsd0p3, is almost exhausted, but the other partitions in this multi-way mirror all have partition sizes almost double that, at 100GB. The second is that those three partitions are all on identical disks, with identical block counts (you can still use the expansion method described here on mirrors where the sizes are not exactly equal, but in that case you absolutely must use the smallest partition as the resize target, as you cannot attach a smaller partition to a larger mirror). Lastly, despite the obviously available space on those three partitions, the EXPANDSZ column does not show any space being available for expansion. Why not?

Well, despite there obviously being space available, ZFS doesn’t consider it to be really available until it can actually implement a resize operation to claim that space. In the specific case of the multi-way mirror shown above, ZFS can’t resize it until it is reduced to a single physical device. This sounds scary, but in practice simply means that you need to detach physical devices from the mirror until you have a single device, resize the filesystem and then reattach the other devices again. All of this can be done with the system up and running normally, with no reboots required (but you do need to take into account that the resilvering of reattached devices can load your system down more than usual).

So let’s start by detaching the eMMC partition, /dev/mmcsd0p3:-

Okay, so now the eMMC partition has gone, but there are no other changes to free space or EXPANDSZ.

Next we detach two of the remaining three physical partitions:-

The detach of da4p3 again doesn’t produce any noticeable change in free space or EXPANDSZ, but when da1p3 is detached, we suddenly see 42.5GB appear in the EXPANDSZ column.

Okay, now we can go ahead and run the resize operation. To do this we use the “online -e” command on our remaining partition, da0p3:-

The “online -e” command takes just a couple of seconds to complete, after which we can see that EXPANDSZ has gone back to displaying nothing available, while our free space has jumped to 44.6GB and the fragmentation has gone down from 91% to 52%. At this point, all that is left to do is to reattach da1p3 and da4p3 to the mirror again:-

And that’s it! We’ve removed the original, cramped root device, /dev/mmcsd0p3, from the root mirror and resized the mirror to use the additional 42.5GB which was available on those external disks, all without a single reboot and without any interruption to the other services running on the machine. All done with the magic of ZFS.

The Daily Steal — $11 Dual-Core Orange-Pi

Update April 27th 2023 — The big news today is that reader [titus m] has confirmed that both Ubuntu and Debian images boot on his board. See the “info” post for the specifics on how to configure the jumpers and “scatter” file to get your board running.

Today’s daily steal is something of a departure from our usual fare of mini-pcs and ESP boards and is appearing here mainly because I was searching for a Raspberry-Pi alternative (Linux capable device with easily available GPIOs), without having to take out a third mortgage. I do have a Pine 0x64 board sitting here, but because of a serious lack of connectivity, it is currently relegated to “curio” status.

I actually found this board after already ordering (and receiving!) a different Orange-Pi model from the Middle Kingdom (more on that below) and what caught my eye was not the spec sheet (to say that the specs are modest is an exaggeration), but the price. This board comes complete for just less than US $11 including shipping (two for less than $20, incl shipping).

This odd-looking beast is the Orange Pi 3G-IOT-A and, despite the weird PCB antennas hanging off the end, turns out to be a less than awe inspiring, but very cheap, Linux-capable, dual-core ARM board. The MT6572 CPU is a 32-bit, dual-core (‡ I’m repeating that, because Orange-Pi themselves seem to be a little unclear on the subject, see note below), ARM Cortex-A7, running at 1.2GHz. The CPU was originally designed and marketed as an all-in-one, low-power smartphone chip (hence the GSM antenna) and Orange-Pi repurposed it as a member of their “IoT” range.

The things you need to be aware of with this board are that the processor is definitely not cutting edge, the memory is limited to 256MB (3G-IOT-A, the 3G-IOT-B has 512MB) and the 3G capability apparently only works using the Android build and not at all under Linux (so you can probably disconnect the GSM antenna and throw it in the bin, just to save yourself some grief).

Despite this being tagged as an Android device, there is a Linux build available for it. The drawback there is that it is a fairly ancient kernel and it is a major PITA to build and install (Okay, so you already suspected that there had to be -some- reason that the board was so cheap …and now you know what it is!). It’s not quite so even more complicated to flash than the Pine 0x64 and certainly isn’t beginner friendly. There is no explanation of what the board jumpers do, but apparently they need to be in place during flashing and need to be removed for normal boot. The baud rate for the console is set to 921600 by default.

On the plus side, it is cheap (have I mention that, yet?), it has a whole 512MB of eMMC flash (Wow!) and by dint of being a phone chip, has fairly modest power requirements.

I don’t actually have one of these boards in my sweaty paws now (see the “info” follow-up post), but it’s only fair to warn you that the Orange-Pi forum does have a fair number of “I can’t get this thing to work!” posts (indispersed with “It’s working now, but I don’t know why!”).

A slight diversion into Orange-Pi Zero 2 country

As I mentioned earlier, I do have another Orange-Pi board on test right now, the Orange-Pi Zero 2. This is a very nice little board which deviates from the Raspberry-Pi shape and size, but does have two sets of pin headers available, making it easy to interface with external devices. It has GbE, as well as WiFi, a quad-core H616 processor and a USB-C connector for power. The model I have is equipped with 1GB of main memory (careful, there are 512MB versions out there. too). I mention this here because this is a very good deal for anyone looking for an SBC with accessible GPIOs, I bought this as a package (Zero-2 board, aluminium heat-sink/ case and USB-C power supply) for US $32 (including postage) from this AliExpress store. I’m including the link here because the store shipped immediately and the parcel was delivered exactly seven days after the order was placed. The packing was exceptional, with plenty of bubble-wrap around the boxes containing the SBC and the heat-sink and all enclosed in a waterproof heavy-duty envelope. The Ubuntu server distribution from the Orange-Pi site works well (the Armbian distributions tend to hang on reboot and don’t seem to support WiFi, even though the kernel is much newer). Please do note that the $32 price (for bundle #4) mentioned here is the “first time user” discount price from this store; if you’re a returning customer, you’ll have to pay the full $36.50, “normal” price.

Bottom line …If you need something which is guaranteed to work out of the box, grab the Zero-2 package. If you’re severely limited in the $$ department and have enough experience with SBCs that you’re not discouraged by the challenge of a somewhat haphazard installation process, then the 3G-IoT-A might be for you (as long as you don’t actually need 3G).


‡ — The introductory paragraph on the Orange-Pi wiki page seems to have been cut-and-pasted from a completely different product, describing the board as having an H6 processor and 2GB of memory, which is clearly not the case.  Then the Hardware Specification table on page two of the User Manual compounds the confusion by  describing the CPU as a “Quad core ARM Cortex-A7”. However,  MediaTek, the maker of the chip, who should actually know for certain, document it as having two cores and, to be fair, Orange-Pi do refer to it in other places on their site as “dual-core”.

A Really Neat Trick With The RPi Pico

I imagine that almost everyone knows by now that the RPi Pico is dual-core and probably you also know that the FreeRTOS stack is available to enable multitasking. What I didn’t know until this morning is that there’s a super-simple, super-easy way of taking advantage of both cores without having to go down the RTOS rabbit hole (although FreeRTOS isn’t that difficult, it can, like many other things, be a wee bit daunting to the beginner).

This is a biggie! This apparently simple change just opened up the world of multitasking, multicore programming to absolutely everyone. This neat idea, centred on the Arduino IDE and with the added popularity of the Raspberry-Pi community, is going to be a huge boon to hobbyists everywhere.

So what is this multiprocessor trick? It couldn’t be much simpler. Using the Raspberry Pi Pico Arduino core (“Arduino-Pico”), use these two functions:-

setup1(){}

loop1(){}

That’s it! That’s essentially all you need to know.

By default, Arduino-Pico will use the normal setup() call to initialize core-0 of the processor, but if it finds that a setup1() function exists, it will initialize core-1 of the processor with the contents. This happens more or less simultaneously at start-up.

Likewise, while core-0 will run code contained in the default loop() function, core-1 will run the code contained within the loop1() function.

There are also a couple of other calls in there which will help you communicate between the two cores and which are also really simple to use. Rather than trying to describe them, I’ll just leave you with a link to a demo program (which will run a WiFi network scan on core-0, while simultaneously running a fader on the on-board LED using core-1).

Hopefully, this change will be picked up on other platforms (ESP32 anyone?) and become an integral part of the Arduino IDE; in the meantime, have fun running multicore on the Pico, quickly and easily!


The Arduino-Pico core is available from Earle F. Philhower’s GitHub repository.

Excellent documentation for the core is also available.

Grub bites man. Man stamps on grub. ‡

‡ — No invertebrates were harmed during the production of this article.

TLDR:-  Skip straight to the updates at the bottom of the page for links to the bug reports.  The short version is “You can blow away any root-on-ZFS Linux system by enabling zstd compression on bpool (or whatever the actual boot partition is called on your particular distribution)”. Do NOT do this (not even to test it); you will regret it!

Almost exactly two weeks ago I got a (normal) pop-up message on my screen, letting me know that there were updates available from Ubuntu for my 21.10 version of Mate and that, by the way, 22.04 was now available if I wanted to upgrade.  I politely refused the upgrade offer, but accepted the updates.  Once the updates were completed I was prompted to reboot (and I noted that the initramfs had been updated).  This is all normal stuff for the millions of us running the various versions of Ubuntu, so after finishing up what I was working on (and washing my hands) I hit the reboot button.

It didn’t.

It hasn’t for the last two weeks (not without a recovery image or an external disk plugged in, anyway).

At first I wasn’t too concerned.  This (as the ‘mericans say) isn’t my first rodeo and, if everything else failed, I’m using ZFS, so I just had to roll back to the last good snapshot, right?

Wrong!

As I wasted more and more time futzing around with things, I just got more and more confused. The EFI boot was working and grub was being run, but it insisted that it couldn’t find a workable filesystem.  Booting into a live-CD image said there were two perfectly good ZFS pools on the disk (actually a 512GB NVME SSD) and a “zfs scrub” passed with flying colours on both of them (bpool and rpool).  Running grub-probe always came back with a message along the lines of “Nope, ain’t nuthin there that I recognize, pinhead!”.

By this time I had convinced myself that someone had broken into Ubuntu’s update servers and slipped a Trojan into my disk headers, or maybe someone was slipping magic mushrooms into my breakfast tea, or aliens had abducted my real ZFS pools and replaced them with zombies.  Anyway, I needed to get some work done, so I found an unused external USB disk, fired up a live-CD again and, because this is ZFS, did a ZFS send-receive between the original disk and the external.  When it came time to run the grub install (on the external disk) it once again insisted that there was nothing at all there which it recognised as any sort of valid filesystem.  Duh!

Okay, nuts to this.  I put a 22.04 live-CD image in, booted it up (“Oh look, you have two perfectly good ZFS pools on this external disk!  Are you really sure you want me to scribble all over them?”) and installed a brand spanking new version of 22.04 onto the external, followed by a ZFS send-receive of just the USERDATA filesystem from the original NVME drive (I’d like to say that I rebooted and everything sprang into life on the external disk, but of course it didn’t.  You can’t easily remove an NVME “disk” from a laptop and of course EFI and grub just kept right on trying to access it).

Eventually, I did manage to broker a truce between the laptop BIOS, EFI and grub, to the point that I could reboot the system successfully, as long as I was actually there to hit the F9 key and manually select the EFI entry for the external disk  …otherwise it would stubbornly continue with a blinky dance of reset, spin disk up, flash something on the screen for 10ms, spin the disk down and repeat.  I never did manage to read what that 10ms micro message was (something from those dang aliens again).

But glory hallelujah!!  It was fantastic!  Not only did I have Mate back again, but the stupidly useless ELAN touchpad on the HP S15 laptop actually worked properly for the first time ever!!  Banzai!!  Well done 22.04!  I’m sorry that I refused your offer of an upgrade at the start of all of this.

Well, long story longer, that’s the way that things have stayed for the past two weeks.  Not that there hasn’t been great gnashing of teeth (not recommended at my advanced age) and thrashing of Gewgull searches (and even Ubuntu’s bug database) for any hints of what could be causing my problems. Searches including both “grub” and “aliens” turned up some interesting stuff, but it seems that I’m the only semi-sentient being-man-thingy in the universe who is having problems with those things in connection with computers.

Eventually, the third neuron in the second bank started firing occasionally and I began to have flashbacks of the horrible problems I had a while back, trying to do ZFS back-ups between my Linux laptop and the mirrored disks on my FreeBSD servers.  Although the FreeBSD servers could send data to a receiving  Linux system, the other way around just would not work at all.  It turned out that there were incompatibilities between the ZFS properties used between the two systems, even though the ZFS versions were meant to be the same (upgrading the FreeBSD servers to version 13.1 seemed to cure that issue).  Now it seemed probable that there was some similar incompatibility between grub and ZFS  …and, finally, it clicked. 

One of those property updates which hit FreeBSD a while back was the introduction of “zstd” compression (Ubuntu introduced it a short while later).  I had tried changing the compression to “zstd” on FreeBSD and noticed a worthwhile increase in compression-ratio with no apparent difference in speed, so I’d made the changes on my laptop, too.  The back-ups kept on working and I was saving more disk space …what’s not to like?

Double-duh!  Pinhead at work (stand clear!).

Okay, so I have (I suspect, anyway) a philosophical disconnect between grub and ZFS about what constitutes a filesystem.  In my book, ZFS wins (whatever grub says, I’m an ex-Sun guy and old loyalties die hard).  What to do now?  Well,back on Gewgull I replace “aliens” with “alternative” and get a few hits on something called “ZFSBootMenu”.  I go to their GitHub repository and start reading.  Nope, I must have left “aliens” in there somewhere, ‘coz I can’t understand this stuff.  It starts off more or less okay (I understand their reference to FreeBSD’s boot environments …a very handy feature,  sign me up), but then they start wandering off into the weeds with things like “fzf” and “dracut” (which sounds like a bad day at the vasectomy clinic) and I want to stop reading so badly that my teeth hurt (told you not to gnash).  I briefly leave the README page and head over to the pre-built releases instead. 

Ah, this is interesting.  “ZFSBootMenu v2.0.0  …New features – Dracut is now optional;”.  Phew!  Well that’s a relief.  Unfortunately, there are four different files (and additional source tarballs), but no information on what the differences are.  A couple have “release” in their names and the others have “recovery”, but no actual information in the v2.0.0 section about what the differences are or how to use them.  Two are compressed tar files (okay, I know what those are, anyway) but the two others have a “.EFI” suffix, which I haven’t come across before, but it’s not too much of a stretch to suspect that they should be used in the Extensible Firmware Interface (that’s the BIOS to you, sonny!).  But how?

Back to the README:-

Each release includes pre-generated images (both a monolithic UEFI applications [sic] as well as separate kernel and initramfs components suitable for both UEFI and BIOS systems) based on Void Linux. Building a custom image is known to work in the following configurations…

Well there you go then.  C’mon!  Chop-chop!  Get on with it!

I won’t bore you with the rest of it, but despite the rambling (or partly missing) documentation, it turns out that ZFSBootMenu is really quite a nifty bootloader (grub alternative) specifically for ZFS filesystems.  It does have a couple of quirks, but after a few false starts, I did manage to bring my 21.10 NVME SSD back from zombieville and ended up with a laptop which I could once again disconnect from all external cables and disks and still have it boot reliably.  To do ZFSBootMenu full justice I need to put together another post with a step-by-step guide of how to recover a stuffed ZFS machine, but just in case you’re stuck up this same creek without a paddle, here are just a couple of essential hints to getting ZFSBootMenu to work:-

  • Use the .EFI  file (I used the “release”, but “recovery” should also work okay).
  • Remember– When you’re booting using ZFSBootMenu, it assumes that the kernel and initramfs are on the root partition, so you’re going to be booting from “rpool”, not “bpool” (and so your kernel and initramfs need to be present on “rpool”, which is not standard in Ubuntu).
  • Disconnect any other disks which you may have added to the system in previous attempts to fix this boot problem (ie:- external USB disks with copies of your original bpool/rpool filesystems).  They will just confuse EFI, grub and you.
  • Set “canmount=noauto” on all filesystems which have “mountpoint=/” set (this one is really important).
  • Make sure that your ZFS pools can be imported without having to use “import -f” (use a live-CD or ZFSBootMenu itself to import the pools manually, fix any problems and then export them again, before you reboot).
  • Lastly, for those others of you out there with non-US keyboard layouts, the “Alt” key for command mode selection within ZFSBootMenu will probably not be the “Alt” key.  For my Japanese keyboard, the magic key turned out to be the one key which I had never before pressed on my keyboard …the (shudder!)  “Windows” key.

And the bottom line… Just don’t change your bpool to zstd compression.  Okay?!?    †  ∇


†  —  From a cursory check of the Grub2 code in the upstream Debian repository, it looks as though the zstd compression library was added in November of 2018.  Unfortunately it seems to have been implemented only for BTRFS, not for ZFS.

  —  “cursory”  Adjective.  Causes the reader to leap out of their chair and shout “G’dammit!!”  (this answer is certain to get you an “A” in GCSE English).

∇  –  Grub Compatibility  —  As usual, the folks at OpenZFS/Debian/Ubuntu are way ahead of me.  If you need to create a new pool which will work with Grub2, there is already an existing compatibility file (they’re stored in /usr/share/zfs/compatibility.d).  You can use it like this:-  

   zpool create -o compatibility=grub2  <POOL NAME>

If anyone is desperate enough to have read all the way down here to the bottom, I’ll just note that this problem hasn’t (has …see below) been submitted as an actual bug, because the auto-submission procedure won’t let you submit a bug against a program which isn’t installed on your system and, of course, I’d removed the grub package and used ZFSBootMenu to actually get my laptop working again. However, the secondary suggested method of opening the issue as a question in LaunchPad is available here if you’re interested (and I’d like to thank Manfred Hampl for trying to help me out there).

Update — 27th July 2022 – I have submitted bug request #1982897 with a condensed description of this issue and a request for an upstream addition of “zstd” support for ZFS in the Grub2 code.

Update #2 — 27th July 2022 – Submitted bug #62821 as a feature request for the addition of “zstd” support to the Grub2 ZFS code.

Update #3 — 13th August 2022 – Updated the Grub2 bug report with a little more detail on the severity of the problem, as there hasn’t been any acknowledgement of the original submission as yet.

Visual Studio Code and PlatformIO

Regular readers will know that I’m a big proponent of PlatformIO as a programming platform for the ESP family; it’s just so much better than the Arduino IDE for us command-line interface die-hards. As I’ve noted before, I’m not a religious fanatic on the CLI vs GUI thing; it’s just that GUIs (with a couple of exceptions) don’t really click for me. Most of the time I just don’t “get it” and what’s on offer usually seems to limit the functionality without really adding much, if anything, in ease of use. Recently though, I’ve been searching for information on getting started with the ESP32’s built-in version of FreeRTOS (specifically, looking for more information on real-world use, rather than just a couple of sentences about the syntax of the xTaskCreate() call) and I found a couple of very useful videos by Xavier on his “Simply Explained” channel which, as the name suggests, do a very good job of explaining by example, how to use FreeRTOS. The thing which (as a doddering old git) really caught my attention was his use of Visual Studio Code. I was captivated by the pop-up prompt with info on the parameters (of which there are plenty) to feed to xTaskCreate. While I imagine that functionality can get pretty tedious when it pops up for each and every printf(), it does look like a definite winner when you’re learning something new (and don’t have much in the way of short-term memory any more).

Now, what was I saying again? Oh yes, here’s the link to one of Xavier’s videos. He’s got a ton of content on his channel on many diverse (but usually tech-related) topics. This one is not the first in the series, so if the abrupt lead-in is a bit too much you can go to his Intro on FreeRTOS instead. I highly recommend watching Xavier’s videos if you’re trying to get started with FreeRTOS.

Of course, I immediately went off and downloaded Visual Studio Code and fired it up …only to just as immediately get totally lost when I couldn’t get it to do anything that I wanted. I did watch a few more videos from a nice lady at Microsoft, but ended up suffering from information overload and Windows-itis. I went for a nice cup of tea instead. And then went back to PlatformIO in an xterm, just so that I could get something done.

More recently, one of my regular morning reads, Hackaday, had an article on making laminated artwork for front panels with an accompanying video (worth a look in itself) by Richard Langner. I was impressed by Richard’s succinct, no-nonsense style and dipped into his video listings to see what other goodies were there. Lo and behold, right at the top of the list were a couple of videos on how to get started with Visual Studio Code with PlatformIO. The first was only a minute and a half long and the second just over six minutes. Both are filled with essential information on doing just what I wanted to do (have the editor prompt me with useful info, but still be able to use PlatformIO as my programming environment). As they’re so short, I’m including both as embedded links below. Take a look. Even if you don’t like them, you won’t have wasted much time.

Many thanks to both Richard and Xavier (oh, and Al Williams and the team at Hackaday, as well as Ivan and everyone at PlatformIO) for making my life not just easier, but a lot more interesting, too.

The Ubuntu ZFS boot pool problem [Part I]

Sorry, as you can see from the title, this is another “not-ESP8266” article, so you can skip this if you’re only interested in our magical little wireless modules. However, if you’re running a system (laptop, server or workstation) loaded with Ubuntu and have the root/boot partitions mounted on a ZFS filesystem, you should at least stick around long enough to read through the problem description, below.


13th Oct 2022 – IMPORTANT NOTE:- Directly related to the “bpool problem”, there is a separate issue with Grub2 not supporting zstd compression for ZFS. So, if you are struggling with the bpool problem, do not, Do Not, DO NOT enable zstd compression as a “fix” on your bpool, otherwise your system will be rendered completely un-bootable (the standard quip is normally “Don’t try this at home, folks!”, but in this case it is most certainly “Don’t try this at work!”, otherwise you’ll be out of a job in short order).


If you landed here from a web search for “can’t upgrade Ubuntu – not enough space on bpool” (or something similar), then you’re in the right place. You can probably skip the introduction to the problem (you already know what you’re facing) and go directly to the solution.

Note that in these articles I am assuming that you are familiar with Linux and confident in your own abilities to administer your own system. Because we are dealing with filesystems, I am also going to assume that you have made and verified back-ups of your whole disk(s) before you follow any of the tips below. I am not responsible for your data. You are. The advice below is given in good faith after having been tested on several of my own machines (of different types), but I cannot be held responsible for any loss of data.

The bpool Problem

You see the familiar Software Updater pop-up, announcing that there are package updates available and prompting you to install them. You scan the list of updates and everything looks good, so you hit the “Install Now” button, but instead of a progress meter, you see a pop-up error window with the message:-

The upgrade needs a total of 127 M free space on disk '/boot'. Please free at least an additional 107 M of disk space on '/boot'.

The message continues with a couple of suggestions of how to increase available space in “/boot”, but basically at this point you are unable to install updates.

You’ve just run into the “bpool problem”.


Background

For the last few releases, Ubuntu has provided an easy method for installing root on a ZFS filesystem, giving you access to snapshots and the instantaneous rollback to previous versions which it enables (as well as the possibility of mirroring) without having to go through the long and tedious process of adding ZFS support after the actual install. It was a major move forwards and the “one-click” install process made it simple for anyone to benefit from ZFS technology (not just snapshots, rollbacks and mirrors, but raidz and ZFS send/receive back-ups, too). With all of those benefits, why wouldn’t you just use it by default?

Well, as a long time ZFS user, I can tell you that it does come with a few drawbacks. It is, for instance, somewhat more difficult to judge the available space left on any physical device than it was in the pre-ZFS world (good ole’ “df -h” is very good at giving you an instant and pretty accurate impression of the current capacity of your disks). ZFS tends to muddy that simplistic view a little, until you get used to depending more on the output from “zpool list -v” and “zfs list -o space” instead of “df”.

Fragmentation is another issue. Die-hard Unix users will remember that “fragmentation” was always a problem for people who used that other operating system, not for Unixes (well, unless you started to run out of inodes, anyway). However, with ZFS you do need to keep an eye on that “FRAG” column in the output of “zpool list -v”; once it starts climbing to around the 50~60% level it’s definitely time to start planning for an upgrade and, once it’s past 70% it’s time to take some urgent action (usually, but not always, time to add more physical disk space — we’ll touch on de-fragmentation as a side-effect in the “Solutions” presented in part-II). Once it hits 80%, you’re in big trouble as, even with available free space, the system will be struggling to find usable space.

These issues are a pain to come to terms with after all of these years of doing the odd “df” just to check that everything was okay, but they are still heavily outweighed by the advantages (did I mention copy-on-write or checksummed data yet?).

So, our simple ZFS installation method from Ubuntu is a real game changer and gives everyone the chance to ride on the ZFS bandwagon with minimal effort. Unfortunately, along with that simplicity and ease of installation comes another problem — sizing your filesystems. The installer is a one-size-fits-all deal; it looks at your disk size and makes a couple of fairly simplistic calculations to create a very simple partition table and then later adds a spread of ZFS datasets on top of those physical partitions. The “bpool” (for “boot-pool”) is a single ZFS filesystem which occupies a dedicated partition just for the kernel/initramfs and EFI/grub data required to boot the system. The “rpool” (for “root-pool”) is the ZFS filesystem which contains datasets for /, /var and /usr (as well as sub-directories) and the user home directories. It’s all very well laid out, so that a rollback to (for instance) a previous kernel version need not affect the user’s data. However, the installation script for ZFS currently has one major issue; it limits the size of the bpool physical partition to 2GB (it can be smaller, but not bigger), no matter what the size of your physical disk

The major drawback that people are finding to this installation mode comes from one of the strengths of ZFS — the snapshot functionality. Put simply, if you make a snapshot of say, your whole bpool, ZFS will never delete anything from that point in time. If you subsequently delete a kernel which was present when you took the snapshot, ZFS will keep the file itself, hidden away in the snapshot and only remove the named link to the file from the normal /boot directory. If, at some later time, you decide that you no longer need that snapshot (because it is outdated and you know you’re never going to revert to that old kernel again) you can destroy the snapshot and only then will you recover that disk space. This is one of the reasons that space management on a ZFS filesystem is a bit of a minefield for new users and is exactly why the “bpool problem” exists.

Every time Ubuntu pushes out an update (even a non-kernel update), the installer will automatically create a snapshot of your filesystem, so that you can roll back to the previous version if things go horribly wrong. In the case of actual kernel updates, the snapshot can consist of tens, or even hundreds of megabytes of combined kernel and initramfs files. Given that we have an upper limit of 2GB on the size of /boot (the bpool filesystem), that space doesn’t go very far if you don’t actively manage the snapshots. Worse, the Software Updater will start to fail when there is no longer enough free space in /boot to fit another version of the kernel and, to be clear, even non-kernel updates will fail to be installed if there is a kernel update still in the queue (even if you de-select it manually). The error messages are clear and quite specific (and even give tips on how to ameliorate the issue). However, by the time Software Updater flags the problem, it can already be too late to easily fix it (and how many of us know which system-generated snapshots are safe to remove and which aren’t, anyway?).

Short-term band-aids

These suggestions are not a true solution, they are fixes to get you up and running in order to have Software Updater working again in the shortest possible time.

Before making any changes which might permanently erase data from your filesystems, you should make a back-up of your whole disk (I’ll be repeating this at various points throughout these articles, because I really mean it — I cannot and will not be held responsible for any loss of data you might suffer while trying to follow the tips given here; I always assume that you have backed-up your data and that you have verified that those back-ups work. Batteries not included. May contain nuts.).

First, one quick fix which Software Updater lists in its output when this problem occurs — edit the /etc/initramfs-tools/initramfs.conf file and change the COMPRESS setting from “lz4” to “xz”. This won’t take effect until the next kernel update, but at that point the initramfs install will use the more efficient (compression, not speed) “xz” method. This can slice around 20MB off each of the initrd.img files in the /boot directory and so will save you about 40MB of space on each update (there are usually two versions, current and “.old”).

The results of this second tip are much more difficult to predict in terms of exact space saved — snapshot whack-a-mole.

You can list your snapshots in bpool using:-

zfs list -t snap -r -o name,used,refer,creation bpool

This will get you a listing with entries that look something like this (but probably much longer):-

NAME              USED   REFER  CREATION
@autozsys_7lzjmg  197M   197M   Wed Dec 30 11:07 2020
@autozsys_9u20hc   17K   199M   Wed Jan 20  6:56 2021
@autozsys_6c4qgp    0B   199M   Thu Jan 21  6:12 2021

[Note that I have removed the pathname before the “@” symbol to fit the text without line wraps]

As you can see, the “used” and “refer” columns vary widely between the snapshots. The bottom entry (6c4qgp) has a “used” entry of zero bytes; surely that can’t be right, can it?. Well, that’s the whack-a-mole function coming into play. In this particular case, there don’t appear to have been any changes to bpool between autozsys_9u20hc and autozsys_6c4qgp, so if we destroyed 6c4qgp, we wouldn’t get any free space released back to the filesystem. So where does the “refer” come from? That’s letting us know that even though there were no changes between the last two snapshots in our list, they both have references to 199MB of data already being held in other, previous snapshots (or the filesystem itself). What this means for us is that while destroying 6c4qgp may not free up any space, it is very likely that destroying 7lzjmg or 9u20hc will cause 6c4qgp to inherit some of that referenced data, thus causing the “used” count for 6c4qgp to increase and the filesystem not to gain back as much free space as we expected (hence “whack-a-mole”, the used data count might just pop back up elsewhere).

Now, to be fair, because we’re dealing with /boot and the turnover is usually caused by the replacement of kernel/initramfs files, it is more than likely that destroying the oldest snapshot will simply delete the oldest of those kernel-related files, returning about 140MB of free space to the filesystem. Likely, but not certain, so don’t go destroying snapshots left, right and centre without checking their contents first.

LISTING OF /boot CAPACITY AND AVAILABLE SPACE
["df -h"]
Filesystem                 Size  Used Avail Use% Mounted
bpool/BOOT/ubuntu_g1cutr   145M  117M   29M  81% /boot

["zfs list"]
NAME                       USED  AVAIL     REFER  MOUNT
bpool/BOOT/ubuntu_g1cutr  1.52G  28.5M      116M  /boot

["zfs list -o space"]
NAME                      AVAIL   USED  USEDSNAP  USEDDS
bpool/BOOT/ubuntu_g1cutr  28.5M  1.52G     1.41G    116M

You can always check the contents of any given snapshot by noting where the ZFS pool is mounted and then navigating to the .zfs/snapshot directory at that point. So, for our bpool snapshots, we can see from the output of “df” or “mount” that bpool/BOOT/ubuntu_g1cutr is mounted at /boot. Listing /boot/.zfs/snapshot will give us a listing of directories which correspond to the snapshot names in the listing above. You can list each of those directories to see what files and directories are included in the snapshot. As /boot is actually quite small, you can easily do an “ls -i” on two of the snapshot directories and see which files have the same inodes and which are different (which gives a good indication of which files are shared between different snapshots and the current, live filesystem and which are unique to a given snapshot).

Snapshots are removed using the “zfs destroy” command, by the way, not by removing the snapshot directories.

Don’t forget that destroying any snapshot restricts your ability to recover to a known point in time, so I would urge you to err on the side of caution — if you’re not 100% certain of what you’re about to remove, don’t do it!

If you’re a user who likes to create their own snapshots (before a major upgrade, for instance) you might already be able to easily target some of your own snapshots as candidates for deletion (perhaps you already know that you’re not going to roll back to that ancient, previous release?).


The [partial and not very satisfactory] Solution

The stop-gap solutions listed above are just that; short term solutions which will give you some extra breathing space, but not long term fixes. To remedy the bpool problem long term, we obviously need to add a substantial chunk of extra disk space.

One brutal, but simple way of getting back more bpool space (and a solution which is very topical with the release of 21.10 almost upon us) is to re-install Ubuntu after editing the ZFS section of the install script to bypass the problem. I’m not suggesting that this is the best or most versatile answer to the issue (in most cases it won’t be), but if you happen to be on the verge of upgrading, or perhaps have a machine where all of the application and user data is mounted from a fileserver rather than local disk, this may be an option (but, as always, I would recommend a full back-up of the system before taking such a drastic step).


Just in case you didn’t quite get that… ==WARNING== The following steps will delete -ALL- of the data on your disk. Do -NOT- proceed with the steps below if you are not prepared to have your disk(s) totally wiped of all existing data.


Booting from the Ubuntu install image will drop you into the Try-or-Install header page. Select “Try Ubuntu”, which will restart the desktop to the normal, live image. From there you can open a terminal session and become root using “sudo -s” (no password required).

Using whatever editor you’re most comfortable with, open /usr/local/share/ubiquity/zsys-setup.

On (or about) line number 267, you’ll find this code:-

[ ${bpool_size} -gt 2048 ] && bpool_size=2048

You just need to comment out that line completely for the simplest fix. Doing so will allow the bpool size calculation to grab a much larger chunk of your available disk space. Note that if your disk is 50GB or less, this isn’t going to help — you’ll still end up with roughly 2GB. Conversely, if your disk is 1TB or larger, you may end up with much more bpool space than you actually need, or want. In these cases, you might want to change line 267 to use some value other than 2GB; I found 10GB (ie:- replace “2048” with “10240”) to be satisfactory for my machines, but if you happen to be a kernel developer, you might want to bump that up even further.

Following the edit of the ubiquity file, you simply select “Install Ubuntu” from the desktop icon and proceed with the normal ZFS install.


Okay, that’s the gist of the bpool problem, along with a couple of suggestions for clawing back some disk space and the most drastic way of fixing the issue.

In the second part of this series, we’ll be looking at a couple of more reasonable methods of fixing existing installations without resorting to a full re-install (fair warning though — it will still involve booting from the install media, so is not entirely without risk).

And don’t forget …back up early and back up often!


FUZIX (Unix-like OS) ported to the ESP8266

Well here’s some really interesting news. I have a job set-up to update “interesting” GitHub projects to local disk on a daily basis, so I can just do a quick listing every morning to see what, if anything, has changed. This morning the FUZIX project flagged changes (FUZIX is a minimal, unix-like OS for very small, resource-limited micros, which started off being targeted at the Z80 series). When I checked the repository to see what the updates actually were, I found:-

drwxrwxr-x 10 gaijin gaijin 20 Feb 18 05:38 ..
-rw-rw-r-- 1 gaijin gaijin 11536 Feb 18 05:38 Makefile
-rw-rw-r-- 1 gaijin gaijin 273 Feb 18 05:38 .gitignore
-rw-rw-r-- 1 gaijin gaijin 35670 Feb 18 05:38 filesys.c
-rw-rw-r-- 1 gaijin gaijin 252 Feb 18 05:38 dep.mk
drwxrwxr-x 2 gaijin gaijin 6 Feb 18 05:38 cpu-armm0
drwxrwxr-x 2 gaijin gaijin 24 Feb 18 05:38 platform-esp8266

Which led, in turn, to David Given’s marathon videos (there are roughly 30-hours of keyboard-bashing and puzzling-out-loud available right now, with another five videos still to be released on a daily basis) detailing his work to port FUZIX to the ESP8266. David’s web site has some further explanation of how far along the port currently is, along with some pre-compiled, loadable binaries for the ESP8266 (I haven’t had time to try them yet). All of David’s work is available from his GitHub repository.

You will need to attach an SD card to get the full FUZIX experience, but David says it is reasonably speedy on the ESP8266, with a boot time of just 4 seconds.

|�l�c|����{���B�p�n�dNn���cp��cl r$p�N�s����cN�|����B�|�N�l��l�Nl�d Nr���N��{$�o�nod���no��rdp�n���l"o�|����p��no�$�$�no$�{$or���o� �n�2NNl��|�N��lp�N��d�#n�|���b��Nn�d�l �oo$�{lor���N$�$sےNl��FUZIX version 0.4pre1
 Copyright (c) 1988-2002 by H.F.Bower, D.Braun, S.Nitschke, H.Peraza
 Copyright (c) 1997-2001 by Arcady Schekochikhin, Adriano C. R. da Cunha
 Copyright (c) 2013-2015 Will Sowerbutts will@sowerbutts.com
 Copyright (c) 2014-2020 Alan Cox alan@etchedpixels.co.uk
 Devboot
 80kB total RAM, 64kB available to processes (15 processes max)
 Enabling interrupts … ok.
 Scanning flash: 2591kB: hda: 
 SD drive 0: hdb: hdb1 hdb2 
 Mounting root fs (root_dev=18, ro): warning: mounting dirty file system, forcing r/o.
 OK
 Starting /init
 init version 0.9.0ac#1
 fsck-fuzix: 
 
 login: root
 Welcome to FUZIX.

David notes in the README (contained in the binary tar-file) that the system does have some limitations; first and foremost is that it is almost unusable running from flash, so you really do need to wire up an SD card (pinouts for this are included in the same README). Here is his ToDo list:-

  • userland binaries can’t find their error messages.
  • CPU exceptions should be mapped to signals.
  • single-tasking mode should be switched off (which would allow pipes to work).
  • someone needs to overhaul the SD SPI code who understands it.
  • not all the ROM routines are hooked up to userland binaries.

Right, I’m off to look for an SD card and a spare ESP. See you later!

Will it mirror?

Pic of (old) Laptop with SSD attached to lid

Here’s another silly one for you. What do you do if the latest release of your OS of choice ships with ZFS, but you don’t have space in your laptop for a second disk? …Answer:- Reach for the velcro.

This Sony Vaio has a Centrino Core-2 p8600 processor, so it’s not going to break any speed records, but it works well enough for day to day use. Courtesy of the Buffalo 500GB SSD taped to the lid, it now sports 1TB of disk space (500GB mirrored), which is probably well in excess of what the designers originally envisaged.

Centrino.2 sticker next to USB ports

This is one of those little “because I can” projects which I don’t necessarily recommend to anyone else, but at the same time, the lightness of an SSD compared to a normal hard-disk (even a 2.5″ one) means this is now an eminently practical solution if your old laptop happens to be running out of space (I do move the laptop around the house to work in different rooms at different times, but it generally doesn’t travel much further afield than a deck-chair out on the veranda).

So, will it mirror? Heck yes!

Should I mirror?

No, probably not. It’s much more sensible to use a periodic ZFS send/receive job to back up your work to an existing server, that way you don’t need to worry about the extra drain on your battery and you still have your work if your laptop is stolen or knocked off the deck of your yacht, mid-ocean (what, you mean that’s never happened to you?).

One other consideration when thinking about installing Ubuntu on ZFS — currently (as of 21.04) Ubuntu will not allow you to edit the size of the disk partitions; you must accept their optimized defaults. Unfortunately , those defaults include a /boot partition which is much too small (typically 2GB). It will work fine for a couple of months, but with every apt update, the system will automatically add a snapshot of the boot partition. When the upgrade includes a kernel update, this means that tens, or even hundreds of megabytes of storage can be used. Even when you set the system defaults to compress the kernels using “xz”, it doesn’t take too many updates before you start getting “not enough free space” messages from apt and it will refuse to continue with the update. This is not something a novice user can easily recover from (hint: deleting files on a ZFS partition doesn’t always return that free space to the system — it all depends on whether it is still being held by a snapshot).