ZFS How to delete only some ZFS datasets...

Hello.

I would like to know how to delete some ZFS datasets mounting the zpool from another disk because I can't do that using the command "bectl -destroy". Infact I'm not able anymore to boot FreeBSD installed on the ZFS disk. When I try to boot it,it is not selected. In its place is the system installed on the UFS disk which boots. There should be some problem inside the /boot folder of the ZFS disk,but I don't understand what could be the error. In addition,as you can see below,there is no space available on the datasets. I would like to remove some of them (like 13.1-RELEASE-p5_2023-01-12_235731 and 13.1-RELEASE_2022-12-27_160733) ,but I don't know how.

Code:
# zpool import -f -R /mnt/zroot zroot
# zfs list

NAME                                           USED  AVAIL     REFER  MOUNTPOINT

zroot                                          443G  2.86G       96K  /mnt/zroot/zroot
zroot/ROOT                                     431G  2.86G       96K  none
zroot/ROOT/13.1-RELEASE-p5_2023-01-05_013659  2.30G  2.86G      273G  /mnt/zroot
zroot/ROOT/13.1-RELEASE-p5_2023-01-12_235731   126M  2.86G      163G  /mnt/zroot
zroot/ROOT/13.1-RELEASE_2022-12-27_160733      300G  2.86G      199G  /mnt/zroot
zroot/ROOT/31-03-2022-b                        128G  2.86G      320G  /mnt/zroot
zroot/tmp                                     32.1M  2.86G     32.1M  /mnt/zroot/tmp
zroot/usr                                     9.29G  2.86G      120K  /mnt/zroot/usr
zroot/usr/home                                 192K  2.86G      192K  /mnt/zroot/usr/home
zroot/usr/ports                               9.29G  2.86G     9.29G  /mnt/zroot/usr/ports
zroot/usr/src-                                  96K  2.86G       96K  /mnt/zroot/usr/src-
zroot/var                                     2.46G  2.86G      136K  /mnt/zroot/var
zroot/var/audit                                 96K  2.86G       96K  /mnt/zroot/var/audit
zroot/var/crash                               1.11G  2.86G     1.11G  /mnt/zroot/var/crash
zroot/var/log                                 4.10M  2.86G     4.10M  /mnt/zroot/var/log
zroot/var/mail                                1.33G  2.86G     1.33G  /mnt/zroot/var/mail
zroot/var/tmp                                 18.1M  2.86G     18.1M  /mnt/zroot/var/tmp

Usually it booted from "zroot/ROOT/31-03-2022-b",but 'cause some unknown reason,this doesn't happen anymore :

Screenshot_2023-01-15_16-02-00.png


I tried with :

Code:
# zfs destroy zroot/ROOT/13.1-RELEASE_2022-12-27_160733

cannot destroy 'zroot/ROOT/13.1-RELEASE_2022-12-27_160733': filesystem has children
use '-r' to destroy the following datasets:
zroot/ROOT/13.1-RELEASE_2022-12-27_160733@2022-12-27-16:07:33-0

# zfs destroy -r zroot/ROOT/13.1-RELEASE_2022-12-27_160733

cannot destroy 'zroot/ROOT/13.1-RELEASE_2022-12-27_160733': filesystem has dependent clones
use '-R' to destroy the following datasets:
zroot/ROOT/13.1-RELEASE-p5_2023-01-12_235731
zroot/ROOT/13.1-RELEASE-p5_2023-01-05_013659@2023-01-12-23:57:31-0
zroot/ROOT/13.1-RELEASE-p5_2023-01-05_013659
zroot/ROOT/31-03-2022-b@2023-01-05-01:36:59-0
zroot/ROOT/31-03-2022-b

as you can see it wants that I destroy some datasets that I don't want to destroy,such as :

Code:
zroot/ROOT/13.1-RELEASE-p5_2023-01-12_235731
zroot/ROOT/31-03-2022-b

what to do in this situation ?
 
Code:
zfs set canmount=off zroot/ROOT/13.1-RELEASE_2022-12-27_160733
zfs destroy -r zroot/ROOT/13.1-RELEASE_2022-12-27_160733@ ... any snapshots
zfs destroy -f -R -r zroot/ROOT/13.1-RELEASE_2022-12-27_160733
 
What's the command to show what are the snapshots under the dataset 13.1-RELEASE_2022-12-27_160733 ? Can the snapshots be deleted indipendently from the other snapshots without to damage the system ? Look at the example below :

cannot destroy 'zroot/ROOT/13.1-RELEASE_2022-12-27_160733': filesystem has dependent clones
use '-R' to destroy the following datasets:
zroot/ROOT/13.1-RELEASE-p5_2023-01-12_235731
zroot/ROOT/13.1-RELEASE-p5_2023-01-05_013659@2023-01-12-23:57:31-0
zroot/ROOT/13.1-RELEASE-p5_2023-01-05_013659
zroot/ROOT/31-03-2022-b@2023-01-05-01:36:59-0
zroot/ROOT/31-03-2022-b

it seems that if I will remove zroot/ROOT/13.1-RELEASE_2022-12-27_160733 also zroot/ROOT/31-03-2022-b will be removed.
 
You will need to have an understanding of ZFS clones, and what zfs-promote(8) does to be able to make sure you are deleting what you want to delete.

zfs get -r used filesystem can be used to show the snapshots present below filesystem.

Take the time to read and understand those links before issuing a delete command and ending up wondering where your filesystem went.
 
ziomario use zfs promote to make your preferred boot environment the "trunk" in the origin-clone relationship. The "branch point" snapshots would get moved to that dataset then.
 
Back
Top