Copy from
https://www.makeuseof.com/fix-read-error-on-swap-device-ubuntu/
sudo swapoff /swapfile
Once the swap file has been disabled, you are ready to create a new swap file. For example, to create a swap file of 4G, run the following command.
sudo fallocate -l 4G /swapfile
For security purposes, you should assign your swap file with only read-write permissions on the root user, using the command below.
sudo chmod 600 /swapfile
You can specify that the /swapfile is a swap area using the mkswap utility as below.
sudo mkswap /swapfile
Finally, you can enable or start your swap file by running the following command.
sudo swapon /swapfile
标签:activate,swapfile,sudo,failed,command,swap,file,ubuntu
From: https://www.cnblogs.com/Fred1987/p/17476849.html