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
Name | Symbol | Value | Relevance |
kilobyte | kB | 103 = 1000 | 1 000 B |
megabyte | MB | 106 = 10002 | 1 000 KB = 1 000 000 B |
gigabyte | GB | 109 = 10003 | 1 000 MB = 1 000 000 KB |
terabyte | TB | 1012 = 10004 | 1 000 GB = 1 000 000 MB |
petabyte | PB | 1015 = 10005 | 1 000 TB = 1 000 000 GB |
Multibyte units of the binary unit system
Name | Symbol | Value | Relevance |
kibibyte | KiB | 210 = 1024 | 1 024 B |
mebibyte | MiB | 220 = 10242 | 1 024 KB = 1 048 576 B |
gibibyte | GiB | 230 = 10243 | 1 024 MB = 1 048 576 KB |
tebibyte | TiB | 240 = 10244 | 1 024 GB = 1 048 576 MB |
pebibyte | PiB | 250 = 10245 | 1 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/sdb1
, where 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.