The swap partition that we have currently

[root@localhost ~]# swapon s

Filename Type Size Used Priority
/dev/sda2 partition 2096472 0 -1
Will show the no of partitions we have

[root@localhost ~]# fdisk -l

Disk /dev/sda: 47.2 GB, 47244640256 bytes 255 heads, 63 sectors/track, 5743 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/sda3 275 2610 18763920 83 Linux

For making new partitions

[root@localhost ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 5743. There is nothing wrong with
that, but this is larger than 1024,and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

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

Command action
e extended
p primary partition (1-4)

e

Selected partition 4
First cylinder (2611-5743, default 2611): Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-5743, default 5743): Using default value 5743

Command (m for help): n

First cylinder (2611-5743, default 2611): Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-5743, default 5743): +4G

We can see that a new partition of 4Gb is added but still we have to change its type
to swap.

Command (m for help): p

Disk /dev/sda: 47.2 GB, 47244640256 bytes 255 heads, 63 sectors/track, 5743 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/sda3 275 2610 18763920 83 Linux
/dev/sda4 2611 5743 25165822+ 5 Extended
/dev/sda5 2611 3097 3911796 83 Linux

Command (m for help): t

Partition number (1-5): 5

Hex code (type L to list codes): 82

Changed system type of partition 5 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sda: 47.2 GB, 47244640256 bytes 255 heads, 63 sectors/track, 5743 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 274 2096482+ 82 Linux swap / Solaris
/dev/sda3 275 2610 18763920 83 Linux
/dev/sda4 2611 5743 25165822+ 5 Extended
/dev/sda5 2611 3097 3911796 82 Linux swap / Solaris
Command (m for help): w

The partition table has been altered! Calling ioctl() to re-read partition table. The
kernel still uses the old table. The new table will be used at the next reboot.
Syncing disks.

If we want to use the newly created partition without rebooting then

[root@localhost ~]# partprobe

[root@localhost ~]# mkswap /dev/sda5

Setting up swapspace version 1, size = 4005675 kB

New entry about the partition that will act as swap will be made in fstab file.

[root@localhost ~]# vi /etc/fstab

[root@localhost ~]# mount a

[root@localhost ~]# swapon a

We can see the change in the swap.

[root@localhost ~]# swapon -s

Filename Type Size Used Priority
/dev/sda2 partition 2096472 0 -1
/dev/sda5 partition 3911788 0 -2