Solved Proper usage of zfs recv -u -o canmount=noauto for emergency backup?

I'm trying to back up the host to a spare drive on the same machine using zfs send|zfs recv and am having trouble setting canmount=noauto on the recv side.

I have tried -o canmount=noauto and -o canmount=off and -x canmount while receiving the snapshot, but the canmount properties on the new datasets don't seem to be correct:

Code:
root@venus:/ # zfs send -c -v -R zroot@20241102_clone | zfs recv -u -o canmount=noauto backup/`hostname -s`
root@venus:/ # zfs send -c -v -R zroot@20241102_clone | zfs recv -u -x canmount        backup/`hostname -s`
root@venus:/ # zfs send -c -v -R zroot@20241102_clone | zfs recv -u -o canmount=off    backup/`hostname -s`

ccammack@venus:~ $ zfs get -r canmount backup | head -10
NAME                                                                                                     PROPERTY  VALUE     SOURCE
backup                                                                                                   canmount  on        local
backup/reserved                                                                                          canmount  noauto    local
backup/venus                                                                                             canmount  on        default
backup/venus@syncoid_salus.ccammack.com_2024-11-01:06:46:55-GMT-04:00                                    canmount  -         -
backup/venus@20241102_clone                                                                              canmount  -         -
backup/venus/iocage                                                                                      canmount  on        default
backup/venus/iocage@syncoid_salus.ccammack.com_2024-11-01:06:58:37-GMT-04:00                             canmount  -         -
backup/venus/iocage@20241102_clone                                                                       canmount  -         -
backup/venus/iocage/jails                                                                                canmount  on        default

The -u option seems to work as expected:

Code:
ccammack@venus:~ $ mount | grep backup
backup on /backup (zfs, local, nfsv4acls)

The current transfer is still in progress. Will those canmount properties be corrected at the end, or do I need to fix them with a script afterwards?

If you needed to quickly clone a machine onto a fresh drive before going on vacation, how would you do it?
 
Okay, I've run the process a few times and I think I understand now.

zfs send -R says: When received, all properties...are preserved.

That seems to take priority over anything that zfs recv -o does later in the pipeline.

Is it common practice to iterate the copied datasets and fix them afterwards to prevent them from mounting over the system on the next import?

zfs list -o name | grep ^backup/ | xargs -n1 zfs set canmount=off
 
Back
Top