Zfs dataset home folder mounting

I’m wondering how to understand the mounting of the zfs datasets for the home folder. I’ve tried a few ways, and I’m currious how other have had the most success, and how different it is when using encryption in one way or another.

I’ve tried this a few ways.

In a laptop I had, my zfs dataset with the home dir was encrypted, and not automounting. I didn’t want to store a key somewhere on the drive, since the rest of install wasn’t encrypted. I wasn’t able to do Full Disk encryptions on that one. So, before I would log into the desktop environment, I would enter the shell, mount the zfs dataset, log out, then log into the DE.

On my current PC, I DO have full disk, and need to enter my key before the OS boots. But I don’t believe I have any zfs encryption on the home dataset, because of that.
But I was worried about what happened if I for some reason the dataset couldn’t mount (or I forget to decypt the zfs dataset on the laptop mentioned above). So I did NOT mount it /home/myuser, but instead /home/myuserzfs. Then, I changed my home directory location after creating my user account. This means, that both directories are available, but one is just part of the root partition. However, som applications seem to ignore what I’ve set as the user’s home dir, unlike the bash ~, it will user /home/myuser instead of the /home/myuserzfs that bash uses.

It seems like changing the home folder location is not as common, based on instructions on the internet. I think most of the posts I’ve seen just mount over the existing /home/myuser. So, if zfs isn’t mounted, I get all the defaults from when the user was first created. I guess I’m a little uncomfortable with that approach. I think becuase it seems a little strange to have data hidden by the mounting of zfs. I don’t think I’m worried, but I don’t understand the technical details of that, at lesat not entirely, so it makes me hesitant. For instance, If I had a hug 500 GB file in my /home/myuser/Downloads, then I mount over that with a zfs dataset. Is that a problem for the OS? (I realize that’s off-topic.) Mostly I just want to know if that’s really the best practice to mount the dataset over the existing home/$USER location.

What I usually do on my desktop Ubuntu systems (which aren’t ZFS on root) is this:

  • install system
  • boot into system, pop shell, install the ZFS stuff
  • zfs create poolname/home ; zfs create poolname/home/myname
  • rsync -ha /home/myname/ /poolname/home/myname
  • mv /home/myname /home/myname-dist
  • zfs set mountpoint=/home/myname poolname/home/myname

Now, log out and log back in, and you’ll be using your new ZFS-ified home directory. Once you’re satisfied everything works, rm -r /home/myname-dist and you’re good to go. If your pool fails to import or this specific dataset fails to mount, you’ll get an “amnesiac” login with no home directory contents at all, instead of a “whatever this looked like several years ago and I just hope I notice the change” like you’d get if you hadn’t renamed and then removed the original ext4 homedir.