How to know if /dev/hda2 is Primary partition or Extended partition

10,982

Solution 1

From terminal, you type parted /dev/hda then type print as result:

Number  Start   End    Size   Type     File system  Flags     
 1      32.3kB  107MB  107MB  primary  ext3         boot, raid
 2      107MB   250GB  250GB  primary               raid 

Solution 2

Check the output of fdisk -l /dev/hda or a similar tool (sfdisk -l /dev/hda, parted -l, …).

You can't tell whether a partition is primary or extended from its number. In the classic PC partition scheme, each partition numbered 1, 2, 3 or 4 can be either primary or extended. (It's possible but not recommended to have multiple extended partitions; Linux itself doesn't mind but some management tools do.)

There's an almost-guaranteed way to check without root access: you can look up the size of each partition in /proc/partitions. The size of extended partitions is always reported as a single block. For instance, in the example below, sda4 is an extended partition.

major minor  #blocks  name
…
   8        1     489951 sda1
   8        4          1 sda4
Share:
10,982

Related videos on Youtube

Abdennour TOUMI
Author by

Abdennour TOUMI

Instructor of Course Run Kubernetes on AWS with EKS. Certified: 🥇 CKA - Kuberntes administrator k8s 🥇 CKAD - Kuberntes App Dev k8s 🥇 AWS DevOps Engineer - Professional devops aws 🥇 Professional Cloud Architect - Google Cloud google-cloud-platform 🥇 AWS Solutions Architect - Professional architecture aws 🥇 Red HAT Certified in Ansible Automation ansible devops 🥇 Red HAT Certified in Openshift Administration ocp 🥇 Red HAT Certified in Openshift App Development ocp 🥇 Red HAT Certified Engineer redhat 🏅 AWS Solutions Architect - Associate architecture 🏅 AWS SysOps Administrator - Associate aws 🏅 AWS Developer - Associate aws 🏅 Linux Professional Institute (LPIC-1) linux 🏅 Professional ReactJS Developer (Udacity Nanadegreee) react frontend 🏅 Fullstack web Developer (Udacity Nanadegreee) python flaskrest Top 1 Stackoverflow reputation in my country Tunisia since 2017 Read more about me: in.abdennoor.com

Updated on September 18, 2022

Comments

  • Abdennour TOUMI
    Abdennour TOUMI over 1 year

    If all four primary partitions exist on an IDE drive, they are numbered as follows:

    • /dev/hda1
    • /dev/hda2
    • /dev/hda3
    • /dev/hda4

    We have also the partitions on a disk with one primary partition and the sole extended partition might be numbered as follows:

    • /dev/hda1 (primary)
    • /dev/hda2 (extended)

    This naming strategy leads to confusion :
    How it is named : /dev/hda2 in both of cases :

    • Primary partition
    • Extended Partition

    Another way to express the issue : How to distinct if it is primary or extended partition

  • Abdennour TOUMI
    Abdennour TOUMI almost 10 years
    cfdisk Does not existed on red-hat . There is sfdisk
  • makos
    makos almost 10 years
    Can't you download it from repositories?