Hard disks can be divided into one or more logical disks called partitions. This division is described in the partition table found in sector 0 of the disk.
Linux needs at least one partition, namely for its root file system. It can use swap files and/or swap partitions, but the latter are more efficient. So, usually one will want a sec-
ond Linux partition dedicated as swap partition. On Intel compatible hardware, the BIOS that boots the system can often only access the first 1024 cylinders of the disk. For this
reason people with large disks often create a third partition, just a few MB large, typically mounted on /boot, to store the kernel image and a few auxiliary files needed at boot time,
so as to make sure that this stuff is accessible to the BIOS. There may be reasons of security, ease of administration and backup, or testing, to use more than the minimum number of partitions.

The device is usually /dev/sda, /dev/sdb or so. A device name refers to the entire disk. The old systems without libata (a library used inside the Linux kernel to support ATA host
controllers and devices) make a difference between IDE and SCSI disks. In such a case the device name will be /dev/hd* (IDE) or /dev/sd* (SCSI).

The partition is a device name followed by a partition number. For example, /dev/sda1 is the first partition on the first hard disk in the system. See also Linux kernel documentation
(the Documentation/devices.txt file).

To create  partition we are using fdisk program. fdisk  (in  the  first  form  of  invocation)  is a menu driven program for creation and manipulation of partition tables. Lets start with example. Run below command on your shell prompt with root user.

fdisk -l

It will list the available disks and partition tables for the specified devices and then exit.  If no devices are given, those mentioned in /proc/partitions (if that exists) are used.

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

In above output we have  disk named as /dev/sdc with size of 1073 MB (1GB), which has no partitions.  Below command will let you create partition on /dev/sdc disk. Lets  move ahead and create partitions:

fdisk /dev/sdc

fdisk program will print some warning message and drive you on below prompt:

Command (m for help):

Type ‘m’ for help, which will print help menu Command action like below :

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)

Type ‘n’ to create new partition on /dev/sdc. It will ask you for partition type (primary or extended )and it’s number.

Command (m for help): n
Command action
 e extended
 p primary partition (1-4)

Type ‘p’ for primary partition and ‘e ‘ for  extended, In this case type ‘p’ and select partition no as ‘1’ :

Command (m for help): n
Command action
 e extended
 p primary partition (1-4)
p
Partition number (1-4): 1

Now it will ask for First cylinder by default it will take 1 number.  Leave it blank and press enter:

 

First cylinder (1-130, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130):

Now enter partition size in  cylinders or size in MB KB and GB. In our case in MB’s , We are creating partition of 200MB so we will type below –  ‘+200M’:

Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +200M

Now it will throw you on main fdisk command prompt. Now type ‘p’ and enter check partition table:

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1a84f581

Device Boot Start End   Blocks    Id   System
/dev/sdc1   1     26    208813+   83   Linux

It will show you the newly created partition as  /dev/sdc1 with the partition Id 83 which is Linux.  you can list known partition types by typing l on fdisk command prompt and change the partition type by typing ‘t’ which we will see later. To add more partition follow the same procedure again.
For now we will  write table to disk and exit by typing ‘w’

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Now it will print above message and dump you on your shell prompt.
Now check whether new partition is created or not by typing below command :

fdisk -l /dev/sdc
Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1a84f581

 Device Boot Start End Blocks Id System
/dev/sdc1 1 26 208813+ 83 Linux

Here we can see our new partition as /dev/sdc1
If you do not see newly created partition after executing fdisk -l /dev/sdc command the run:

partprobe

partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.

Now you will be able to see your partition, if not then there is some problem.

Now we have to create filesystem on /dev/sdc1. mke2fs is used to create an ext2, ext3, or ext4 filesystem, usually in a disk partition. device is the special file corresponding to the device (e.g /dev/hdXX). blocks-count is the number of blocks on the device. If omitted, mke2fs automagically figures the file system size.

mke2fs -j -t ext3 /dev/sdc1

It will dump something like this.

mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
52208 inodes, 208812 blocks
10440 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
26 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks: 
 8193, 24577, 40961, 57345, 73729, 204801

Writing inode tables: done 
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

We used -j and -t options to mke2fs command.
-j to create the filesystem with an ext3 journal. If the -J option is not specified, the default journal parameters will be used to create an appropriately sized journal (given the
size of the filesystem) stored within the filesystem. Note that you must be using a kernel which has ext3 support in order to actually make use of the journal.
-t fs-type to specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that is to be created. If this option is not specified, mke2fs will pick a default either via how the command was
run (for example, using a name of the form mkfs.ext2, mkfs.ext3, etc.)

Now we are ready to use our new partition. Mount the partition by executing following  command:

mount -t ext3 /dev/sdc1 /mnt
Free Web Hosting