Migrating A ZPool To A Smaller Disk

A week ago, I’ve migrated my gateway to a standalone machine running FreeBSD 13.1. The whole process was certainly flawless and soon enough it was forwarding packets to and from my network. Quite happy with the result, I didn’t expect it to crash less than 2 days after its first production hour. At first I thought it could have been the temperature, the graphic card, the memory… until it crashed again a couple of days after and I saw this:

Boot an Existing ZFS From a FreeBSD LiveCD

Because I ran gpart bootcode on the wrong partition of every replacement disk I swapped and because my motherboard is incapable of finding an EFI partition, I basically bricked my FreeBSD NAS / gateway. It took me a ridiculous amount of time in order to find how to boot into an existing ZFS FreeBSD installation from a FreeBSD LiveCD (I used mini-memstick). Finally, in a 2014 thread from the FreeBSD questions mailing list, someone mentioned the magic invocation, and from there I deducted the remaining parts.

Replacing a (silently) failing disk in a ZFS pool

Maybe I can’t read, but I have the feeling that official documentations explain every single corner case for a given tool, except the one you will actually need. My today’s struggle: replacing a disk within a FreeBSD ZFS pool. What? there’s a shitton of docs on this topic! Are you stupid? I don’t know, maybe. Yet none covered the process in a simple, straight and complete manner. Here’s the story:

Migrate FreeBSD root on UFS to ZFS

At ${DAYJOB} I’m using a FreeBSD workstation for quite a while. Everything goes smoothly except for the filesystem. When I first installed it, I chose UFS because FreeBSD installer said that root-on-ZFS was “experimental”. I later learned that nobody uses UFS anymore and that root-on-ZFS is perfectly stable. Thing is, I chose UFS and I deeply regret it. Not because of ZFS’s features that absolutely do not matter for me on the desktop, but because FreeBSD implementation of UFS is terribly, terribly slow when it comes to manipulate big files.


Au boulot, j’ai mis en place un NAS. À force de lire les louanges de ZFS, je me suis dit que c’était l’occasion idéale d’utiliser réellement ses capacités, et plus simplement comme “le filesystem de Solaris/OpenSolaris”. Nous sommes partis de l’hypothèse suivante : Nous utiliserons les fonctions RAID de ZFS, et non pas le RAID5 natif fourni par le controlleur du serveur de disques; en effet, après moult lectures, il apparait que le mode RAID-Z de ZFS est non seulement plus flexible, plus rapide, mais également plus sur (voir par exemple ici ou ici) La partition de boot/root fonctionnera, elle, en mode mirror et sera disponible sur tous les disques Le reste de la place disponible formera un pool raidz.