Jump to content

1. Check memory usage

Check the usage of virtual memory before swap is added

free -m

2. Create swap file

Use the dd command to create a swap file with a size of 2G

dd if=/dev/zero of=/home/swap bs=1024 count=2048000 The larger the file, the more factory the time it is created.

3. Convert to swap format

Convert file format to swap format

mkswap /home/swap

4. Mount the swap partition

Use the swapon command to mount the swap partition to the swap partition

swapon /home/swap If an error is reported: swapon: /home/swap: insecure permissions 0644, 0600 suggested.

Modify permissions:

chmod 600 /home/swap

5. Check the memory usage again

Pay attention to the changes in observation and 1.

free -m

6. Setting up restart is still valid

To prevent the swap partition from becoming 0 after restart, you need to modify the /etc/fstab file:

At the end of the file (the last line)

/home/swap swap swap default 0 0

7. Deactivate virtual memory

swapoff -v /home/swap

0 Comments

Recommended Comments

There are no comments to display.

Guest
Add a comment...