Disk Management | Create Partition Using fdisk in Linux environment

Disk Management | Create Partition Using fdisk in Linux environment
Normally in the windows system we can easily create the partition using disk management similarly In Linux by using fdisk command we can create and delete the partition.In this case I use pen drive for create & delete the partition.First mount the pen drive. For these purpose the user must have the root privileges first login to the root.
Use fdisk command to create partition in pen drive disk file /dev/sdb
Then it will ask to which thinks perform and it also contain help page:
Important commands
n->create new partition
d->delete partition
p->print partition

[root@localhost ~]# fdisk /dev/sdb
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n

Then if you give command
n ->create new partition then it will ask to create which type is it extended-e or primary-p
Primary->it is contain the OS file
Extended -> it is used to store the other user file
First create the primary partition then create extended partition
Command action
e extended
p primary partition (1-4)

p
Partition number (1-4): 1
First cylinder (1-1009, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1009, default 1009): +500M
I give the primary partition size is 500MB and partition Number is 1 other things I skip it.
Then create extended partition.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 4
First cylinder (252-1009, default 252):
Using default value 252
Last cylinder or +size or +sizeM or +sizeK (252-1009, default 1009): +1G

Give extended partition some large size because you can store your file in the extended and then you can create extended partition only one time the you can't create second extended partition. You can create only logical partition after creating extended partition.

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (252-752, default 252):
Using default value 252
Last cylinder or +size or +sizeM or +sizeK (252-752, default 752): +500M

And you can create the logical partition max range is 1GP because you allocate extended partition size is 1GP
Finally perform the all the thing print the partition table

Command (m for help): p
Disk /dev/sdb: 2019 MB, 2019557376 bytes
63 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 3906 * 512 = 1999872 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 251 490172 83 Linux
/dev/sdb4 252 752 978453 5 Extended
/dev/sdb5 252 502 490172 83 Linux

Before exit doesn’t forget give the command w it will save your partition other wise whenever you reopen the partition it does not contain the created partition.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 0: Success.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

Related post