Linux Partition Tables

Partition Tables are parts of a disk drive that an operating system reads in order to understand how to read the rest of that disk drive. There are many historical standards, but in modern terms we are referring exclusively to GUID Partition Tables (GPT), part of the UEFI standard. Historically, the prevailing standard was Master Boot Record (MBR).

You almost certainly don't want to stop at creating a partition table--take a look at setting up a file system.


gdisk

gdisk is the Linux utility for formatting a drive. Older tutorials may recommend fdisk, which gdisk has superseded.

It is called by superuser on a device, and starts a REPL. Suppose we want to format /dev/sde:

$ gdisk /dev/sdX
GPT fdisk (gdisk) version 1.0.4

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

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): 

As the prompt suggests, ? prints help. Some other useful commands:

Command

Action

o

Create a new GPT (i.e. Delete all partitions)

d

Delete a partition

n

Create a partition

p

Print partition table

l

List known partition types

w

Write partition table to disk and exit

q

Exit


fdisk

If you are using fdisk, chances are that you cannot use GPT. So the first thing to do is verify that your device is not using GPT. Check the 'Disklabel type' attribute shown in the printed partition table (see commands below).

$ fdisk /dev/sdX

Welcome to fdisk (util-linux 2.35.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):

As the prompt suggests, m prints help. Some other useful commands:

Command

Action

g

Create a new GPT (i.e. Delete all partitions)

o

Create a new MBR (i.e. Delete all partitions)

M

Coerce partition table into MBR

d

Delete a partition

n

Create a partition

a

Apply the boot flag to a partition

p

Print partition table

t

Change partition type

l

List known partition types

w

Write partition table to disk and exit

q

Exit


CategoryRicottone