5

I'm trying to delete a bunch of old ZFS snapshots but I get errors saying that the datasets are busy:

[root@pool-01 ~]# zfs list -t snapshot -o name -S creation | grep ^pool/nfs/public/mydir | xargs -n 1 zfs destroy -vr
will destroy pool/nfs/public/mydir@autosnap_2019-02-24_03:13:17_hourly
will reclaim 408M
cannot destroy snapshot pool/nfs/public/mydir@autosnap_2019-02-24_03:13:17_hourly: dataset is busy
will destroy pool/nfs/public/mydir@autosnap_2019-02-24_02:13:17_hourly
will reclaim 409M
 cannot destroy snapshot pool/nfs/public/mydir@autosnap_2019-02-24_02:13:17_hourly: dataset is busy
will destroy pool/nfs/public/mydir@autosnap_2019-02-24_01:13:18_hourly will reclaim 394M

Running lsof shows no processes accessing these snapshots:

[root@pool-01 ~]# lsof | grep pool/nfs/public/mydir

There also appears to be no holds on any of the snapshots:

[root@pool-01 ~]# zfs holds pool/nfs/public/mydir@autosnap_2019-02-24_03:13:17_hourly
NAME                                                              TAG  TIMESTAMP

Is there anything else I should look out for? Anything else I can do besides a reoot?

2

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

| improve this answer | |
1

This appears to be unintended behavior on ZoL, I left the ZFS box alone for a few days and finally gave up and rebooted the said box, and I was able to destroy those snapshots after reboot.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.