Linux Mint 19.3 installation with ZFS root


abstract: Bleeding edge Linux releases (Ubuntu 19, for example) now provide a mechanism to install the operating system on a ZFS root filesystem. This is quite useful for installing the OS on a laptop with a single drive and still be able to take advantage of many ZFS benefits, like compression and encryption, but many prefer the comfort of long term support (LTS) versions. This how-to goes through the steps of installing one such Linux distribution with a boot / root ZFS file system, with encryption and compression. See also the ZFS survival guide.

Linux Mint

I'm a big fan of Linux Mint Mate as a desktop operating system. It has a fairly clean look, and once I do a few tweaks to the UI, it replicates to some extent my user experience in OpenSolaris. It is running a Linux kernel (5.0 as of this writing) and is based on Ubuntu / Debian. And it can use OpenZFS, but we will have to do a bit of extra work because we not only want ZFS support (ie. creating new pools of storage on unallocated devices), but we want to install the OS to ZFS and use compression and encryption. The later requires zfs-0.8.3 that was just released 2 weeks ago in a PPA.

To find out a bit more about the latest version of Mint, we can check the os-release file:

$ cat /etc/os-release
NAME="Linux Mint"
VERSION="19.3 (Tricia)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 19.3"
VERSION_ID="19.3"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.ubuntu.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=tricia
UBUNTU_CODENAME=bionic

os-release tells us it is based on Ubuntu Bionic, aka the long term support (LTS) version of  Ubuntu 18 (https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes).  This is advantageous if we run Ubuntu 18.04 LTS on the server side, as the command line experience will be the same.

The 19.3 release can be downloaded from:


I'll be using the 64 bits Mate live image in this how-to and I've not tested any of the other versions. Once you download the iso, verify the integrity of the file (see https://linuxmint.com/verify.php), and either burn it on a DVD if your computer has one, or use UNetBootin to install the image on a USB key.

Warning: This install procedure is completely destructive, meaning that if you have any data you need on the computer you are installing this on, make a full backup. The installer will destroy the partitions and create brand new partitions. Once this is done, there is no undoing. You have been warned.

BIOS

Before we go any further, the path we will take will require a machine that has a modern BIOS. A BIOS (Basic Input Output System) is a collection of routines that allow low level communication between programs and components of a computer. There are two modes of operations in modern computers, a Legacy BIOS mode, and a UEFI mode. We need UEFI. For this, you will need to know what key(s) to press to invoke the BIOS configuration screen when you turn on your computer (usually an F-key, like F2 or F10) and navigate to the screen where you can configure the boot mode. Set UEFI boot to enabled, and legacy boot to disabled. Something like:


Make sure the DVD drive or USB "hard disk" (USB key) is at the top of the devices as far as boot order goes. If you are installing in a virtual environment like VirtualBox, enable EFI and select the ISO for the optical drive.

zfs-installer


The Linux Mint live image boots to a live desktop. There is an icon to install it, but we won't be able to use it, as it doesn't know anything about ZFS. To get around this, we will use a very neat installer script that does the heavy lifting for us, found at: https://github.com/saveriomiroddi/zfs-installer

NOTE: current main branch is working with Mint 19.3. The pull request to fix it was merged. [May 19, 2020]

We will need to take a few steps before invoking it, however. For one thing, you need to connect to a network. If you are connected to a wired network with DHCP, that's already taken care of, else connect to your wireless network.

Next, open a terminal (click the terminal icon on the bottom left):



mint@mint:~$ cd /etc/apt
mint@mint:/etc/apt$ cat sources.list
#/etc/apt/sources.list

deb cdrom:[Linux Mint 19.3 _Tricia_ - Release amd64 20191216]/ bionic contrib main non-free



If you have this deb cdrom: line, edit the file (with nano or vi) and delete the line:

mint@mint:/etc/apt$ sudo vi sources.list
mint@mint:/etc/apt$ cat sources.list
#/etc/apt/sources.list

Note: Leaving the line in will cause an error in the installation, complaining about the repository not having a Release file, and you'll have to start all over again.

The other preliminary step that we need to complete is the installation of zfs-zed. The installation script assumes we have it already. To install it:


mint@mint:/etc/apt$ sudo apt install zfs-zed -y
Reading package lists... Done
...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
mint@mint:/etc/apt$


We are now ready to run the installer: As per the instructions on https://github.com/saveriomiroddi/zfs-installer, you start it with the following.

mint@mint:/etc/apt$ GET https://git.io/JelI5 | sudo bash -


If you don't feel comfortable piping a strange URL to sudo bash, you can verify that the URL pulls the installer script, or wget the script (from https://raw.githubusercontent.com/saveriomiroddi/zfs-installer/stable/install-zfs.sh) and then execute it with sudo.

Once the script starts, you should see:



On the next screen, you will be able to select which drive is going to be wiped clean and used for the boot and root file systems. There is also an opportunity to create a mirror by selecting 2 devices of equal size (see the ZFS survival guide if you want to understand the advantages and disadvantages of using multiple devices). Mirroring is perfect if you happen to have a laptop with two NVME devices. If you do, you can select both devices.

Next, you will be asked if you want to encrypt the root pool. Most likely, the reason you are reading this post is because you want an encrypted root pool, so in that case select yes. If you do, you will get to this screen next:


Now, let me be very clear: IF YOU FORGET THE PASSPHRASE, YOU WILL NOT BE ABLE TO RECOVER ANYTHING ON YOUR COMPUTER. 

Make sure you use something you can remember. You will need to type this every time you power on and boot your computer. The next screen will ask to confirm this passphrase.

Next screen asks for the swap size, in GB. You can set it to the same size as your RAM (see my article on memory for more details and reasoning on the sizing).

Next screen asks about how much space to leave at the end of the disk. You can type 0, unless you want to create a non ZFS partition later on.

The next two screen will ask for the boot and root pool names. Accept the default values.

Following this, you will be asked about the ZFS options you would like for the boot pool (default is ok):


and for the root pool (default is ok, unless you do not want compression, for some reason):


If you need to disable compression, remove the -O compression=lz4.

After this, the script will run for a while:


Finally, the preinstall steps conclude with this screen:


This gives us the instructions to follow and especially which partition (/dev/zd16p1 in this case here) we will have to customize further down, when the actual Linux Mint installer launches:


Select the options you need until you get to this screen:


Select "Something else", instead of the default "Erase disk and install Linux Mint". In the next screen we will select the partition the installer screen gave us earlier (/dev/zd16p1 in my case) and click change, select use as EXT4, check format partition and mount point as /:


Continue with the Mint installation until you get to this screen:


Click on "Continue Testing", to let the post install part of the script do the final sync:


After a little while, you will get to the final screen:


It is now time to power off and power back on your computer. During the boot sequence, you will be asked for your passphrase, then you will be able to log on to the desktop. Opening a command line, we can see that there are now 2 ZFS pools:

user@mint:~$ sudo zpool list
NAME     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
bpool    480M  87.0M   393M        -         -     4%    18%  1.00x    ONLINE  -
rpool    464G  4.28G   460G        -         -     0%     0%  1.00x    ONLINE  -
user@mint:~$ 

You now have the full power and control that ZFS gives you over the whole storage of your computer, including your root filesystem. Your logs are now automatically and transparently compressed. Your whole OS install takes only 4GB. You can snapshot and rollback, etc.

Francois Dion
Chief Data Scientist
@f_dion

Comments

  1. Thank you for this guide! Now I have something that feels like the next version of my old OpenIndiana desktop.

    ReplyDelete
  2. will this work on linux mint 20

    ReplyDelete
    Replies
    1. It should now work, current github version has [Linuxmint]="20" in the check.

      Delete
    2. Also, it is no longer required to install zfs-zed on Mint 20 with the latest version of the script (December 2020) making the installation simpler

      Delete
  3. Thanks for your clear desciption! Everything worked like a charm. However, I run into a problem. I have install linux mint 20, and everything was working perfectly fine. But then you need to upgrade to linux mint 20.1. I also did this and the upgraded run find and ended with the message everything was succeeded. The problem occurs with rebooting: after a reboot I get the following message after selecting Linux Mint 20.1 in the grub menu:

    error: file `ROOT' not found.
    error: you need to load the kernel first.

    That's it, I cannot boot the system anymore.

    Do you have any idea if this is easily fixable ?

    ReplyDelete
    Replies
    1. I don't know that it supports 20.1 or upgrades like that.

      You should enter an issue here:
      https://github.com/saveriomiroddi/zfs-installer/issues

      or post your question on the github discussion for the script:
      https://github.com/saveriomiroddi/zfs-installer/discussions


      Delete
  4. Thanks for you reply. Most likely it is because when upgrading to a new Mint version, the re-installation is done by the native installer of Mint, and not by your script, and the native installer of Mint does not know anything about zfs. After the upgrade is done, you should most likely do some of your post-install steps as described above, but I don't know how to do that. My conclusion was that it was better for me to move to a Linux distribution with native support for ZFS, so I installed Ubuntu. It is very similar to Mint, has build in support for ZFS and therefor I think it is a better choice if you want to use ZFS unless you know exactly how to handle this kind of issues I ran into after upgrading. Perhaps your description should add a disclaimer that you cannot use the Mint upgrade option.

    ReplyDelete

Post a Comment