The following commands are required to operate under the root account
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
Restart the machine and use the FREE-M command to see the size of the memory and swap partitions, and you will find that the swap space is increased after your machine automatically starts.
Thank you for watching Brother Lian technology sharing
[Technology sharing] Linux Add swap partition