I installed Debian Jessie with default partitioning on my SSD drive. My current disk partitioning looks like this:
As I have 16GB of RAM, I assume I don't need swap. But since I have other disk drives I may create a swapfile for example, on one of the other drives instead.
Can you tell me what steps I should take to remove the swap partition correctly and permanently for it not to occupy disk space? I wish to delete the swap partition as I currently have only 128GB SSD.
Here is what I tried and rebooted each time; each of these steps being not permanent, or did not do anything:
-
Using the
swapoff
utility:swapoff --all
-
Using the GParted utility:
Right-clicking the swap partition and clicking Swapoff.
-
Commenting out the swap partition's UUID in the following file:
/etc/fstab
-
Commenting out the swap partition's UUID in the following file:
/etc/initramfs-tools/conf.d/resume
-
Running these commands in the end (both in this and the opposite order):
update-grub update-initramfs -u
Best Answer
If you have GParted open, close it. Its Swapoff feature does not appear to to be permanent.
Open terminal and become
root
(su
); if you havesudo
enabled, you may also do for examplesudo -i
; seeman sudo
for all options):Turn off the particular swap partition and / or all of the swaps:
Make 100% sure the particular swap partition partition is off:
Open a text editor you are skilled in with this file, e.g.
nano
if unsure:Comment out / remove the swap partition's UUID, e.g.:
Open a text editor you are skilled in with this file, e.g.
nano
if unsure:Comment out / remove the previously identified swap partition's UUID, e.g.:
Don't close the terminal as you will need it later anyway.
Note: The next steps differ depending on, whether you rely on CLI or GUI.
GUI:
Open up GParted, either from menu, or more conveniently from the terminal we have opened:
If you don't have it installed, you may do so; afterwards run the previous command again:
Choose your drive from top-right menu.
As the GParted reactivates the swap partition upon launch, you will have to right-click the particular swap partition and click Swapoff -> This will be applied immediately.
Delete the swap partition with right click -> Delete. You must apply the change now.
Resize your main / other partition with right click -> Resize/Move. You must apply the change now.
Back to the terminal, let's recreate the boot images:
Update GRUB:
You may reboot now if you wish to test that the machine boots up.
Encryption note: If your swap partition is encrypted, then you also need to comment out the related line in
/etc/crypttab
, otherwise CryptSetup will keep you waiting for 90 seconds during boot time. Thanks frank for this addition.CLI:
I will check in VMs if my solution works, then I will share it. In the meantime, see this answer.