Browsing this Thread:   1 Anonymous Users






linux swap ubuntu添加虚拟内存
#1
Just can't stay away
Just can't stay away


See User information
linux swap ubuntu 添加虚拟内存

Start by creating a file which will be used for swap:

sudo fallocate -l 1G /swapfile


If fallocate is not installed or you get an error message saying fallocate failed: Operation not supported then use the following command to create the swap file:

sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576



Only the root user should be able to write and read the swap file. Set the correct permissions by typing:
sudo chmod 600 /swapfile


Use the mkswap utility to set up a Linux swap area on the file:

sudo mkswap /swapfile



Activate the swap file using the following command:

sudo swapon /swapfile



To make the change permanent open the /etc/fstab file:

sudo nano /etc/fstab



and paste the following line:
/etc/fstab

/swapfile swap swap defaults 0 0



Verify that the swap is active by using either the swapon or the free command , as shown below:
sudo swapon --show

Posted on: 2021/8/23 9:20
Top








friend links
Themes

(2 themes)
Login
Username:

Password:


Lost Password?
Register now!
Categories
Xoops (11)
--Modules (2)
--Themes (0)
Article (8)