I have a swap file in my file system /swapfile with 2GB, but I want to use a partition.

I created a partition using Gparted.
I removed my swap file using: sudo swapoff /swapfile
But I have a line on /etc/fstab with my old swapfile.
** I Need To Inform My Ubuntu That I'm Using A Swap Partition. **

How can I achieve this?

  • Possible duplicate of Swap partition to Swap file – vanadium Jun 27 at 19:38
  • @vanadium, My question is the opposite of your suggestion. And I can't achieve my objective reading that another topic. – danilo Jun 27 at 19:39
  • You are right: removed my vote. – vanadium Jun 27 at 19:47

I found a solution:

First find the UUID of the swap partition:
sudo blkid | grep 'TYPE="swap"'

Then modify your /etc/fstab and replace /swapfile with UUID=xxx, using the UUID you got from the command above. The line that now has /swapfile must then look something like

UUID=01234567-89ab-cdef-0123-456789abcdef none swap sw 0 0

The swap partition will be used after a reboot or running
sudo swapon -a

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.