Yandex
Update cookies preferences

Disk space on the server

Before talking about the disk space available for use, it is worth saying a few words about the units of information volume. The unit of digital information is the byte, which consists of 8 bits.
There are two systems of measurement: decimal and binary. The International System of Units (SI) uses a decimal system in which magnifying prefixes are multiples of 1000 = 103. And in binary systems, such as IEC and ISO, multiples of 1024 = 210.
 

Multibyte units of the decimal unit system

NameSymbolValueRelevance
kilobytekB103 = 10001 000 B
megabyteMB106 = 100021 000 KB = 1 000 000 B
gigabyteGB109 = 100031 000 MB = 1 000 000 KB
terabyteTB1012 = 100041 000 GB = 1 000 000 MB
petabytePB1015 = 100051 000 TB = 1 000 000 GB
 

Multibyte units of the binary unit system

NameSymbolValueRelevance
kibibyteKiB210 = 10241 024 B
mebibyteMiB220 = 102421 024 KB = 1 048 576 B
gibibyteGiB230 = 102431 024 MB = 1 048 576 KB
tebibyteTiB240 = 102441 024 GB = 1 048 576 MB
pebibytePiB250 = 102451 024 TB = 1 048 576 GB
 

Let us now consider this in practice

Let's take the disk as an example Samsung SSD 860 EVO 4TB, with capacity 4 000 787 030 016 bytes [4.00 TB]. In binary, the disk capacity is approximately 3.64 TiB.
In Linux it is common to use the df utility to output the disk size, and we will use it further.
Binary system is used by default. For convenience, you can use the command 
df -h /dev/sdb1where instead of /dev/sdb1 you need to specify either a disk or a mount point:
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       3.7T  903G  2.6T  26% /backup
To view the disk capacity in decimal system, use the command
df -H /dev/sdb1 or 
df -si /dev/sdb1
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       4.0T  970G  2.9T  26% /backup
 
And at a glance, everything looks accurate. But let's see what happens if we output the volume in kilobytes / kibibytes. In the decimal system:
df --block-size=kB /dev/sdb1
Filesystem       1kB-blocks        Used    Available Use% Mounted on
/dev/sdb1      3999089472kB 969324938kB 2829708461kB  26% /backup2
And in the binary:
df --block-size=K /dev/sdb1  or 
df --block-size=KiB /dev/sdb1 or even simply
df /dev/sdb1
Filesystem       1K-blocks       Used   Available Use% Mounted on
/dev/sdb1      3905360812K 946606384K 2763387168K  26% /backup2
 
Let's note the usage and available disk space, and compare it to the total.
946 606 384 KiB + 2 763 387 168 KiB = 3 709 993 552 KiB, which is completely inconsistent 3 905 360 812 KiB.
It's actually simple - it's all about the file system in Linux. In this case, it's EXT4. By default, linux marks 5% of each disk partition as space reserved for the root user.

You can check this with the command:
tune2fs -l /dev/sdb1 |grep -i 'Block count'
Block count:              976754385
Reserved block count:     48837719
Let's check. 48837719 / 976754385 and multiply it by 100. We're getting 5%.
 

Important

For larger disks and assuming the ext4 file system is used, this redundancy may be excessive and can be reduced slightly.
And in the case of using ext3 file system it is not recommended to do this, it is better to always keep a reserve of 5%, because when the disk is filled to more than 95% there is a fragmentation of files and as a consequence of performance degradation. The ext4 file system has no such problem.
 

Summary

Keep in mind that by default you have 5% less available disk space. And don't confuse kB and KiB.
28 Apr 2024, 13:41:41