ZFS on Linux: cannot destroy snapshot, dataset is busy

Originally, I used the following method to stop a busy dataset to enable me to export this dataset for a pool rebuild. I use a ZFS dataset for my /home directory and I was unable to find the process which kept it busy. Here's my solution which should work for you too, when you cannot find the process using your dataset:

  1. On all dataset(s) you wish to export (but had trouble exporting) set:

    zfs set canmount=noauto dataset1

zfs set canmount=noauto dataset2 ... and so on where you substitute your datasets' names for dataset1, dataset2, etc....

Setting canmount=noauto ensures that the dataset will not mount on reboot

  1. Make a user account (or use the root account) which doesn't use the dataset for /home etc... Give this account sudo privileges.

  2. Reboot and log into the above account, i.e. the account you just created in step 2. This account should boot up without mounting the datasets you modified in step 1 and therefore, deny those datasets to any daemons/programs.

  3. Since the datasets are now not busy, you can now destroy them and/or their snapshots.

  4. Be sure to:

    zfs set canmount=on datasetx

(where datasetx is your dataset in question) to any datasets that you want to mount on boot. This is the zfs default. Best, Phil