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
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 3
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 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.
Related videos on Youtube
Ryan McClure
Updated on September 18, 2022Comments
-
Ryan McClure over 1 year
Running Ubuntu 15.04. I was receiving messages about my root
/
partition running out of space, and so I looked up how to allocate more space to it. I followed the answer to this question: How to extend my root (/) partition?After turning swapoff, deleting the
swap
parition, and hittingApply all operations
, I executed the commandsudo resize2fs /dev/sda10
(in my case, I used sda8, as it is myroot
partition) and it said: The filesystem is already 2441472 (4k) blocks long. Nothing to do! . I restarted the machine, and once it reached the Ubuntu screen with the loading dots it stayed there for about 2 minutes before proceeding to the login screen.I figured I messed something up with the boot process, so I thought I'd recreate the swap space. I opened up GParted and created a new parition in the unallocated space, allocated it as
swap
, hitswapon
,Apply all operations
, and restarted. Same thing happens. Every time I restart or do a fresh boot, it hangs on the loading screen for a good 2-3 minutes and then proceeds to the login screen.I don't see why deleting the swap partition would have messed with the boot, as I understand it is only really used for hibernation.
-
boshra about 9 yearsHave you checked your /etc/fstab to make sure that after deleting (and recreating) the swap partition everything is in place and mounted properly on boot?
-
-
Ryan McClure about 9 yearsCommenting out the swap entry in
/etc/fstab
fixed the boot problem. Thanks! -
aarn over 7 yearsThanks lxg. I have been dual-booting ubuntu-type OSs on 'modern systems' these past couple of years. Always annoying when the first installed system would take >1min 30 sec to boot. Your suggestion to delete swap entries from /etc/fstab, then delete swap partitions using Gparted, did the trick.
-
Torrien over 5 yearsThanks... I knew that this was the problem but I couldn't find where erase the partition. Thanx.
-
Stefan over 3 yearsAlso during boot for a very short time it will show a message: Gave up waiting for suspend/resume device
-
Stefan over 3 yearsAlso, after changing the resume file described in this answer I had to run the command: update-initramfs -u
-
thomasrutter over 2 yearsThanks for this, this extra delay when booting was driving me crazy and this fixed it
-
karthik nair over 2 yearsThank you so much man, i don't really know how to thank you.