
click to enlarge
fdisk is a very popular command-line based Partition Manager. The command is invoked with the device which is going to be used for partitioning. For example, if you want to partition the disk at /dev/sda, then the relevant command would be "
sudo fdisk /dev/sda". This will open the /dev/sda disk for partitioning. Make sure to include just the disk device and not a specific partition like /dev/sda1.
Once you've invoked fdisk, it will open a small interactive command-line menu which will allow you to do various things regarding partitioning. Viewing the list of keys can be done by typing "p", then pressing the Enter/Return key. This will print a list of all keys used in fdisk. Check out the list of keys which will be used during any partitioning job:
n - Create new partition. Remember that you can only have 4 Primary partitions. The correct thing to do if you need more than 4 partitions is to create 3 Primary partitions and 1 Extended partition. The Extended partition can then hold multiple Logical partitions. Once you type "n" and press Enter/Return, it will ask you for a partition number. Assuming that the disk is completely empty, type 1. If you have created any partitions before, increment the number to type and then press enter. It will then ask for the first cylinder that it should use for the partition. You can safely type Enter and let it take the default value unless you want to create another partition in between. The next query will be about the last cylinder that it should use. You can also specify the size of the partition by typing +sizeK or +sizeM, for example, +500M. This will create a 500MB partition.
t - Set the type of partition. This can be used to change the partition type, for example Swap, Linux, Extended, Windows and so on.
a - Set the bootable flag on a partition.
d - Delete a partition. It will ask you for a partition number.
p - Print current partition table.
w - Write the modified partition table to disk.
q - Quit fdisk.