Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (10) AWS (5) numerology (5)

Thursday, March 2, 2017

Linux Query or Interview question - 3

Query 1. What is primary partitions on HDD.

We can create only 4 partition on HDD called as "Primary Partition" or "Physical Partition" & it is defined in partition table. 
There are two type of partition table.
a. MSDOS/MBR – Where limit is set as 4 for primary partitions
b. GPT – Where you can create 128 primary partitions

so the limit of creation of primary partitions is set in partition table type.
[root@testmachine ~]# parted -l /dev/sda
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start   End     Size    Type     File system  Flags
 1      1049kB  525MB   524MB   primary  ext4         boot
 2      525MB   21.5GB  20.9GB  primary               lvm
 3      21.5GB  31.1GB  9665MB  primary

In our example, we are having 3 partitions like /dev/sda1, /dev/sda2, /dev/sda3 etc.  

 [root@testmachine ~]# fdisk /dev/sda
Command (m for help): p
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           2         501      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             502       20480    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/sda3           20481       29697     9438208   83  Linux

If we want to create more than 4 partitions then we have to make 1 partition as extended out of 4 partitions. The use of extended partition is that it will create a boundary for extended and in that we can create multiple logical partitions.

Take example that our 4th partition is extended partition. Then /dev/sda4 will be used for that but it is just for name sake. It will not have data. The exact logical partition will start form /dev/sda5, /dev/sda7 etc…

If we want to create primary partition more than 4 then we have to use partition table type GPT where we can create 128 primary partitions.

We can change the partition table type from MSDOS to GPT by using “parted” command. Better to have a backup so data loss may not happen.


Query 2. Why we see HDD size less in OS.

The HDD manufacturers (like IBM, EMC, Dell, HP etc..) use the universal method of calculation . They divide the disk size by 1000.

Like 1GB= 1000MB

But in OS we divide the disk size by 1024. So the disk size is actually same but we may see less disk size when we use it in OS (Linux, windows etc..)

5GB = 5000MB (as per manufacturer)
5000MB/1024 = 4.88GB so in OS you will see disk size 4.88GB.


Thanks & Regards,
Kiran Jadhav




No comments:

Post a Comment