ext4 defragmentation

This commit is contained in:
Bob Mottram 2017-06-16 19:55:04 +01:00
parent 73eb2d8146
commit a1a448088d
1 changed files with 14 additions and 4 deletions

View File

@ -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