3 Replies Latest reply on Aug 31, 2012 11:53 AM by Darren Moffat-Oracle

    zfs destroy DOES NOT CHECK NFS mount file-systems

    Andrew Watkins
      I asked this question twitter once and the answer was a good one, but I did some checking today and was surprised!!

      # zfs destroy mypool/home/andrew

      The above command will destroy this file-system no questioned asked but if the file-system is mounted you will get back the Device busy and if you have snapshot then they will be protected as well

      server# zfs destroy mypool/home/andrew
      cannot unmount 'tank/home/andrew

      server# zfs destroy dpool/staff/margaret
      cannot destroy 'dpool/staff/margaret': filesystem has children
      use '-r' to destroy the following datasets:


      server# zfs destroy dpool/staff/margaret@Wed18
      server# zfs destroy dpool/staff/margaret@Wed22

      NFSclient# cd /home/margaret
      NFSlient# ls -l
      drwx------+ 2 margaret staff 2 Aug 29 17:06 Mail
      lrwxrwxrwx 1 margaret staff 4 Aug 29 17:06 mail -> Mail
      drwx--x--x+ 2 margaret staff 2 Aug 29 17:06 public_www

      server# zfs destroy dpool/staff/margaret


      I will file a bug report to see what Oracle say!

      I think there should be a hold/protect of file-systems
      # zfs hold dpool/staff/margaret

        • 1. Re: zfs destroy DOES NOT CHECK NFS mount file-systems
          The CR is already filed:

          6947584 zfs destroy should be recoverable or prevented

          The zfs.1m man page, which covers the mounted case and the ZFS admin guide are pretty clear
          about the current zfs destroy behavior.

          Caution - No confirmation prompt appears with the destroy subcommand. Use it with extreme caution.

          zfs destroy [-rRf] filesystem|volume

          Destroys the given dataset. By default, the command
          unshares any file systems that are currently shared,
          unmounts any file systems that are currently mounted,
          and refuses to destroy a dataset that has active depen-
          dents (children or clones).

          I'm sorry that you were surprised.

          Accidents happen too, like destroying the wrong file system, so always have good backups.

          Thanks, Cindy
          • 2. Re: zfs destroy DOES NOT CHECK NFS mount file-systems
            Andrew Watkins
            Thanks for that.

            It makes me a little happier that there is a CR for it. I know we have to be careful when deleting things, but Sys Admins do make errors and I am just thinking ahead when it may be next time ;-)

            Thanks, as always,

            • 3. Re: zfs destroy DOES NOT CHECK NFS mount file-systems
              Darren Moffat-Oracle
              Try this proceedure:

              Create the dataset and then imediately create a snapshot and hold it.
              zfs create builds/foo
              zfs snapshot builds/foo@initial
              zfs hold initial builds/foo@initial

              Now later create some snapshots

              zfs snapshot builds/foo@1
              zfs snapshot builds/foo@2

              Try a delete:

              zfs destroy -r builds/foo
              zfs destroy -Rr builds/foo

              This will fail to delete the dataset. Now when you really do want to delete it:

              zfs release initial builds/foo@initial
              zfs destroy -r builds/foo