In Linux world, disk management is an interesting area. As time moves on, the disk capacity is increasing, speed is improving, and price is dropping. In this post, let’s talk about disk partition table type:MBR and GPT.
Master Boot Record (MBR)
MBR was born in the early 1980s for IBM PCs, way back in the thrilling days of ten-megabyte hard disks. The MBR must live on the first 512 bytes (first sector) of disk, and it holds the bootloader and partition table. The bootloader occupies 446 bytes, the partition table uses 64 bytes, and the remaining two bytes store the boot signature. The MBR is limited to four primary partitions, and a single primary partition can be an extended partition which can then be divided into logical partitions. Linux supports (theoretically) an unlimited number of logical partitions.
MBR is tiny and inflexible, and has lasted this long thanks to clever hacks to get around its limitations. Logical Block Addressing (LBA) gets around the limitations of its original cylinders, heads, and sectors (CHS) addressing. The traditional hard disk block size of 512 bytes limits partitions to 2TB in size. Even though MBR is still widely used, but it is retiring…
GUID Partition Table (GPT)
GPT is part of the Unified Extensible Firmware Interface (UEFI) specification, GPT does not have primary and logical partitions.
GPT has several advantages over the MBR:
64-bit disk pointers allows 2 powerof 64 total sectors, so a hard disk with 512-byte blocks can be as large as 8 zebibytes. With 4096-byte sectors your maximum disk size is really really large.
The default maximum number of partitions is 128, and if your operating system supports it you can have more.
No more CHS cruft or hacky primary-extended-logical partitioning scheme, which falls down if you need Windows because Windows is inflexible and hogs primary partitions
GPT has fault-tolerance by keeping copies of the partition table in the first and last sector on the disk
GPT computes a cyclic redundancy check (CRC) checksum to verify its own integrity, and of the partition table
Unique IDs for disks and partitions.
Let’s do some simple exercise by using a 1GB USB pendrive.
I insert 1GB UBS pendrive into a box running Centos, it is detected as /dev/sdb.
First thing to notice is that the partition tool “gdisk”, instead of “fdisk”.
Second thing, “gdisk -l /dev/sdb” tells there is no partition exists in the device so far.
Let’s create 5 partitions, first one is 100MB, the second one is 200MB, and third one is 100MB, fourth is 100MB, fifth has the rest of space.
As it is shown, there is no partition table so far.
As it is shown, first partition with 100MB is created now.
As it is shown, first and second partitions are created.
As it is shown, all five partitions are created. Now it is time to save it to make it permanent.