Remove swap partition after upgrading to Fedora 33


I just can’t understand why can’t I remove the swap partition after upgrading to Fedora 33. I have got ext4 filesystem in all partitions. I do the following steps:

  1. Boot up with a USB pen drive.
  2. Remove LVM swap partition.
  3. Extend LVM home partition.
  4. chroot to comment swap line in /etc/fstab so as not to mount it during boot up.

Everything is OK up to this point but Fedora freezes and doesn’t boot up. I have to roollback all changes in order to get Fedora working again. The funniest is that I didn’t uncomment swap line in /etc/fstab, however, it worked! Moreover, it is not used by Fedora any longer, since monitor app reports 5 GB of zram memory while I only have 1 GB of swap memory. I mean, swap partition must exists despite being useless!

What on earth is happening?


1 Like
# chroot
sudo -e /etc/default/grub
sudo grub2-mkconfig -o /etc/grub2$(test -d /sys/firmware/efi && echo -efi).cfg
sudo dracut -f --regenerate-all

Thanks vgaetera, but I wasn’t lucky. My computer is very old and uses BIOS, so in my case is:

It says “done”, however, not only it’s not done, but also now grub enters rescue mode and Fedora doesn’t boot.

error:…/…/grub-core/kern/dl.c:429: symbol grub_calloc not found
Entering rescue mode…
grub rescue>

When I try to reinstall grub2:

sudo dnf reinstall $(rpm --query --all | grep grub) $(rpm --query --all | grep shim)

I get:

Curl error (6): Couldn’t resolve host name for [Could not resolve host:]

Finally, if I do

grub2-install --directory=/boot /dev/sdc1 (/dev/sdc1 is my boot partition and is mounted in the chroot /boot directory), I get:

grub2-install: error: /boot/ does not exists. Please, specify --target or --directory.

Could this be a bug?

Please, help.


1 Like

You can use swapon --show to see swap information.

swapoff /dev/sdxy will disable that swap device. Then you can remove/comment line for swap from /etc/fstab, and remove/reallocate the partition, etc.

More details here: Swap - ArchWiki

You can temporarily configure DNS statically:

sudo mv -f /etc/resolv.conf{,.bak}
sudo tee /etc/resolv.conf << EOF

It looks like you should specify the target disk, not the partition.

To work around the grub2-probe errors, apply this fix from chroot:

sudo tee -a /etc/default/grub << EOF

Then repeat the above commands.

Thanks guys for your advice.

The problem was the order which I was doing things in. It was much simpler than everything I posted before. I summarize it all for everybody wanting to remove swap partition after upgrading to Fedora 33.

  1. Boot up your computer normally.
  2. Disable swap partition:
    # swapoff -va
  3. Rebuild grub2 configuration. Since /etc/default/grub still mentions swap partition, I decided to do something risky, but fortunately I hadn’t got any issue:
    # rm -rf /etc/grub2*
    # rm /etc/default/grub
    # dnf remove *grub2*
    # dnf install grub2-pc grub2-tools
    # grub2-mkconfig -o /boot/grub2/grub.cfg
    # grub2-install /dev/sdc ==> Your device here. Warning! Your device, not the partition as vgaetera said before.
    Perhaps it might be enough to make only a grub2-mkconfig instead of a full reinstallation of grub2 but, as I explained before, I didn’t trust because /etc/default/grub made references to swap partition. Anyway, I repeat that I hadn’t got any issue. Another thing to take into account is that I have got BIOS. You might need install grub2-efi instead, if your computer is more modern than mine.
  4. Remove swap partition.
    # lvremove /dev/mapper/vg_hogar_ssd-swap ==> your LMV here
  5. Delete swap line in /etc/fstab.
  6. You can now resize home partition by using a USB pen drive. My home partition is /dev/mapper/vg_hogar_ssd-home, so in my case I made:
    # lvextend --extents +100%FREE --resizefs /dev/mapper/vg_hogar_ssd-home
  7. You might need reinstall NVIDIA/AMD proprietary driver owing to step 3.
  8. Bye, bye, swap!

I hope this help others remove swap partition if they don’t need btrfs filesystem or don’t want to make a fresh install of Fedora 33.


Step 3 contains suboptimal advice. The only thing needed in this step is:

nano /etc/default/grub

Edit the GRUB_CMDLINE_LINUX line, remove the resume=UUID=<oldswapuuid> portion. And recreate the grub.cfg.

BIOS firmware:

grub2-mkconfig -o /boot/grub2/grub.cfg

UEFI firmware:

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

In particular on UEFI, running grub2-install can prevent it from booting.


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.