How to modify SWAP space size under Linux

  
 

I don't know how much swap space is allocated, so I will assign one randomly. When I use it, for example, installing Oracle10g will require a large swap space. If I find that the swap space is not enough, how should I increase the size of the swap space?


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 is restarted, it is found that the swap is still as large as the original, the new swap does not start automatically, but also needs to be manually started. Then we need to modify the /etc/fstab file, add the following line

/home/swap swap swap defaults 0 0

You will find that your swap space is also increased after your machine starts automatically. .

Copyright © Windows knowledge All Rights Reserved