CHECK OUT HOW TO DELETE SWAP PARTITION IN LINUX .

In this post we will learn how to delete swap partitions in Linux.

 

  • First check how many partition you have in your system  by fdisk -l command . And you can see /dev/sda5 is  my swap partition that  i want to delete .
[root@deepit ~]# fdisk -l
Disk /dev/sda: 50.9 GB, 50985402368 bytes
255 heads, 63 sectors/track, 6198 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        5099    40957686   83  Linux
/dev/sda2            5100        5736     5116702+  82  Linux swap / Solaris
/dev/sda4            5737        6198     3711015    5  Extended
/dev/sda5            5737        5798      497983+  82  Linux swap / Solaris
  • Before going further check whats size of swap by free -m command .
[root@deepit ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1772        404       1368          0         30        276
-/+ buffers/cache:         96       1676
Swap:         5483          0       5483
  • First we have to deactivate swap  before deleting /dev/sda5
[root@deepit ~]# swapoff /dev/sda5
  • Now check by free -m command your swap memory will be reduced .
[root@deepit ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1772        404       1368          0         30        276
-/+ buffers/cache:         96       1675
Swap:         4996          0       4996
  • Now let’s delete swap partition .
[root@deepit ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 6198.
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)
  • Type command “d” for deleting a partition . Then it will ask which partition you wanna delete .
Command (m for help): d
Partition number (1-5): 5
  • After that check by ” p “command (to print) your partition is been removed or not .
Command (m for help): p
Disk /dev/sda: 50.9 GB, 50985402368 bytes
255 heads, 63 sectors/track, 6198 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        5099    40957686   83  Linux
/dev/sda2            5100        5736     5116702+  82  Linux swap / Solaris
/dev/sda4            5737        6198     3711015    5  Extended
  • Now type command ” w “ to save .
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 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
  • Don’t forget to hit partrobe command . To save whatever changes happen in /dev /sda command .
[root@deepit ~]# partprobe /dev/sda
  • Now if you check by fdisk -l command your partition will be removed .
[root@deepit ~]# fdisk -l
Disk /dev/sda: 50.9 GB, 50985402368 bytes
255 heads, 63 sectors/track, 6198 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        5099    40957686   83  Linux
/dev/sda2            5100        5736     5116702+  82  Linux swap / Solaris
/dev/sda4            5737        6198     3711015    5  Extended

CHECK OUT MY VIDEO , IF YOU GOT ANY PROBLEM .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s