6

zfs pool imported automatically on boot in Ubuntu 18.10

Updated to 20.04, pool no longer imported on boot - I don't see any errors anywhere, but might be missing something.

sudo zpool import pool -- Works, fine. Files are all there, no issues.

zpool update shows no updates required.
zpool status shows everything is ok.

/etc/default/zfs :: (cut most, but I think the important question is answered below)

# Run zfs mount -a during system start?

ZFS_MOUNT='yes'

# Run zfs unmount -a during system stop?

ZFS_UNMOUNT='yes'

Mount is to a specific location with the same name as the pool, so if I were running zpool import pool the mount location would be: /pool

/ is an ext4 volume on an ssd. So the system boots and operates fine outside of mounting the zfs volume.

I am fully up to date on apt update etc. Really kind of at a dead stop, not sure what to look at?

scot
  • 71

3 Answers3

1

In my case, ZFS was failing to import a zpool because it was on a cloud persistent volume that was not physically attached to the machine. I guess network volumes become available later than expected in the bootup process.

Running systemctl status zfs-import-cache.service after boot gave the following message:

● zfs-import-cache.service - Import ZFS pools by cache file
     Loaded: loaded (/lib/systemd/system/zfs-import-cache.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2021-09-07 18:37:28 UTC; 3 months 17 days ago
       Docs: man:zpool(8)
    Process: 780 ExecStart=/sbin/zpool import -c /etc/zfs/zpool.cache -aN (code=exited, status=1/FAILURE)
   Main PID: 780 (code=exited, status=1/FAILURE)

Sep 07 18:37:26 ingress-zfs-2 systemd[1]: Starting Import ZFS pools by cache file... Sep 07 18:37:28 ingress-zfs-2 zpool[780]: cannot import 'data': no such pool or dataset Sep 07 18:37:28 ingress-zfs-2 zpool[780]: Destroy and re-create the pool from Sep 07 18:37:28 ingress-zfs-2 zpool[780]: a backup source. Sep 07 18:37:28 ingress-zfs-2 systemd[1]: zfs-import-cache.service: Main process exited, code=exited, status=1/FAILURE Sep 07 18:37:28 ingress-zfs-2 systemd[1]: zfs-import-cache.service: Failed with result 'exit-code'. Sep 07 18:37:28 ingress-zfs-2 systemd[1]: Failed to start Import ZFS pools by cache file.

The solution was to patch the zfs-import-cache.service service file to include the remote-fs.target dependency:

[Unit]
...
After=remote-fs.target
...

On Ubuntu 20.04, this file was located at: /etc/systemd/system/zfs-import.target.wants/zfs-import-cache.service.

I think specifying After=remote-fs.target is equivalent to using the _netdev option in an /etc/fstab file (see: https://unix.stackexchange.com/a/226453/78327).

ostrokach
  • 864
1

Ubuntu 20.04 here. I had problems about mount ordering. I got it working by following the instructions here:

https://openzfs.github.io/openzfs-docs/Getting%20Started/Ubuntu/Ubuntu%2020.04%20Root%20on%20ZFS.html

  1. Filesystem mount ordering
mkdir /etc/zfs/zfs-list.cache
touch /etc/zfs/zfs-list.cache/mypool
ln -s /usr/lib/zfs-linux/zed.d/history_event-zfs-list-cacher.sh /etc/zfs/zed.d

zfs set canmount=on mypool

After reboot the mount order is correct and I can bind mount directories from the ZFS volume.

Manel Clos
  • 111
  • 2
0

Here are some more suggestions.

Try adding the pool to the ZFS cache file:

sudo zpool set cachefile=/etc/zfs/zpool.cache pool

Make sure the ZFS service is enabled:

sudo systemctl enable zfs.target

Also make sure ZFS import cache service is enabled:

sudo systemctl enable zfs-import-cache.service

I can confirm that my own ZFS pool is imported via the /etc/zfs/zpool.cache file on bootup.

Let me know if this works for you.

Artur Meinild
  • 31,035