zfs - two pools with nested mountpoints and conflicting mount order
I have a problem with automounting separate pools, that have nested mountpoints. I am using ZfsOnLinux 0.6.2.
The siuation currently is as follows:
zpool1 ---> /var
zpool1/log ---> /var/log
zpool1/mail ---> /var/mail
Now I need to add a separate zpool for db. To keep directory hierarchy consistent, I thought about this:
zpool2 ---> /var/db
Now, the problem is that when zpool2 is mounted first, zpool1 fails to mount (this is logical).
Is there a way I can force the mount order of pools to allow mounting of zpool2 inside zpool1, besides using the legacy mount option? Something like zpools dependency? Or should I avoid such nested mounts at all costs?
Solution 1:
Instead of mounting zpool2
as /var/db
, mount it as /zpool2
or /db
or whatever makes sense for you.
Then make /var/db
a symlink to /db
.
Solution 2:
You can set the file system mountpoint properties to legacy
and use /etc/fstab
to define them.
That way, you'll be able to define the order in which they will be mounted.
Edit: I just noticed you already considered the legacy approach. It might be the only one though.
Solution 3:
Within the same pool, the composition of mount paths determines the mount order. Within one pool, Zfs sorts the file systems to be mounted by their respective mount point paths, which guarantees the correct mount order.
When there are 2 or more pools involved, there is no similar facility to automatically impose the mount order between the pools.
In other words, Zfs has a built-in mechanism that makes sure that any mount-point composition will cause the fs-s to get mounted in the correct order, but it has no similar facility to make this guarantee when multiple pools are involved.
If pool2 has a file system that is set up to mount on a mount point that is made available by mounting an fs in pool1 first, it is on the admin to make sure that pool1 is indeed mounted first. E.g.: It has to be scripted. So the answer is "do not expect this to sort itself out".