Skip to content

Instantly share code, notes, and snippets.

@chapmanjacobd
Created September 7, 2024 12:41
Show Gist options
  • Save chapmanjacobd/7674ee8f77e807ca87d265cdce47e044 to your computer and use it in GitHub Desktop.
Save chapmanjacobd/7674ee8f77e807ca87d265cdce47e044 to your computer and use it in GitHub Desktop.
re-sparse hydrated files
function is_sparse_file
set actual_size (du --block-size=1 "$argv" | awk '{print $1}')
set apparent_size (du --block-size=1 --apparent-size "$argv" | awk '{print $1}')
if test $actual_size -eq $apparent_size
return 1
else
return 0
end
end
for f in (fd -tf . /fs/.tmp/)
if is_sparse_file "$f"
fallocate --dig-holes "$f"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment