How do I add swap space manually when swap space is not available?
The following actions are performed under the root user:
First create a partition, using the DD command such as
DD If=/dev/zero of=/home/swap bs=1024 count=512000
This creates a partition file such as/home/swap. The size of the file is 512,000 blocks, normally 1 blocks are 1 K, so the space here is 512M.
Then turn the partition into a swap partition.
/sbin/mkswap/home/swap
Then use this swap partition. Make it a valid state.
/sbin/swapon/home/swap
Now using the FREE-M command to see the size of the memory and swap partitions, we found that the 512M space was increased. However, when the computer restarts, it is found that the swap is still the same size, the new swap does not start automatically, but also to start manually. Then we need to modify the/etc/fstab file to add the following line
/home/swap Swap swap defaults 0 0
You will find that the swap Space also increases after your machine starts automatically.
This article is from the "Huangyi blog" blog, please be sure to keep this source http://linuxpython.blog.51cto.com/10015972/1649607
Linux manually add swap partitions