Linux / UNIX : How to create extended partition using fdisk

Whats is a disk partition

Partitioning divides a disk drive into one or more logical disks. Each partition is treated as a separate disk with its own file system. Partition information is stored in a partition table. There are 2 types of partitions that can be created using the fdisk utility :

  1. Primary Partitions
  2. Extended Partitions

Primary Vs extended partitions

– The original partitioning scheme for PC hard disks allowed only four partitions, called primary partitions.
– To create more than four partitions, one of these four partitions can be divided into many smaller partitions, called logical partitions. When a primary partition is subdivided in this way, it is known as an extended partition.

Creating extended partition using fdisk

We will assume that you are creating the first extended partition on the disk. To get a listing of your current partition scheme use ‘fdisk -l’.

1. Use the option n in the fdisk command to create your first extended partition on the disk /dev/sdc.

# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n

2. Next create your extended partition by selecting ‘e‘. It will automatically select the next available partition on the drive. In our case the next available partition is 2.

Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): e
Partition number (2-4, default 2): 2

3. Now, we have to select the stating point for our partition. By default the system will choose the next available cylinder on the disk. You can press enter here to select the default value.

First sector (20973568-41943039, default 20973568):     ### press ENTER Here 
Using default value 20973568

4. On the next step, you can select the size of your new partition, for example, to make a 1 GB partition you would set the command: +1024M.

Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte)
            2^N: K  (KibiByte), M  (MebiByte), G  (GibiByte)
Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039): +1024M
Partition 2 of type Extended and of size 1 GiB is set

5. This will then take you back to the command line where you can see your newly created partition. The last line is the newly created extended partition as you can see it is listed in blocks rather than megabytes and the partition ID type automatically defaults to Extended which will allow you to create your filesystem on that partition.

Command (m for help): p

Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos
Disk identifier: 0xacbed9c3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    20973567    10485760   83  Linux
/dev/sdc2        20973568    23070719     1048576    5  Extended

6. Finally save and exit fdisk with the write/quit command (w). Changes will be permanent after this command is executed.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

7. Run the partprobe command to scan the newly modified partition table:

# partprobe

If partprobe does not identify the newly modified table then a reboot will be required. You can also run the command “fdisk -l” to verify the new partition.

# fdisk -l /dev/sdc

Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos
Disk identifier: 0xacbed9c3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    20973567    10485760   83  Linux
/dev/sdc2        20973568    23070719     1048576    5  Extended
Related Post