# Btrfs Maintenance Script # This script checks if your system is Btrfs and attempts to fix "Full" states # by running a balance on chunks > 75% full. export def maintenance [ mount_point: path = '/' # mount point to check, `/` by default ] { print "šŸ” Checking filesystem type..." let fs_type = df | where Mounted == $mount_point | get Filesystem.0 if $fs_type != "btrfs" { print $"āŒ Error: Not a Btrfs filesystem ($fs_type). Aborting." exit 1 } print "āœ… Filesystem is Btrfs." print "\nšŸ“Š Current Btrfs Usage:" ^btrfs filesystem usage $mount_point print "\nšŸ›  Starting Btrfs Balance..." try { ^sudo btrfs balance start -dusage=75 -musage=75 $mount_point print "āœ… Balance command sent successfully." } catch { |err | print $"āŒ Failed to start balance: $err" print "Ensure you have sudo privileges." exit 1 } print "\nā³ Waiting for balance to complete or show status..." ^sudo btrfs status $mount_point if ($in | str contains "Balance") { print "\n⚠ Balance is still running. You can check progress with:" print $" btrfs balance status $MOUNT_POINT" } print "\nšŸ“ˆ Checking storage after balance:" ^btrfs filesystem usage $mount_point print "\nāœ… Maintenance Complete." }