Combining this with "-exec sudo btrfs property set {} compression zstd:1 ;", I multiple warnings of the following type, which seem to indicate it's descending into other mounted filesystems:
ERROR: object is not a btrfs object: /boot/efi
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
You're absolutely correct in identifying the issue! The warnings you're seeing (like ERROR: object is not a btrfs object: /boot/efi) indicate that the find command is indeed traversing into directories mounted on different filesystems, even though you're using -xdev.
The problem lies in how find -xdev works. It prevents descending into directories that are mount points of different filesystems. However, it doesn't prevent accessing files or directories that are bind-mounted or are part of a different filesystem but are reachable through the current filesystem.
In your case, /boot/efi is likely a separate EFI system partition, mounted on its own filesystem (often FAT32), but it's accessible from your root filesystem.
To truly stay within a single Btrfs filesystem and avoid these errors, you need a two-pronged approach:
Ensure /boot/efi and other non-Btrfs filesystems are properly mounted as separate partitions:
Double-check your /etc/fstab or mount configuration to ensure /boot/efi and any other non-Btrfs partitions are mounted correctly as separate filesystems.
Use find with -xdev and filter by filesystem type:
bash
find / -xdev -type f -o -type d -printf "%P\n" | while read -r file; do
if [[ "$(stat -f -c %T "$file")" == "btrfs" ]]; then
sudo btrfs property set "$file" compression zstd:1
fi
done
Explanation:
find / -xdev -type f -o -type d -printf "%P\n":
Finds files and directories starting from root (/), staying within the same filesystem (-xdev).
Uses -printf "%P\n" to print only the relative path (avoiding potential issues with full paths across filesystems).
Uses stat -f -c %T to get the filesystem type of the file.
Checks if the filesystem type is "btrfs".
sudo btrfs property set "$file" compression zstd:1:
Only applies the Btrfs compression if the file is on a Btrfs filesystem.
Important Notes:
Permissions: You'll likely need sudo privileges to execute btrfs commands and access certain directories.
Testing: Always test this command on a small subset of files before running it on your entire system.
Performance: This approach might be slower than directly using find -exec because it involves an additional check for each file.
By combining -xdev with filesystem type checking, you can ensure that your command only operates on files within the intended Btrfs filesystem, avoiding errors related to other filesystems.