
The fdisk command partitions a drive as MBR (master boot record). The gdisk command partitions a drive as GPT (GUID partition table). The parted command can partition a drive as either MBR or GPT. MBR is typically needed for systems with old hardware or software, because GPT is not backwards compatible with old hardware or software. gdisk or parted can be used if the system is using modern hardware and software. GPT is typically used if you need a create a partition greater than 2 TB.
The fdisk --list command can be used to view each parition and type. In this example, there are a variety of partition types, including an LVM partition and a RAID partition.
[root@server1 ~]# fdisk --list
/dev/sda1 83 Linux
/dev/sdb1 8e Linux LVM
/dev/sdc1 fd Linux raid autodetect
To create a new partition
Type fdisk /dev/xxx and press enter, where xxx is a device, such as /dev/sda or /dev/sdb.
[root@server1 ~]# fdisk /dev/sdb
Type p and press enter to print the partition table. Let's say you want to increase the size of the /dev/sda2 partition.
Command (m for help): n
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 510000 83 Linux
/dev/sda2 1026048 16894837 492871 8e Linux LVM
Type d to delete a partition and press enter. Don't worry - the data on the partition will not be lost if you follow the next steps.
Command (m for help): n
Select the partition you want to delete (2 in this example).
Partition number (1-4): 2
Type p and press enter to print the partition table. In this example, /dev/sda2 is no longer listed.
Command (m for help): n
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 510000 83 Linux
Type n and press enter to create a new partition.
Command (m for help): n
If you will have 1 - 4 partitions, each partition can be a primary partition. If you wil have 5 or more partition, partitions 1 - 3 can be primary, partition 4 must be extended, and then partitons 5 and above will be logical.
Select (default p): p
Select the partition number, where 1 is /dev/xxx1, 2 is /dev/xxx2, et cetera.
Partition number (2-4, default 2): 2
When prompted First sector, press enter to use the default first sector.
First sector (1234567-3456789, default 1234567):
When prompted Last sector, enter the size of the partition (such as +1GB or +512MB).
Last sector (1234567-3456789, default 1234567): +1GB
Type t and press enter to set the partition type.
Command (m for help): t
Type L to view all of the available codes. Type the code for the type you wish to use and press enter. For example, type 83 for Linux, 8e for Linux LVM (Logical Volume Group), or fd for Linux RAID auto.
Hex code (type L to list all codes): 8e
Type w and press enter to write the changes.
Command (m for help): w
Use the partprobe command to update the system to recongize the new partition.
~]# partprobe
Did you find this article helpful?
If so, consider buying me a coffee over at