Swap: From partition to file, now get "no matching swap device is available"

25,293

Solution 1

That line is in /etc/initramfs-tools/conf.d/resume so try deleting it.


The file in question, /etc/initramfs-tools/conf.d/resume, hasn't even existed in an Ubuntu LTS release since 14.04. Deleting the one line it contained on an 18.04 system will never cause a problem. This is a great example of why a reinstall is preferable to an upgrade, sometimes old things get left which can later cause problems.

As for those who think blkid will produce anything at all for a swapfile, you are wrong, and the answer which suggest using blkid is non-responsive to the stated problem. Reread the question, there is no longer a swap partition.

As a comment suggested, a UUID for the swapfile may be produced with swaplabel, but it is left as an exercise for the reader to see if using that swapfile UUID in a configuration file which is no longer part of the Ubuntu system will actually fix anything, or just result in another UUID lookup failure.

Solution 2

Step 1:

$ sudo blkid

It will list get UUID of each device or partition on your system. Copy the UUID of swap partition.

Step 2:

$ sudo vim /etc/initramfs-tools/conf.d/resume

Replace the available UUID with paste the UUID which you just copied and save it.

Step 3:

$ sudo update-initramfs -u
Share:
25,293

Related videos on Youtube

rkeating
Author by

rkeating

Updated on September 18, 2022

Comments

  • rkeating
    rkeating over 1 year

    Running Ubuntu 18.04, I changed from a swap partition to a swap file.

    swapon -s (summary) and free show the swapfile with the new size. /etc/fstab was changed, permission on the swapfile changed and the swap partition was deleted. When there are updates (apt-get update and upgrade), I get this error:

    Setting up amd64-microcode (3.20180524.1~ubuntu0.18.04.2) ...
    update-initramfs: deferring update (trigger activated)
    amd64-microcode: microcode will be updated at next boot
    Processing triggers for libc-bin (2.27-3ubuntu1) ...
    Processing triggers for initramfs-tools (0.130ubuntu3.1) ...
    update-initramfs: Generating /boot/initrd.img-4.15.0-29-generic
    W: initramfs-tools configuration sets RESUME=UUID=c5a2c6f4-b67c-4d95-bc23-8333ed6c0f11
    W: but no matching swap device is available.
    

    The UUID listed there is for the old swap partition. I didn't think a swap file has a UUID, but I am not sure about that. Everything else seems to work fine. How should I proceed to troubleshoot and fix this?

    • oldfred
      oldfred almost 6 years
      What does this show? sudo swapon --show? And: ls -lh /swapfile
    • rkeating
      rkeating almost 6 years
      outputs are: NAME TYPE SIZE USED PRIO /swapfile file 3G 0B -2 and -rw------- 1 root root 3.0G Jul 10 13:00 /swapfile
    • oldfred
      oldfred almost 6 years
      Those look essentially the same as mine. What does fstab show? Post above to preserve formatting. cat /etc/fstab
    • rkeating
      rkeating almost 6 years
      Tried to post it above, but text was huge. Just going to put the last lines (about swap) here: # swap was on /dev/sdb5 during installation #UUID=c5a2c6f4-b67c-4d95-bc23-8333ed6c0f11 none swap #sw 0 0 # swap now in /swapfile /swapfile none swap sw 0 0
    • mook765
      mook765 almost 5 years
      It's not an error, W: stands for Warning.
  • sudodus
    sudodus almost 6 years
    +1 Yes. Delete it or replace with RESUME=NONE or make it a comment (put a # in the beginning of the line).
  • rkeating
    rkeating almost 6 years
    Deleted it, reboot, reran apt update and upgrade. initramfs updated with no errors. Thanks!
  • Serge Stroobandt
    Serge Stroobandt about 5 years
    RESUME=NONE does not work on Ubuntu LTS 18.04. Deleting the line or RESUME= does work.
  • Marc Vanhoomissen
    Marc Vanhoomissen about 4 years
    Perfect, but how is this related to no matching swap device available?
  • Gryu
    Gryu almost 4 years
    'sudo swaplabel /swapfile' will actually show the UUID of swap FILE. sudo blkid shows partitions, not /swapfile. At least it is so in my case. Do you have a /swapfile created?
  • Sam Protsenko
    Sam Protsenko almost 4 years
    This is the correct answer
  • Aries VII
    Aries VII almost 4 years
    this should be the accepted answer. I hate those lazy "Delete it" answers.
  • Eric
    Eric almost 4 years
    this screws up new debian and ubuntu installs. the answer below fixes it properly... just do that.
  • dovetalk
    dovetalk almost 4 years
    This answer is terrible advice. Please don't just delete stuff from Linux that you don't understand. How this is the accepted answer is baffling. Instead, follow the instruction in the other answers on using blkid to determine the correct swap partition UUID and substitute that!
  • dovetalk
    dovetalk almost 4 years
    This has nothing to do with the problem, which is the RESUME swap partition in /etc/initramfs-tools/conf.d/resume. Not /etc/fstab!
  • Laurent Simon
    Laurent Simon over 3 years
    This answer is invalid for this case. The OP stated: "The UUID listed there is for the old swap partition. I didn't think a swap file has a UUID". He is right. If he does not use a swap partition anymore, but a swap file, then there is no more UUID to deal with. So, this answer is out of purpose for this case. But, it can be useful for those that use a swap partition...
  • DanglingPointer
    DanglingPointer over 2 years
    This is an incorrect answer for distros that have moved to using a swapfile.
  • Tofandel
    Tofandel over 2 years
    This answer is also not fully correct, first I had this file on Ubuntu 16.04 which was the first installed version and on another instance on ubuntu 20.04 I had this error without having this file and adding it with the blkid fixed the issue