It appears that `zfs send -R <root-dataset-snapshot> | zfs receive -Fdu <external-media-dataset>` will mount the received dataset despite the -u flag. I discovered this sending the root partition having mountpoint=/ which broke devfs. Below is a session done in a clean new (KVM) VM install with two disks to replicate the issue: root@freebsd:~ # zpool status pool: zroot state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM zroot ONLINE 0 0 0 vtbd0p2 ONLINE 0 0 0 errors: No known data errors root@freebsd:~ # zpool list NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT zroot 3.97G 830M 3.16G - 13% 20% 1.00x ONLINE - root@freebsd:~ # zfs list NAME USED AVAIL REFER MOUNTPOINT zroot 830M 3.03G 829M / root@freebsd:~ # zpool list -t snapshot NAME USED AVAIL REFER MOUNTPOINT zroot@test-snapshot 496K - 829M - root@freebsd:~ # zpool create zbackup vtbd1 root@freebsd:~ # zfs create zbackup/backup root@freebsd:~ # zfs list NAME USED AVAIL REFER MOUNTPOINT zbackup 250K 3.84G 19K /zbackup zbackup/backup 19K 3.84G 19K /zbackup/backup zroot 830M 3.03G 829M / root@freebsd:~ # zfs send -R zroot@test-snapshot | zfs receive -Fdu zbackup/backup root@freebsd:~ # zfs list internal error: failed to initialize ZFS library root@freebsd:~ # mount zroot on / (zfs, local, nfsv4acls) devfs on /dev (devfs, local, multilabel) zbackup on /zbackup (zfs, local, nfsv4acls) zbackup/backup on / (zfs, local, nfsv4acls) root@freebsd:~ # mount -t devfs devfs /dev root@freebsd:~ # zfs list NAME USED AVAIL REFER MOUNTPOINT zbackup 829M 3.03G 19K /zbackup zbackup/backup 829M 3.03G 829M / zroot 830M 3.03G 829M / root@freebsd:~ # zfs mount zroot / zbackup /zbackup zbackup/backup / root@freebsd:~ # zpool export zbackup cannot unmount '/': Device busy
I think that the received filesystem got mounted because it was received as zbackup/backup and zbackup/backup was mounted before. Still this is a bug, of course. But you can try to repeat the procedure with zbackup/backup unmounted before doing send | receive.
Yes, I just tried sending to imported but unmounted zbackup and indeed, it did not automount.
okay, so this must be the same issue as https://www.illumos.org/issues/6412
As suggested by Allan Jude on IRC, I tried sending to a nonexisting dataset and without the -d flag and it autocreated the receiving dataset but did not automount it. root@freebsd:~ # zfs mount zroot / zbackup /zbackup zbackup/backup /zbackup/backup root@freebsd:~ # zfs send zroot@test-snapshot | zfs receive -Fu zbackup/backup/foo root@freebsd:~ # zfs list NAME USED AVAIL REFER MOUNTPOINT zbackup 829M 3.03G 19K /zbackup zbackup/backup 829M 3.03G 19K /zbackup/backup zbackup/backup/foo 829M 3.03G 829M / zroot 898M 2.97G 897M / root@freebsd:~ # zfs mount zroot / zbackup /zbackup zbackup/backup /zbackup/backup
Created attachment 163360 [details] proposed patch for testing Please test the attached patch using your original procedure.
I tested it against r291085, the line numbers were different but I located the only place in the file where the code appears. It looks like that fixed it. Tried the procedure again and the dataset is not remounted with -Fdu onto existing dataset.
Thank you!
A commit references this bug: Author: avg Date: Sun Apr 3 07:40:34 UTC 2016 New revision: 297520 URL: https://svnweb.freebsd.org/changeset/base/297520 Log: zfs receive: -u can be ignored sometimes When force-receiving a filesystem that was already mounted the re-created filesystem is mounted despite -u flag. Also see https://www.illumos.org/issues/6412. PR: 204705 Tested by: Vladimir Krstulja <vlad-fbsd@acheronmedia.com> MFC after: 2 weeks X-Needs-Upstreaming: illumos Changes: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
A commit references this bug: Author: avg Date: Tue Apr 19 12:14:15 UTC 2016 New revision: 298264 URL: https://svnweb.freebsd.org/changeset/base/298264 Log: MFC r297520: zfs receive: -u can be ignored sometimes PR: 204705 Changes: _U stable/10/ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
A commit references this bug: Author: avg Date: Tue Apr 19 12:14:53 UTC 2016 New revision: 298265 URL: https://svnweb.freebsd.org/changeset/base/298265 Log: MFC r297520: zfs receive: -u can be ignored sometimes PR: 204705 Changes: _U stable/9/cddl/contrib/opensolaris/lib/libzfs/ stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c