ubuntu failed to activate swap/swapfile

发布时间 2023-06-13 10:41:05作者: Fred1987

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