February 3, 20251 yr I use my two nvme Cache Drives with ZFS and made some Snapshots. How can I delete EVERY Snapshot in my System Folder? Edited February 3, 20251 yr by unrd44
February 3, 20251 yr Community Expert while I wouldn't destroy the .system snapshot as it does hold settings for zfs as that is a remneat of a import from truenas into unraid... you can run the zfs destroy -r to kill the entire dataset system and snapshots... I don't remember the terminal command offhand that targes snapshots only... Unraid zfs master plugin also has a snapshot admin where you can select your snapshot and delete it. select all at top delete button:
February 4, 20251 yr Author Thanks for your answer. In Snapshot Admin i do not get the whole tree, when i select the top entry...
February 4, 20251 yr Community Expert ok then lets see if this works as intended for you... as i'm lacking some data to make a script... I will pull from my backup the prune command and attempt to grab the entire dataset to kill all snapshots... # Function to prune snapshots prune_snapshots() { local DATASET="$1" local KEEP="${SNAPSHOT_QTY}" local SNAPSHOTS=( $(zfs list -t snapshot -o name -s creation -r "${DATASET}" | grep "^${DATASET}@") ) local SNAPSHOTS_COUNT=${#SNAPSHOTS[@]} echo "Total snapshots for ${DATASET}: ${SNAPSHOTS_COUNT}" local SNAPSHOTS_SPACE SNAPSHOTS_SPACE=$(zfs get -H -o value usedbysnapshots "${DATASET}") echo "Space used by snapshots for ${DATASET}: ${SNAPSHOTS_SPACE}" if [[ ${SNAPSHOTS_COUNT} -gt ${KEEP} ]]; then local TO_DELETE=$((SNAPSHOTS_COUNT - KEEP)) for i in "${SNAPSHOTS[@]:0:${TO_DELETE}}"; do zfs destroy "${i}" echo "Deleted snapshot: ${i}" echo "_____________________________________________________________" done else echo "_____________________________________________________________" fi per some of my workarounds and script... step 1 we will need a list that zfs is seeing. you may be fighting zfs acl and linux ownership and file access permission... # List all datasets, particularly focusing on the `.system` dataset zfs list -t snapshot -r $(zfs list -H -o name | grep -m 1 '.system') List all datasets and snapshots We need to grab the full list of datasets, especially focusing on .system and its snapshots. This command can identify and list them all. step 2. delete the listed snapshots: # Example script to delete snapshots within `.system` SYSTEM_DATASET=$(zfs list -H -o name | grep -m 1 '.system') zfs list -t snapshot -r "$SYSTEM_DATASET" | awk '{print $1}' | while read SNAP; do echo "Destroying snapshot: $SNAP" zfs destroy "$SNAP" done step 3 set acl/permissions.. Fixing permissions and ACLs Unraid requires that files and directories be accessible to the nobody user and users group. Reapplying correct permissions can solve access issues. SYSTEM_DATASET=$(zfs list -H -o name | grep -m 1 '.system') # Change ownership to Unraid-friendly user and group chown -R nobody:users "/mnt/$SYSTEM_DATASET" # Apply full permissions to allow access chmod -R 777 "/mnt/$SYSTEM_DATASET" *As I did turenas original, went back and forth to unraid. Was on unraid for a long while and recently moved my pool into truenas and into unraid again to collect what goes wrong where and how to fix this... Truenas makes .system dataset and stores truenas and other zfs related data there. Moving uraid to truenas there is an issue on how the dataset and mount point is set. It can be a pain to move from unriad into truenas... Unraid uses the nobody user and user group for just about everything, setting these acl and permission will help access manipulate and do things to the system. With dataset and setting permission, you may see read only file system. That is normal based on zfs acl permission... # Verify that snapshots are gone and permissions are set correctly zfs list -t snapshot -r "$SYSTEM_DATASET" ls -l "/mnt/$SYSTEM_DATASET" You will need to get the full zfs path and use the zfs destroy command more info here: https://openzfs.github.io/openzfs-docs/man/master/8/zfs-destroy.8.html Edited February 5, 20251 yr by bmartino1 typo
February 5, 20251 yr Author @bmartino1 Thanks for the Script. How can i execute that? With the user script Plugin in Unraid? What Dows "legacy" and the yellow camera icon mean?
February 5, 20251 yr Community Expert 5 hours ago, unrd44 said: @bmartino1 Thanks for the Script. How can i execute that? With the user script Plugin in Unraid? What Dows "legacy" and the yellow camera icon mean? User Plugin is preferd... The ZFS master plug-in has a warning system of 30 days default Settings> ZFS Master If you have content that has a snapshot or needs to be snapshot for ZFS bit rot protection, it will turn yellow based on how long it was since last snapshot. Letting you know that it's time to make a new snapshot and/or verify your data. How to explain the legacy info.... The legacy option is just an old format on how ZFS was using .system dataset in order to store and use some of zfs configurations... The legacy system for ZFS was used to store and pull the information. It's marked as legacy more to the note that it was never mounted as it does contain data and is considered a dataset... Review: What is a ZFS legacy mount point http://superuser.com/questions/790036/ddg#1557822 ZFS provides a hierarchical structure of datasets within a pool. In example case you have a pool named rpool, and at least the following datasets: rpool rpool/ROOT rpool/ROOT/s10x_u10_wos_17b Each of these datasets is often a filesystem (though it can be a volume / block device instead)... Just as each of these is datasets is likely a full / independent filesystem, each can also be mounted or not mounted independently. By default, ZFS will mount children datasets at their logical location within the parent... If the rpool dataset is mounted at /rpool (i.e: default), then you would find that the rpool/ROOT dataset mounted at /rpool/ROOT, etc... This is controlled by the mountpoint property - run zfs get -rt filesystem mountpoint to see its current value for each dataset. If the value is a path, then ZFS will automatically mount the dataset at that path when the pool is imported. The default (as mentioned above) is to mount the filesystem under the parent. (usualy /mnt/<poolname> and then /mnt/<poolname>/<Dataset_name>) If the value is none, then ZFS will not mount the filesystem, and the filesystem cannot be mounted using mount either. If the value is legacy, then ZFS will not mount the filesystem, but you can use mount and umount to manage the filesystem's mountpoint manually. On other Linux Distros, You could use /etc/fstab to guide automatic mounting. Edited February 5, 20251 yr by bmartino1 typo - Data
February 5, 20251 yr Community Expert The easiest way is to run the code is via the user script plug-in yes... However, you can make an sh script in terminal stored anywhere and run the script. Sometime: Or simply copy paste the entire script and it will run.
February 11, 20251 yr Author @bmartino1 Thank you for your Script and explains! When i run the Script i get the following error Messages. In the past i used Docker Directories, now i use Docker Image. I think this is old stuff... What can i do to get a clean system Share?
February 11, 20251 yr Author Solved! I user the following Script with the Parameter -R: # Example script to delete snapshots within `.system` SYSTEM_DATASET=$(zfs list -H -o name | grep -m 1 '.system') zfs list -t snapshot -r "$SYSTEM_DATASET" | awk '{print $1}' | while read SNAP; do echo "Destroying snapshot: $SNAP" zfs destroy "$SNAP" -R done
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.