Monday, June 29, 2015

Primary, Extended and Logical Partitions in RedHat/CentOS 7

Primary Partition


A primary partition is in which an Operating System can be installed. One MBR hard disk may contain a maximum of 4 primary partitions. An active partition is based on primary partition. Any one of the 4 primary partitions can be set as active partition. Since there can be 4 primary partitions with 4 different Operating Systems installed, one of the partition that is marked active is used for the initial booting.


Extended Partition


Because the primary only can be created four maximum, this need to use extended partition to break the limitation of 4 partitions. In an Extended Partition you can create unlimited logical drives. You can store data in the logical partitions similar with primary partition, but the extended partition is not used to store data, because the Extended Partition is used to hold logical partitions, at the same time, there is one extended partition on a disk.


Logical Partition

A logical partition is a a partition that has been created inside of an extended partition.





Primary Partion
Extended Partition
Logical  Partition
1
fdisk /dev/sdb
fdisk /dev/sdb
fdisk /dev/sdb
2
3
1
2
5
4
p   
e
l
5
press enter    
press enter    
press enter    
6
+200M         
+200M         
+150M         
7
t

t
8
83

8e     
9
p
p
p
10
w     
w     
w     
11


partprob /dev/sdb
12
mkfs.ext4 /dev/sdb1 

mkfs.ext4 /dev/sdb5 
13
mkdir /PARTITION1   

mkdir /PARTITION2 
14
vim /etc/fstab 
/dev/sdb1 /PARTITION1 ext4 defaults 0 0

vim /etc/fstab 
/dev/sdb5 /PARTITION2 ext4 defaults 0 0
15
mount -a   

mount -a   
16
df -h  

df -h  

Assume we have installed a new physical drive as "sdb" .The name can be vary on disk type and no of disks installed. 

sd - SCSI disks. and all removable data carriers.
eg - sda, sdb,sdc, ...

vd -Virtual disks on virtual server environment.
eg- vda, vdb, vdc, ...

1. Select the physical disk.

2. Press 'n' and Enter.

3. Set a unique no for disk partition. (note that server set next available unique no as disk partition no by default) 

4. Select the partition type( 'p' for primary, 'e' for extended and 'l' for logical) and press Enter. Note that when creating a logical partition, there should be a extended partition or else you have to configure it first.

5. Select the starting cylinder point. Set it with default value by pressing Enter.(Note that system set next free cylinder point by default)

6. Select the end cylinder point. It's difficult to figure out the end cylinder point no which need to create a required size of disk partition. So we set disk size instead of end cylinder point no and you can't go beyond the size of the physical disk. (I have set +200M to create 200MB partiton in given example)
eg :- +200     - 200Bytes 
        +200K   - 200KB
        +200M  - 200MB
        +200G  - 200GB

7. Type 't'. Then select the correct partition id and select the partition system type.

8. I have selected Linux for primary partition and Linux LVM for logical partition by typing "83" and "8e" id in given examples. you can list the ids by pressing 'l'

9 . List the created partitions on selected physical disk by pressing 'p' and Enter
You will see an output like follows...



Note that primary partition system is displays as "Linux" , Extended partition system is display as "Extended" and Logical partition system is display as "Linux LVM". (Note the device name of created partitions  )

10. Save the configuration by pressing 'w' and Enter.
End of creating extended partition. :) 

11. Enter given command to update the partition table specially when creating logical partitions.

12.Format the partition. Note that partitions has been formatted in ext4 format in given examples.

13. Create a mount point. This can be any location. I have created PARTITION1 for primary partition and PARTITION2 for logical partition inside '/'

14. Add given lines to fstab.



15. mount all partitions.

16. Verify by checking /PARTITION1 and /PARTITION2 is there in receiving output.










No comments:

Post a Comment