CentOS - gdisk and parted

maelamrani

Member
Credits
253
Hello,
i have a question
why when i use gdisk to create a partition of 20 Go
when i do lsblk i found 20 Go

But when i user parted to create it
mkpart 1 0 20GB
when i user lsblk i found 18.6 Go

How can i get the same space with parted

thx in advance
 


dos2unix

Well-Known Member
Credits
1,697
A lot of this has to do with the history of kilobytes and such.
Technically 1K is 1000. But usually in "computer speak", people normally mean 1024.
This has to do with binary math and a byte being 8 bits.
So some programs use 1000, and others use 1024 as the base of how they figure math.
The other problem here is... the partition "table".
With MBR a small section of the disk is used to store where everything is. Kind of like a table of contents in a book.
Because of this, a 16GB USB stick, will never be exactly 16GB. Usually it's closer to 15.8 or something like that. If you're using LVM (logical volume manager) there is even more overhead to keep track of the book-keeping of what is happening on the disk partition.
Then there is the way disks are formatted. you have EXT4, XFS, BRTFS, etc... each of those stores
stores things slightly differently. The more files you have, the bigger the table. With GPT it is similar, but instead of a flat file, it uses a mini-database to keep track of directories, permissions, and files.

Now sometimes the manufacturers "fool" us. I bought a 32GB USB stick. After I formatted it,
it was 32.02 GB. It turns out it was really about 33.5GB, but after everything was formatted it
showed very close to 32GB.

You could run lsblk -b /dev/sda1 (or whatever partition you are trying to figure out)
and that will give the exact bytes. Something like this..

├─sda4 8:4 0 42949672960 0 part /home

You can divide the bytes by 1024 to get pretty close.
(Which is what running lsblk without the -b does)
 
Last edited:


Members online


Top