diff --git a/src/freedombone-utils-filesystem b/src/freedombone-utils-filesystem index 8183a924..11dde6d3 100755 --- a/src/freedombone-utils-filesystem +++ b/src/freedombone-utils-filesystem @@ -106,11 +106,21 @@ function install_tomb { function defrag_filesystem { fs_type=$(stat -f /) - if [[ "$fs_type" == *"btrfs"* ]]; then - echo $'Defragmenting root directory' - btrfs filesystem defragment -r / - echo $'Defragmentation completed' + if [[ "$fs_type" != *"btrfs"* && "$fs_type" != *"ext4"* ]]; then + return fi + + echo $'Defragmenting root directory' + + if [[ "$fs_type" == *"btrfs"* ]]; then + btrfs filesystem defragment -r -clzo / + fi + + if [[ "$fs_type" == *"ext4"* ]]; then + e4defrag / + fi + + echo $'Defragmentation completed' } # NOTE: deliberately no exit 0