I am running Ubuntu 18.04 with encrypted ZFS on /
and have now decided that I would like to make my /home
directory a separate dataset.
Initial Issue
As per Proper way to create a zfs off an existing directory? I created a new dataset with mount point at /home
.
# backup data
sudo mv /home /home-backup
# create empty dataset
sudo zfs create tank/ds1/home # you could already specify the mountpoint here.
# oops, I forgot to set the mountpoint so it is now /tank/ds1/home
sudo zfs set mountpoint=/home tank/ds1/home
# copy data to newly created dataset
sudo rsync -aAX /home-backup/ /home
After reboot I cannot login in the GUI anymore - entering the correct password just throws me back to the login screen. But that's not a big problem: In the Terminal that opens when I press CtrlAltF2 I can login and run sudo zfs mount tank/ds1/home
and after that, logging in in the GUI works fine. The problem is just that this dataset is not automatically mounted at boot.
Some advice in the arch wiki advises to use certain services, but I don't know if that also applies to my ubuntu and also I would like to only automount tank/ds1/home
(mountpoint /home
) and tank/ds1/u18
(mountpoint /
, is already automounted somehow) but not tank/ds1
(which only exists for hierarchical purposes) if that can be avoided.
Questions
- How can I automount my home directory dataset at boot?
"Solved". See the section Solution below. - Why is my root directory dataset automatically mounted at boot?
I'm happy that it is, but I am curious why. If it is within the scope of the first question, please answer this too. - Which datasets get auto-mounted by the zfs mount service?
The basis for this question is outlined in the section Remaining Question) below.
System Information
$ uname -a
Linux motorbrot 5.3.0-62-generic #56~18.04.1-Ubuntu SMP Wed Jun 24 16:07:03 UTC 2020 x86_64 x86_64 GNU/Linux
$ zfs version
zfs-0.8.4-1
zfs-kmod-0.8.4-1
Listing the zfs datasets right after booting (before temporarily fixing anything) shows the datasets and their mountpoints and they are as expected. Using zfs get all tank/ds1/home | grep mount
and similar commands shows that all are canmount on
but only tank/ds1/u18
is mounted (on /
).
My /etc/fstab
contains only my swap partition and my EXT2 /boot
partition.
My /etc/default/zfs
contains ZFS_MOUNT='yes'
but that seems to have no effect, since not all datasets are being mounted. That can perhaps be explained by the comment Changing some of these settings may not make any difference on systemd-based setup, e.g. setting ZFS_MOUNT=no will not prevent systemd from launching zfs-mount.service during boot.
.
$ systemctl list-unit-files | grep zfs
zfs-import.service generated
zfs-mount.service generated
zfs-share.service generated
zfs-zed.service masked
Solution
Following How can I make ZFS datasets mount automatically on boot I am informed that zfs.target
does not exist and that both zfs-import.service
and zfs-mount.service
are "not native services, redirecting to systemd-sysv-install".
After running these commands, the output of systemctl list-unit-files | grep zfs
is still the same. I would have expected the status to change to enabled
.
However, after a reboot the login works again - /tank/ds1/home
is mounted correctly to /home
.
Now that I am finding this question again, a year later, having the exact same problem with a new encrypted dataset, this "solution" is not helping anymore.
Remaining Question
The outputs of zfs get all DATASET | grep mount
show that tank
and tank/ds1
are not mounted after boot while tank/ds1/u18
and tank/ds1/home
are mounted on their respective mountpoints. That's great! But why are only those two automatically mounted? It's exactly as it should be, but I fail to see why it is behaving that way.
So what I am asking in the end is: Please explain to me how ubuntu decides which zfs datasets are automatically mounted during boot. How could I specify specific datasets to be automatically mounted?
How can I automount a specific encrypted dataset at boot?
0 Answers