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

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 

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