How do you delete a dataset created by cloning a snapshot?

G3orgios

Cadet
Joined
Jun 2, 2020
Messages
6
After quite some searching and reading, i still cannot figure out how to get rid of a a dataset created by cloning a snapshot. The dataset is located at /mnt/Jails/iocage/jails-auto-20200525.1523-3m-clone and so far tried:
  • Checked dataset contents: ls -all --> empty (just “.” and “..”)
  • Delete (shell, root): rmdir jails-auto-20200525.1523-3m-clone --> Device busy
  • Unmount: zfs unmount -f jails-auto-20200525.1523-3m-clone --> dataset does not exist
  • Delete connected snapshot: obviously, this cannot be deleted since it is linked with the dataset. Error received: “libzfs.ZFSException: Cannot destroy Jails/iocage/jails@auto-20200525.1523-3m: snapshot has dependent clones”
So, what am I missing here for killing the dataset created by the cloned snapshot?

Thanks.
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,398
First, you have to zfs promote the clones to unlink them from this snapshot. Once all the clones are unlinked, you can then zfs destroy Jails/iocage/jails@auto-20200525.1523-3m.
 

guermantes

Patron
Joined
Sep 27, 2017
Messages
213
Why not just delete the dataset clone from the gui? That's what I always have done and i see no bad consequences.
If you promote you will change the original dataset and it will become a clone. How would that be of any help I don't understand. I recently had a mishap just like that.

I thought promoting was used when you want to delete the snapshot but keep the clone?
 

G3orgios

Cadet
Joined
Jun 2, 2020
Messages
6
Why not just delete the dataset clone from the gui? That's what I always have done and i see no bad consequences.

The dataset cannot be deleted, at all, from either GUI, Shell, SSH.
 

G3orgios

Cadet
Joined
Jun 2, 2020
Messages
6
First, you have to zfs promote the clones to unlink them from this snapshot. Once all the clones are unlinked, you can then zfs destroy Jails/iocage/jails@auto-20200525.1523-3m.
Thanks a lot!
 

guermantes

Patron
Joined
Sep 27, 2017
Messages
213
Maybe I am misreading the context, but what happened here? My own experience as well as the manual's recommendation suggest that G3orgios' dataset should have been deletable in the way I suggested. Why wasn't it?
To restore the data within a snapshot, the recommended steps are:
  1. Clone the desired snapshot.
  2. Share the clone with the share type or service running on the FreeNAS® system.
  3. After users have recovered the needed data, delete the clone in the Active Pools tab.
 

KenNashua

Explorer
Joined
Feb 24, 2012
Messages
62
I'm totally stuck here as well. I cloned a snapshot to recover a deleted file. The snapshot was an auto snapshot of the entire dataset.

There's no way in the GUI to destroy the dataset (that I can see)

1660616332599.png


If I try to destroy from the cli I get:
Code:
# zfs destroy  data/auto-20220814.0015-2w-clone
cannot destroy 'data/auto-20220814.0015-2w-clone': filesystem has children
use '-r' to destroy the following datasets:
data/auto-20220814.0015-2w-clone@auto-20220811.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220808.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220804.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220801.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220805.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220809.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220814.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220810.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220803.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220807.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220812.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220813.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220802.0015-2w
data/auto-20220814.0015-2w-clone@auto-20220806.0015-2w


If I use -r, it goes through and shows all the snapshots from the "data" dataset but at the end the data/auto-20220814... dataset is still there.
 

guermantes

Patron
Joined
Sep 27, 2017
Messages
213
I'm totally stuck here as well. I cloned a snapshot to recover a deleted file. The snapshot was an auto snapshot of the entire dataset.

There's no way in the GUI to destroy the dataset (that I can see)

View attachment 57712
@KenNashua Don't you have the three menu dots at the very right on every line for each dataset. Sort of under the cogwheel in your image. From there you can perform GUI operations on individual datasets, such as deleting clones.

I still don't understand why one would promote the dataset in this context. That seems as bad advice to me, if the purpose was to recover a single or a few files, as it overwrites the newer version from before the cloning with the older version of the snapshot. What if other files had changed?

@Samuel Tai Since you are more knowledgeable than I maybe you can chime in here and let me know what I am missing. Why was not the section from the manual I quoted earlier/above the correct manner to proceed?
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,398
@guermantes, your conception of promoting the clone is incorrect.

Let's say you have a dataset with snapshot:

tank/some-random-dataset
- snapshot

After a clone operation, you have

tank/some-random-data-clone <- this is linked via a parent-child relationship to tank/some-random-dataset by the cloning process
- snapshot-clone

To break the link between the clone copy, and the source dataset, you zfs promote the clone so it becomes an independent dataset.

tank/some-random-data-clone <- this is now an independent dataset after promotion
- snapshot-clone

I can't say for certain what the UI does, since I've never cloned datasets through the UI.
 
Top