ZFS What happens when the data sets of two pools are mounted to the same mountpoint?

Hello everyone,

I test sending and receiving with 2 computers, and test as follows:

pool: zroot on Host1
pools: zroot, testpool on Host2

On host1
zfs snapshot -r zroot@snap
zfs send -Rv zroot@snap | ssh host2 zfs receive -dvF testpool

Then the testpool and zroot datasets on host2 are mounted to the same mountpoint, Is there a problem with this?

Code:
NAME            USED    AVAIL    REFER    MOUNTPOINT
testpool                                /zroot
testpool/ROOT                            none
testpool/ROOT/default                    /
testpool/tmp                            /tmp
...
zroot                                    /zroot
zroot/ROOT                                none
zroot/ROOT/default                        /
zroot/tmp                                /tmp
...


Thanks.
 
Yes there is a problem, the datasets of the more recently imported pool or more recently created datasets on the receiving side would be mounted over the existing directories. To avoid the problem with for example a backup pool that receives datasets that would conflict with your running system you can import the backup pool with the -R (altroot) option:

# zpool import -R /mnt zbackup

This would make all the mountpoints of datasets in the zbackup pool relative to /mnt.
 
Thank you. Is it necessary to change their mountpoints?
Because I found that even though the mount point of the testpool is the same as the zroot, the contents of the datasets are not displayed on the corresponding mountpoints.
 
Don't touch the mountpoints themselves, the altroot property will make sure there are no conflicts when the destination pool is attached to the system. You just need to be very careful when importing the destination pool and remember to use the -R /path option every time.
 
If you send|recv for backup purposes, you might want to set the "canmount=noauto" (or even off) and "readonly=on" properties at the receiving side to protect the datasets from being mounted and/or modified.

If both values are inherited at the sending side, it is enough to set both properties at a parent dataset or for the whole pool on the receiving side.
 
Back
Top