how to delete snapshot in TrueNAS-13.0-U3.1

Joined
Mar 5, 2022
Messages
224
I recently cloned a one of my pools (storage->pools->right-click->snapshot) so that I could find some deleted data in
Code:
/mnt/pool/documents

This created the folder
Code:
/mnt/documents-auto-2023-01-05_00-00-clone

I retrieved the delete files, now I want to delete the shapshot.
I have tried:

Code:
sudo zfs promote pool/home-auto-2023-01-05_19-00-clone
sudo zfs destroy -r pool/home-auto-2023-01-05_19-00-clone
sudo zfs destroy -R pool/home-auto-2023-01-05_19-00-clone
sudo rm -rf pool/home-auto-2023-01-05_19-00-clone


Nothing seems to work :-(
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
A snapshot cloned into a dataset (then promoted by one of your commands if it succeeded) may either be a snapshot or a dataset.

I suggest looking at zfs list | grep documents first to make sure you know what you're working with.
 

Whattteva

Wizard
Joined
Mar 5, 2013
Messages
1,824
Snapshots are usually denoted with an @ symbol (ie. dataset@snapshot). I'd do the following to see what you actually really have in your file system.
Code:
zfs list -r pool/documents
zfs list -rt snapshot pool/documents
 
Joined
Mar 5, 2022
Messages
224
Snapshots are usually denoted with an @ symbol (ie. dataset@snapshot). I'd do the following to see what you actually really have in your file system.
Code:
zfs list -r pool/documents
zfs list -rt snapshot pool/documents
Code:
phong% zfs list -r pool/documents
NAME             USED  AVAIL     REFER  MOUNTPOINT
pool/documents  38.7M  7.13T     1.58T  /mnt/pool/documents
phong% zfs list -rt snapshot pool/documents
NAME                                   USED  AVAIL     REFER  MOUNTPOINT
pool/documents@auto-2023-01-08_02-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_03-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_04-00   154K      -     1.58T  -
pool/documents@auto-2023-01-08_05-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_06-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_07-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_08-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_09-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_10-00     0B      -     1.58T  -
 
Joined
Mar 5, 2022
Messages
224
A snapshot cloned into a dataset (then promoted by one of your commands if it succeeded) may either be a snapshot or a dataset.

I suggest looking at zfs list | grep documents first to make sure you know what you're working with.
Code:
phong% zfs list | grep documents
pool/documents                                         38.7M  7.13T     1.58T  /mnt/pool/documents
pool/documents-auto-2023-01-05_00-00-clone             1.58T  7.13T      358K  /mnt/pool/documents-auto-2023-01-05_00-00-clone
 
Joined
Mar 5, 2022
Messages
224
Is there any way that I may have broken my original dataset by running the above commands? I don't see anything wrong with the data, but the thought just passed through my head :-/
 

Whattteva

Wizard
Joined
Mar 5, 2013
Messages
1,824
Code:
phong% zfs list -r pool/documents
NAME             USED  AVAIL     REFER  MOUNTPOINT
pool/documents  38.7M  7.13T     1.58T  /mnt/pool/documents
phong% zfs list -rt snapshot pool/documents
NAME                                   USED  AVAIL     REFER  MOUNTPOINT
pool/documents@auto-2023-01-08_02-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_03-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_04-00   154K      -     1.58T  -
pool/documents@auto-2023-01-08_05-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_06-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_07-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_08-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_09-00     0B      -     1.58T  -
pool/documents@auto-2023-01-08_10-00     0B      -     1.58T  -
So you see here, you have a bunch of snapshots in pool/documents though strangely, I don't see one for 2023-01-05-00_00.
Btw, I wouldn't just blindly start executing sudo rm -rf or zfs destroy -r without actually knowing what you're doing. Those two commands are highly destructive and may be unrecoverable from as there are no confirmations and -r flag will destroy even snapshots on the dataset.
 

Whattteva

Wizard
Joined
Mar 5, 2013
Messages
1,824
Is there any way that I may have broken my original dataset by running the above commands? I don't see anything wrong with the data, but the thought just passed through my head :-/
It's possible. Did you get any not found errors? If you didn't get any errors executing those. It's possible that you have deleted a bunch of stuff. Usually those commands would throw an error message if it can't delete stuff.
 
Joined
Mar 5, 2022
Messages
224
Initially I did not get any errors. Now I get busy errors when I run the rm command.
The data in the original folder looks OK, but there is a lot it there so it's hard to tell for sure if it's ALL there.

I don't think I care too much about the snapshots at this point... I'm just worried about the data in the documents folder. There hasn't been any changes to speak of lately, so any updates are not going to be missed.
 
Joined
Mar 5, 2022
Messages
224
Still unable to delete the snapshots... Any suggestions?
 

Whattteva

Wizard
Joined
Mar 5, 2013
Messages
1,824
Which ones are you trying to delete out of the ones listed from the command above?
 
Joined
Mar 5, 2022
Messages
224
I am trying to delete the following:
Code:
drwxrwx---   2 root       home        2 Jan  6 21:55 documents-auto-2023-01-05_00-00-clone
drwxrwx--x+  2 root       home        2 Jan  6 21:56 home-auto-2023-01-05_19-00-clone


They were created under /mnt/pool where my pools are located:
Code:
drwxr-xr-x   9 root       wheel      12 Mar 12  2022 iocage
drwxr-xr-x   2 88         88          2 Mar 12  2022 datadir
drwxr-xr-x   2 88         88          3 Mar 12  2022 innodb_log
drwxrwx--x+  6 root       home        6 Mar 17  2022 home
drwxr-xr-x   2 88         88          4 Aug  8 12:54 innodb_data
drwxrwx---  10 root       home       10 Nov 13 07:47 documents
drwxrwxrwx+  2 sambauser  sambauser   3 Dec 29 23:20 downloads
drwxrwx---   2 root       home        2 Jan  6 21:55 documents-auto-2023-01-05_00-00-clone
drwxrwx--x+  2 root       home        2 Jan  6 21:56 home-auto-2023-01-05_19-00-clone
 

Whattteva

Wizard
Joined
Mar 5, 2013
Messages
1,824
Ok, so if you are ABSOLUTELY sure that you don't need the clones anymore, you can try this.
Code:
zfs destroy -r pool/documents-auto-2023-01-05_00-00-clone
zfs destroy -r pool/home-auto-2023-01-05_19-00-clone


If you get any errors when you do that. Please post your errors here.
 
Joined
Mar 5, 2022
Messages
224
So now you have me concerned... Why would I care about the clone if it a duplicate of the original pool? I have only read from it (and honestly nothing has changed in the original pool)
 

Whattteva

Wizard
Joined
Mar 5, 2013
Messages
1,824
So now you have me concerned... Why would I care about the clone if it a duplicate of the original pool? I have only read from it (and honestly nothing has changed in the original pool)
It's probably good to delete. I just wanted to make sure you have nothing you need from the clone anymore.
 
Joined
Mar 5, 2022
Messages
224
I tried the zfs destroy command and got this:

Code:
phong% zfs destroy -r pool/home-auto-2023-01-05_19-00-clone
cannot destroy 'pool/home-auto-2023-01-05_19-00-clone': filesystem has dependent clones
use '-R' to destroy the following datasets:
pool/home@auto-2023-01-09_09-00
pool/home@auto-2023-01-09_08-00
pool/home@auto-2023-01-09_20-00
pool/home@auto-2023-01-08_23-00
pool/home@auto-2023-01-09_18-00
pool/home@auto-2023-01-09_19-00
pool/home@auto-2023-01-08_22-00
pool/home@auto-2023-01-09_21-00
pool/home@auto-2023-01-08_20-00
pool/home@auto-2023-01-09_23-00
pool/home@auto-2023-01-08_18-00
pool/home@auto-2023-01-10_08-00
pool/home@auto-2023-01-08_19-00
pool/home@auto-2023-01-10_09-00
pool/home@auto-2023-01-09_22-00
pool/home@auto-2023-01-08_21-00
pool/home@auto-2023-01-09_13-00
pool/home@auto-2023-01-10_00-00
pool/home@auto-2023-01-09_04-00
pool/home@auto-2023-01-06_00-00
pool/home@auto-2023-01-09_05-00
pool/home@auto-2023-01-10_16-00
pool/home@auto-2023-01-10_01-00
pool/home@auto-2023-01-09_12-00
pool/home@auto-2023-01-10_03-00
pool/home@auto-2023-01-09_10-00
pool/home@auto-2023-01-09_07-00
pool/home@auto-2023-01-10_14-00
pool/home@auto-2023-01-07_00-00
pool/home@auto-2023-01-10_15-00
pool/home@auto-2023-01-09_06-00
pool/home@auto-2023-01-09_11-00
pool/home@auto-2023-01-10_02-00
pool/home@auto-2023-01-09_02-00
pool/home@auto-2023-01-10_11-00
pool/home@auto-2023-01-10_06-00
pool/home@auto-2023-01-08_16-00
pool/home@auto-2023-01-09_15-00
pool/home@auto-2023-01-09_14-00
pool/home@auto-2023-01-10_07-00
pool/home@auto-2023-01-08_17-00
pool/home@auto-2023-01-10_10-00
pool/home@auto-2023-01-08_00-00
pool/home@auto-2023-01-09_03-00
pool/home@auto-2023-01-10_12-00
pool/home@auto-2023-01-09_01-00
pool/home@auto-2023-01-09_16-00
pool/home@auto-2023-01-10_05-00
pool/home@auto-2023-01-10_04-00
pool/home@auto-2023-01-09_17-00
pool/home@auto-2023-01-09_00-00
pool/home@auto-2023-01-10_13-00
 

Whattteva

Wizard
Joined
Mar 5, 2013
Messages
1,824
Yes, for the snapshots, you'd need to use the -R option because they are presumably tied to clones. It should be safe to use the -R option on those. Be aware that by doing so, you WILL lose the cloned file systems based on those snapshots and you can't undo the process.
 
Joined
Mar 5, 2022
Messages
224
Thanks so much for your help with this... It is rather nerve-wracking to delete massive amounts of data :-/

As long as the original pools are unaffected, I don't mind doing this... I just want to make sure the original pools will remain intact!
 
Joined
Mar 5, 2022
Messages
224
OK, I was able to delete the contents of the two cloned folders, but I am unable to remove the (empty) folders:

Code:
phong% sudo zfs destroy -R pool/documents-auto-2023-01-05_00-00-clone
cannot unmount '/mnt/pool/documents': pool or dataset is busy
cannot destroy snapshot pool/documents-auto-2023-01-05_00-00-clone@auto-2023-01-05_00-00: snapshot is cloned
phong% ls pool/documents-auto-2023-01-05_00-00-clone
 

Whattteva

Wizard
Joined
Mar 5, 2013
Messages
1,824
Thanks so much for your help with this... It is rather nerve-wracking to delete massive amounts of data :-/

As long as the original pools are unaffected, I don't mind doing this... I just want to make sure the original pools will remain intact!
You're just deleting clones so the original should be fine.

What's the output of zfs list -r pool now?
 
Top