How to delete a second swap partition safely?

First of all I've tried to install Ubuntu , but something went wrong and the installation was interrupted. Then I tried to install again , and it was installed successfully.

And there was another partition about 600 Mb , but I removed it using Disk Utility .And I had to restore grub from a live CD.

but Why is /dev/sda4 now extended and contains 2 linux swap ?And how can I remove the other linux swap? and how to make it one Linux partition with one swap ?

enter image description here

enter image description here


When I try to remove /dev/sda5

Please unmount any logical partitions having a number higher than 5 . enter image description here


I'm not sure why your system ended up with 2 swap partitions, but it's easy to fix.

  • I recommend using gparted instead of fdisk or Disk Utility. You can delete the "extra" swap partition and resize the others to claim the freed disk space. It will also tell you if either swap partitions are being actually used or not. Very helpful. gparted is not installed by default, but it is available for install in the repositories. It is also pre-installed in Live sessions from the Ubuntu install CD/USB.

  • About the extended partition: using a traditional partition table, you can only have 4 primary ("non-extended") partitions. Since you already have 3 NTFS/Windows, and you need 2 more for Ubuntu (OS and Swap), this only can be done using an extended partition. So your 4 primary partitions are the 3 NTFS ones + Extended (the extended partition itself takes up 1 "slot"), and the other partitions are within the extended.

  • Using gparted, check the status of your swap partitions. If they are locked, it's being currently used by the system. Take note of their status, and decide which one you want to keep and which to delete. Also, right-click them both, go to information, and take note of their UUID (sudo blkid also works).

The possible scenarios are:

1 - The one you want to delete is NOT being used by the system: nice, just delete the partition.

2 - Both swaps are being used by the system: right-click it the one you want to delete, select Swapoff. To make that permanent, remove its entries from /etc/fstab and /etc/initramfs-tools/conf.d/resume (deleting the lines that match its UUID). Now you can safely delete the partition.

3 - Just the one you want to delete is being used, the one you want to keep is not: right-click the one you want to delete, select Swapoff. Right-click the other, select Swapon. Edit /etc/fstab and /etc/initramfs-tools/conf.d/resume, and replace the UUID from one to the other. Delete the unwanted partition.

If any changes are made to /etc/initramfs-tools/conf.d/resume, use the following command to apply the changes:

sudo update-initramfs -u

If you have any question about the answer, feel free to ask!


Identify your partition using

sudo blkid

and look at /etc/fstab to see which swap partition is use

grep swap /etc/fstab

Then delete the old swap partition, graphically with gparted or from the command line with fdisk.

If you wish to resize partitions, I suggest you do so with gparted from a live CD.


What you get from the screenshots is that there are indeed two partitions that have been designated as swap partitions. Whether they are both used can be determined by running free.

For example, the output of free has the lines

Swap:      4200000          0    4200000

This means that there is one or more swap partitions totaling to about 4.2GB of swap space.

You can use free to establish whether both partitions are used as swap, or just one of them.

Then, you can select which one to deactivate, by running (for the second swap)

sudo swapoff /dev/sda7

Once deactivated, you can use the Disk Utility to erase the partition.

When your computer boots up, it runs the command sudo swapon -a which activates all available swap partitions. Therefore, simply the removal of one of the swap partitions is enough to complete the work. No further action/configuration is required.