I was also wondering when a long lasting delete would finish so I came up with this little piece of shell code:
btrfs device usage --raw /mnt/data | egrep -- '-[0-9]+' | sed -E 's/[^0-9]+([0-9]+)/\1/'
while [ 1 ]; do
if [ "$diff" -gt 0 ]; then
dd if=/dev/zero iflag=count_bytes count="$diff" 2>/dev/null
done | pv -petraW -s $(get_bytes) >/dev/null
This will give you a nice progress bar like this:
0:13:54 [0,00 B/s] [16,0MiB/s] [> ] 1% ETA 19:23:19
The general idea is to use
pv to display progress. Since that command only allows to monitor bytes flowing through a pipe we use
dd to generate an appropriate amount of zeros and pipe them into
The advantage of this method is that you get a nice progress bar. However, since it seems
btrfs always deletes data one GB at a time it takes some time until a new difference in byte sizes can be observed.
To address this issue the flag
-a is added to the default flags of
pv to make it display an average transmission rate (since the normal current transmission rate will be 0 most of the time).
I realize this is not the best solution but the best I could come up with. If someone has ideas for improvements please let me know! :)