Ubuntu won’t boot after changing swap size and running out of space

Solution 1:

It seems you’ve asked your computer to make a 130GB swap file rather than an 8GB file. You will need to do the following:

  1. Boot into recovery (or with a Live USB stick)
  2. Confirm that you’re not using a swap file:
    sudo swapoff -a
    
  3. Delete the oversized swap file that you created:
    sudo rm -f /swappyswapswap
    
    IMPORTANT: You will need to change the name of the file in this command from swappyswapswap to the proper name of the big swap file in your / directory. The file name in this command is intentionally wrong so that you — hopefully — do not blindly copy a sudo rm command, as there is no undo.
  4. Confirm your system now has space:
    df -h
    
  5. Create an 8GB file full of zeros, which will become your swap:
    sudo dd if=/dev/zero of=/swapfile bs=1M count=8192 status=progress
    
  6. Set the new file as your swap:
    sudo mkswap /swapfile
    
  7. Add the new swap file to your /etc/fstab file:
    sudo vi /etc/fstab
    
    Note: Feel free to use any text editor of your choosing to modify this file. Just remember to open the file with sudo as it is owned by root.

    Add this line to the bottom:
    /swapfile    none    swap    sw    0    0
    
    This will ensure the swap file is mounted every time you reboot.
  8. Restart the system normally.

Be sure to read, understand, and agree with every one of these steps before copy/pasting them.