linux_wiki:list_create_delete_partitions_on_mbr_and_gpt_disks

List Create Delete Partitions On Mbr And Gpt Disks

General Information

  • Disks with a MBR (master boot record) are limited to 4 primary partitions and 2TB max usable size.
    • Use fdisk or parted.
  • Disks with GPT lift both of these restrictions.
    • Use gdisk or parted.

List MBR partitions

fdisk -l /dev/sdb


Create MBR partitions

fdisk /dev/sdb
m (help)
n (add new partition)
p (primary)
default (partition number)
first sector (default 2048)
last sector: +20G (to have a 20G partition)
w


Change partition type

fdisk /dev/sdb
t
selected partition: 1
Hex code: 83 (linux)
w


Delete MBR partitions

fdisk /dev/sdb
d
Partition number: 1
w

List GPT partitions

gdisk /dev/sdb
p (print partition table)


Create GPT partitions

gdisk /dev/sdb
n
default (partition number): 1
first sector (default 2048)
last sector: +20G (to have a 20G partition)
Hex code type: 8300 default
w


Delete GPT partitions

gdisk /dev/sdb
d
Partition number (if more than one):2
w

Sometimes, after you create a new partition and write changes, you could see this message:

OK; writing new GUID partition table (GPT) to /dev/xvdf.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.


Instead of rebooting, inform the kernel that changes have been made on the disk:

partprobe /dev/xvdf

  • linux_wiki/list_create_delete_partitions_on_mbr_and_gpt_disks.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)