With a ZFS root install, which partitions need to be `canmount=noauto` and why?

Stonecraft asked:

With a ZFS root install, which partitions need to be canmount=noauto and why?

I am looking at a fresh installation of Ubuntu 20.04 with ZFS on root. I am using these instructions on the openzfs site, but there is one thing that I don’t get which is bugging me.

from the guide:

3.2 Create filesystem datasets for the root and boot filesystems:

zfs create -o canmount=noauto -o mountpoint=/ rpool/ROOT/ubuntu
zfs mount rpool/ROOT/ubuntu

zfs create -o canmount=noauto -o mountpoint=/boot bpool/BOOT/ubuntu
zfs mount bpool/BOOT/ubuntu

With ZFS, it is not normally necessary
to use a mount command (either mount or zfs mount). This situation is
an exception because of canmount=noauto.

I understand that the noauto means that fstab or a mount command is needed to mount the volumes. but I don’t get why it is necessary/recommended for some datasets but not others. Can someone help me understand that?

My answer:

The tutorial itself explains why this was done for /boot:

Until there is support for mounting /boot in the initramfs, we also need to mount that, because it was marked canmount=noauto. Also, with UEFI, we need to ensure it is mounted before its child filesystem /boot/efi.

Thus it instructs you to configure an /etc/fstab entry.

In general you as an admin would set canmount=noauto when you want a dataset to be mountable but not mounted automatically when the zpool is imported. For example, a zpool containing a backup is a good use case for this.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.