The Nextcloud serverinfo app does not use the total disk size as listed in the size column of the df -h command. Instead, it uses the df -TPk output to determine “Used” and “Available” space and calculates the file system size based on the sum of these two values.
The ext4 file system reserves a portion of disk space for administrative purposes, which is not included in the ‘used’ and ‘available’ space reported by df. This reserved space is intended to prevent file system fragmentation and ensure that critical system operations can continue even when the disk is nearly full.
To calculate the size of the reserved blocks and convert it into human-readable formats (KB, MB, and GB), you can use the following script:
device="/dev/sda1"
# Extract block size and reserved block count
blocksize=$(tune2fs -l $device | awk '/Block size:/ {print $NF}')
reserved=$(tune2fs -l $device | awk '/Reserved block count:/ {print $NF}')
# Calculate reserved space in KB, MB, and GB
reserved_kb=$((reserved * blocksize / 1024))
reserved_mb=$((reserved_kb / 1024))
reserved_gb=$((reserved_mb / 1024))
# Display results
echo "Reserved space: $reserved_kb KB"
echo "Reserved space: $reserved_mb MB"
echo "Reserved space: $reserved_gb GB"
Much and good luck,
ernolf