Okay, I understand the problem. The errors ERROR: object is not a btrfs object: /boot/efi indicate that your find command, while respecting -xdev to stay on the same filesystem mount point, is still encountering directory entries (like /boot/efi) that are mount points for other filesystems (typically FAT32 for EFI partitions).
When find /path/to/start -xdev encounters /boot/efi, it sees it as a directory entry within the starting filesystem. Because it's a directory, find adds it to its list of items to process. However, it doesn't descend into /boot/efi because that's a different mount point. But then, your -exec command tries to run btrfs property set on /boot/efi itself, which fails because /boot/efi is not a Btrfs path.
The solution is to tell find to only consider entries that are actually on a Btrfs filesystem. You can do this using the -fstype predicate.
Here's the corrected command:
find /path/to/start -xdev -fstype btrfs \( -type f -o -type d \) -exec sudo btrfs property set {} compression zstd:1 \;
Let's break down the addition:
-fstype btrfs: This predicate checks the filesystem type of the current item ({}) being processed by find. It ensures that the subsequent actions (like -exec) are only performed if the item resides on a filesystem identified as btrfs.
How this solves the problem:
find /path/to/start -xdev: find starts searching from /path/to/start and stays on the same filesystem mount point. It will list all entries within this mount point, including directories that are mount points for other filesystems (like /boot/efi).
-fstype btrfs: For each entry found, find checks its filesystem type.
- If an entry like
/home/user/documents/file.txt is found, and it resides on the Btrfs filesystem that /path/to/start is on, -fstype btrfs evaluates to true.
- If an entry like
/boot/efi is found, and it's a mount point for a vfat filesystem (which is typical), -fstype btrfs evaluates to false.
\( -type f -o -type d \): Filters for regular files or directories.
-exec sudo btrfs property set {} compression zstd:1 \;: This action is only executed if all preceding predicates (-xdev, -fstype btrfs, -type f -o -type d) are true for the found item.
Therefore, the btrfs property set command will now only be attempted on files and directories that are actually part of a Btrfs filesystem within the specified mount point, effectively skipping entries like /boot/efi.
Important Considerations: