This is an old revision of the document!
List Create Delete Partitions On Mbr And Gpt Disks
General Information
About this page/how-to/script.
MBR
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
GPT
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