Fun with GPT partitioning
Executive summary : A Linux user can easily partition a Pata or Sata disk with the gpt partitioning scheme. Most modern Linux will run on gpt disks with little bother but MS Windows will find it an uphill struggle. It is something useful to have when the hard disk exceeds 2TB. The gpt disks can happily co-exist with the non-gpt disks.
I have stayed away from this GUID partition table (GPT) until I bought a 2TB hard disk. The legacy partition table, also called MBR partition table adopted since Dos, has a limitation beyond the 2TB so I was just looking ahead and had a go with the gpt partioning system. A disk partitioned with the legacy type is called Msdos disk whereas a hard disk with a gpt scheme is now called gpt disk.
In theory the gpt partitioning scheme is ready-make for breaking the 2TB barrier in the hard disks. It will cope well with the future 4k physical sector change as well as the resulting alignment problems created. There is a lot of promises so here I am to find it out.
Apparently the GPT partition table is part of the Extensible Firmware Interface (EFI). The former can be implemented in Linux using certain partitioning tools but the latter requires a efi-aware motherboard which is not easy to find. None of my PC has it.
The upshot of it is that the 64-bit MS Windows can be installed and booted if the PC has both efi hardware and gpt hard disk. The 32-bit Windows can never be booted with gpt hard disk. That means the gpt partition table is pretty useless for the majority of the MS systems.
When it comes to Linux the matter is a lot happier and brighter.
To make a gpt disk all we need is to run the "parted" command in a root terminal. To create a gpt hard disk, say for device /dev/sdb, the command is
The command nukes all existing partitions. To create a partition say from 0Gb to 100Gb is simply
The gpt partition table automatically reserves the front end, about 34 sectors or 34x512= 17408 bytes, for the system use. This is a far cry from the Msdos disk that uses 4x16=64 bytes to describe the 4 primary partitions. The MS systems recognise a gpt disk can have 128 partitions. That apparently also applies in Linux as Post #2 shows how I make a 128 partition under 20 seconds!
mkpart Ubuntu 0 100G
The gpt partition table is recognised as one partition type ee in all Linux's partitioning tool that do not support gpt because the first 512 bytes sector is common in both gpt and MBR disks. This GPT partition uses up the whole disk. If the disk is larger than 2TB then only the first 2TB will be reported in the protective MBR entry but the GPT partition can be a lot larger. This is how my 500Gb disk looks like after partitioned with "parted" and interrogated by "fdisk".
I have actually created 5 partitions inside using parted but only a few partitioning tools that support gpt can report it. The list from parted looks like this
bash-3.1# fdisk -l /dev/sdb
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2aa773c4
Device Boot Start End Blocks Id System
/dev/sdb1 1 60802 488386583+ ee GPT
Thus the Linux kernel sees the content inside the gpt and the /dev/sdbx partitions can be used as in a normal MBR partition table.
bash-3.1# parted -l /dev/sdb
(note: the tabulations of 60 partitions of sda were removed as they are irrelevant)
Model: ATA SAMSUNG HD501LJ (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 100GB 100GB ext3 Ubuntu
2 100GB 110GB 9999MB ext3 Mepis
3 110GB 120GB 10.0GB ext3 PClinuxOS
4 120GB 130GB 10.0GB ext3 LinuxMint
5 130GB 140GB 9999MB ext3 Slackware
I have installed Ubuntu 10.4 in sdb1 but sdb2 to sdb5 were filled with Mepis, PClinuxOS, Linux Mint and Slackware from other hard disk. They all boot normally with Grub1 but my Linux Mint has Grub2 and I have to manually boot it up first before I could do a Grub-install inside.
I encountered the following interesting points:-
(1) Grub1 if patched can see the partitions inside a gpt disk. The standard 0.97 Grub1 only see gpt disk with one partition type ee and cannot boot the internal partitions. As an example my Mepis has a standard v0.97 Grub1. Although I can chainload Mepis using a patched Grub1 from Ubuntu when Mepis is loaded its standard Grub failed to boot up Mepis, claiming the partition did not exist.
(2) Grub2 has native support for gpt disks so it can be used to boot their internal partitions.
(3) Some older kernel fail to detect the internal partitions of a gpt disk. As an example I am now using Slackware with a 2.6.29 kernel. I managed to boot it up from sdb5 and was using it, yet when I attempted to mount /dev/sdb2 I got an error message of
. Its /dev directory only has sdb1 device name. Thus the gpt support is still not mature in Linux.
mount: special device /dev/sdb2 does not exist
(4) The UUID numbering system appears to originate from gpt partitioning system.
(5) Without efi hardware support from the motherboard I could not install any of the 64 bit MS Windows on the gpt disk. For the 32 bit MS system the gpt is a no-go area because the internal partitions won't get mounted at all. This means a ntfs partition created by a 64-bit Win7 cannot be seen in a Xp home. And I originally thought gpt partition table was invented for the MS systems.
(6) Any hard disk can be created in gpt format. I have tried it on both 500Gb and 2Tb hard disks.
(7) The partition type numbers appear to have been dropped in gpt system.
(8) A gpt partition table to a non gpt-aware partitioning tool like fdisk, cfdisk or sfdisk is similar to a LVM partition or an extended partition. It show up as one entry but there can be several partitions inside it.
(9) When a hard disk is partitioned in gpt the entire space is used up. A maximum of 128 partitions can be created (as showed in Post #2).
I shall add references to this thread about gpt in the space below from time to time
efi as explained in Wikipedia. Best explanation of gpt A comprehensive tutorial (for gdisk) of the current state of gpt from author of gdisk Rod Smith
Windows and GPT FAQ uefi specification
How Seagate manage a 3TB to suit operating systems
Bought a 3TB external hard disk today. It is one of those Seagate Geoflex series. It does not have a gpt partition table but a special or interesting Msdos partition table
The saying is a 32-bit operating system has a limit of addressing up to a maximum just below 2.2TB and so this becomes the limit of the MSDOS partition table based on each record the hard disk read or write is 512 bytes.
The trend is go for the gpt partition table but that is still too immature or too new for many PC users.
Seagate in order to sell their 3TB hard disks has increased the sector size from 512 bytes to 4096 bytes. Thus the number of records to search is artificially reduced so that the hard disk hooked up as an external drive (not required for booting) can be used by the common operating systems.
Here is the disk geometry of Seagate 3TB hard disk, factory-preformatted to one NTFS partition.
Thus the hard disk is still reading 512 bytes per sector physically but the controller of the external hdd enclosure changes it to 4096 bytes.
Note: sector size is 4096 (not 512)
Disk /dev/sdb: 3000.6 GB, 3000592977920 bytes
1 heads, 7 sectors/track, 104652377 cylinders
Units = cylinders of 7 * 4096 = 28672 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xa4b57300
Device Boot Start End Blocks Id System
/dev/sdb1 2 104652001 2930256000 7 HPFS/NTFS
Partition 1 does not start on physical sector boundary.
This 3TB USB disk is automatically mounted by Xp (32-bit), Win7 (64-bit) and Ubuntu (32-bit) and operates normally.