Deleted Swap, now boot takes forever

Solution 1:

If you want to remove the swap partition, you should first try by commenting its entry in /etc/fstab, then reboot.

As for the long boot time, it may be that one of your filesystems has been damaged. As soon as your system is up, run the appropriate fsck.* command for each of the file systems. If it reports errors, it will usually recommend how to fix them.

(Btw, running a system without swap is perfectly normal. I'm doing this since several years – these days, common machines have enough RAM.)

Solution 2:

From Terminal run

    sudo blkid

Then

    cat /etc/fstab

Double check that the fstab entry for swap partition matches all entries in the blkid

Your fstab entry should look something like this=>

    UUID=your/UUID/here none      swap    sw        0       0

If they don't match with each other, change UUID in fstab using your preferred text editor, to match the one you get from command sudo blkid. Then reboot and you'll see the effect.

Solution 3:

You may also need to edit the /etc/initramfs-tools/conf.d/resume file and comment out any references to the deleted Swap partition

sudo nano /etc/initramfs-tools/conf.d/resume
#RESUME=UUID=2854a8db-6494-44ac-9cee-974714bb0b00

Afterwards, run update-initramfs -u (thanks @Stefan)

I commented out the swap entries in /etc/fstab and the slow boot wasn't resolved. I also made sure that my swap wasn't encrypted, since no /etc/crypttab existed as suggested by @ankit7540. In the end, i came across this error message while installing a virtualization package and this gave me the right direction

W: initramfs-tools configuration sets RESUME=UUID=2854a8db-6494-44ac-9cee-974714bb0b00
W: but no matching swap device is available.

From the docs:

The initramfs is an cpio archive. At boot time, the kernel unpacks that archive into ram, mounts and uses it as initial root file system. From there on the mounting of the real root file system occurs in user space.

resume
      The resume hook tries to autodetect the resume partition and uses  the  first  swap
      partition   as  valid  guess.  It  is  possible  to  set  the  RESUME  variable  in
      /etc/initramfs-tools/conf.d/resume.  The boot variable noresume overrides it.

In simpler words, since a swap partition is a requirement for hibernation in Ubuntu, it makes sense that it'll be defined in some boot config as the RESUME parition and the boot process will look for it.

Solution 4:

I had about the same problem. When I removed my swap partition, the system kept booting very slowly. Although my situation was different from that of the OP, I hope it will be useful to others. I'm adding it here because this was my first hit when searching for solutions.

For me commenting out the relevant line in /etc/fstab as indicated by other answers did not yet solve it. It turned out that I had an encrypted swap partition enabled, which may be the default if your home directory is encrypted.

Look at /etc/crypttab, and comment out any lines referring to a partition that no longer exists. For me, removing this line reduced the boot time from ~3 minutes to the usual < 1.