Differences between revisions 9 and 10
Revision 9 as of 2021-11-18 08:15:55
Size: 3001
Comment:
Revision 10 as of 2021-11-18 08:24:15
Size: 2964
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
'''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'''). '''Partition Tables''' are binary data written to a specific part of a disk drive. By reading this data according to the corresponding protocol, instructions for how to read and mount the disk drive can be programmatically determined. Generally this is the job of an operating system, not an end user or software programmer.
Line 5: Line 5:
You almost certainly don't want to stop at creating a partition table--take a look at [[Linux/FileSystems|setting up a file system]]. The modern protocol is '''GUID Partition Tables''' ('''GPT'''), part of the UEFI standard. Historically, the prevailing standard was '''Master Boot Record''' ('''MBR''').

Note the follow-up article for [[Linux/FileSystems|setting up a file system]].

<<TableOfContents>>
Line 13: Line 17:
`gdisk` is the Linux utility for formatting a drive. Older tutorials may recommend `fdisk`, which `gdisk` has superseded. '''`gdisk(8)`''' is the primary utility for formatting and partitioning a drive. Calling it starts a REPL.
Line 15: Line 19:
It is called by superuser on a device, and starts a REPL. Suppose we want to format `/dev/sde`: In order to format `/dev/sde`:
Line 18: Line 22:
$ gdisk /dev/sdX $ gdisk /dev/sde
Line 32: Line 36:
As the prompt suggests, `?` prints help. Some other useful commands: Some useful commands:
Line 46: Line 50:
Line 48: Line 53:
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(8)`''' is the predecessor to `gdisk(8)` and should only be used when GPT is not an option.

Accordingly, the first thing to do is to verify that a device is not using GPT. Check the 'Disklabel type' attribute shown in the printed partition table (see commands below).
Line 51: Line 58:
$ fdisk /dev/sdX $ fdisk /dev/sde
Line 61: Line 68:
As the prompt suggests, `m` prints help. Some other useful commands: Some useful commands:
Line 77: Line 84:

Linux Partition Tables

Partition Tables are binary data written to a specific part of a disk drive. By reading this data according to the corresponding protocol, instructions for how to read and mount the disk drive can be programmatically determined. Generally this is the job of an operating system, not an end user or software programmer.

The modern protocol is GUID Partition Tables (GPT), part of the UEFI standard. Historically, the prevailing standard was Master Boot Record (MBR).

Note the follow-up article for setting up a file system.


gdisk

gdisk(8) is the primary utility for formatting and partitioning a drive. Calling it starts a REPL.

In order to format /dev/sde:

$ gdisk /dev/sde
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): 

Some 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

fdisk(8) is the predecessor to gdisk(8) and should only be used when GPT is not an option.

Accordingly, the first thing to do is to verify that a device is not using GPT. Check the 'Disklabel type' attribute shown in the printed partition table (see commands below).

$ fdisk /dev/sde

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):

Some 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

Linux/PartitionTables (last edited 2021-11-18 08:24:15 by DominicRicottone)