How to adjust the SWAP space size of Linux system tutorial

  
Many beginners linux children's shoes application have this experience, when I first contacted Linux, I don't know how much SWAP space allocation is better, so I will assign one randomly, in real use. At the time, for example, installing Oracle10g will require a large SWAP space and find that the swap space is not enough. How should we increase the size of the swap space? Here to share with you how to adjust the SWAP size of the Linux system.

Note: The following operations must be performed under the root user. First, create a partition first, using the dd command such as
dd if=/dev/zero of=/home/swap bs=1024 count= 512000
This will create a partition file like /home/swap. The size of the file is 512,000 blocks. In general, 1 block is 1K, so the space here is 512M. Then turn this partition into a swap partition.
/sbin/mkswap /home/swap
Then use this SWAP partition. Make it active.
/sbin/swapon /home/swap
Now use the free -m command to check the memory and SWAP partition size, and found that 512M space has been added. However, when the computer was restarted, it was found that SWAP was still as large as the original, and the new SWAP did not start automatically, but also started manually. Then we need to modify the /etc/fstab file, add the following line
/home/swap swap swap defaults 0 0
You will find that the SWAP space is also increased after your machine starts automatically.
Copyright © Windows knowledge All Rights Reserved