How to partition disk using fdisk

List partitions on the disk device

sudo fdisk -l /dev/sda

Enter command mode to work on disk’s partitions

sudo fdisk /dev/sda

Type m and press Enter to see a list of available commands

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change partition system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Type p to print the current partition table

Command (m for help): p
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000564f5
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   968386559   484192256   83  Linux
/dev/sda2       968388606   976771071     4191233    5  Extended
/dev/sda5       968388608   976771071     4191232   82  Linux swap / Solaris

Create a partition
Type n to create a new partition. You can create a logical partition by typing l, or create a primary partition by typing p. Next, you have to specify the sector of the disk you want the partition to start at. Press Enter to accept the default sector (the first free sector on the disk). After specifying the first sector of your partition, you have to specify the last sector. If you want to use up all available space after the initial sector, just press Enter or you can specify a specific size, such as +10G or +512M.

Command (m for help): n
Partition type:
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)

see also view hard drive partitions with fdisk and parted