How to restore a swap partition


If you accidentally deleted your swap partition then don't worry you can easily restore it by following these steps:

  • First of all, open GParted and find the hard drive you want to create the swap partition. From the file menu press Gparted-->Devices-->[The hard drive you want].
  • Once you pick your hard drive, you will either have to resize a partition or use an unallocated space from that drive to create your swap partition.
    • To resize a partition, make sure the partition is not current in use (if it does you will need to use a Live CD) and then right click and select Resize Partition. Pick the size you want to remove (preferably leave the empty space to the end of the selected partition)
    • Once you have an unallocated space (Usually 2-4GB are enough), right click that space and select "New". From the new partition dialog make sure to select the filesystem as "linux-swap", then pick the size you want and at last press the button "Add".
    • The last step to create the swap partition is to apply all the changes you made so far by going to Edit-->Apply All Operations (this might take a while depending on your system and changes).
  • Now that you have a swap partition ready, you need to activate it. To do that right click on it and select "Swap on".
  • Unless you removed the swap partition entry from fstab, it should still be in /etc/fstab. Check from the terminal with:

    $ grep swap.*sw /etc/fstab

    and you should see a long line like:

    UUID=adc15cab-1cd4-4278-9a1d-59016cced6dd none swap sw 0 0

    If you do not see such a line, obtain the UUID using

    $ sudo blkid | grep swap

    and then add a line in this format to /etc/fstab.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>