Skip to content. | Skip to navigation

Navigation

You are here: Home / Support / Guides / Tools / Multiboot USB / GPT

Personal tools

Multiboot USB

Booting from multiple ISOs on one USB

GPT

Create the GPT Disk Label

parted manipulates (GPT) disk labels. Here we really have two choices: gpt and msdos (for when you want to revert!):

# parted /dev/sda
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) quit
Information: You may need to update /etc/fstab.

Or you can do a one-liner:

# parted /dev/sda mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? y
Information: You may need to update /etc/fstab.

(rather annoyingly it asks you Yes or No.)

You can check what you've done with the print command, abbreviated to p:

# parted /dev/sda p
Model: SanDisk Ultra Fit (scsi)
Disk /dev/sda: 30.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags

The important bit being Partition Table: gpt.

Note

If you do decide to revert (parted /dev/sda mklabel msdos) then you've done nothing with the GPT data and any subsequent GPT-aware command will mutter darkly about a valid GPT (or even an invalid primary GPT but a valid secondary GPT).

Going back to the old ways isn't covered by this article.

Create the Partitions

Which Partitions?

A quick recap: we need an EFI System Partition, ESP, which must be FAT32 (or FAT16 ...) and is probably a few hundred MiB; and another partition, the rest of the disk, which must be able to handle our 4.2GiB CentOS DVD ISO. We'll use xfs as the filesystem for that.

The choice of filesystem is fairly arbitrary. xfs is pretty elderly but is also understood by lots of things including GRUB2.

Note

CentOS 7.x seems to default to using xfs for regular partitions during install -- who knows why.

gdisk

gdisk is the GPT fdisk so we end up using it in pretty much the same way. The only thing to note is that the partition types are 16 bits (four hex digits).

We'll create the ESP partition first then the xfs one (comments inline):

# gdisk /dev/sda
...
n              - new partition
[RET]          - default 1
[RET]          - default start sector
+500M
ef00           - EFI System Partition
n              - new partition
[RET]          - default 2
[RET]          - default start sector
[RET]          - default end sector
[RET]          - default type (Linux)
w              - write
y              - JFDI!

Note

I don't think the ESP partition has to be partition number one nor even the first partition on the disk. Not on my box, anyway.

Note

If you were looking closely you might have noticed that the start of partition 1 was sector 2048 which is a long way from the start of the disk. This is due to alignment calculations.

It is now and only now that you can violate the alignment calculations and create a partition that starts at sector 32 and extends to sector 2047.

There is mooted use for this in a MBR/GPT and/or BIOS/UEFI mashup where you may need a "BIOS Boot Partition", type ef02, to solve some problems.

Finally, we can run gdisk again to show the final setup:

# gdisk /dev/sda -l
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
 MBR: protective
 BSD: not present
 APM: not present
 GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 60062500 sectors, 28.6 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 6876BFCF-A00A-4F4F-A10F-680A77B2E85D
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 60062466
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
  1            2048         1026047   500.0 MiB   EF00  EFI System
  2         1026048        60062466   28.2 GiB    8300  Linux filesystem

Just out of interest we can run parted again:

# parted /dev/sda p
Model: SanDisk Ultra Fit (scsi)
Disk /dev/sda: 30.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name              Flags
 1      1049kB  525MB   524MB   fat16        EFI System        boot
 2      525MB   30.8GB  30.2GB  xfs          Linux filesystem

Notice the extra boot flag that has appeared?

Document Actions