Follow the steps to explain how Red Hat Linux increases swap space
Method/Step
- First step: Make sure there is enough space in the system for swap swap space, I am using KVM, ready to add a swap file to a separate file system, add 2G swap files to/opt/image
-
Step two: Add the swap file and set its size to 2G, using the following command
[[email protected] image]# dd If=/dev/zero of=/opt/image/swap bs=1024 count=2048000
After a while, the following results are returned:
2048000+0 Records in2048000+0 Records out2097152000 bytes (2.1 GB) copied, 272.867 seconds, 7.7 mb/s
-
Step Three: Create (set) Swap space, use command Mkswap
[Email protected] image]# Mkswap/opt/image/swap
Setting up Swapspace version 1, size = 2097147 KB
-
Fourth step: Check the size of the existing swap space and use the command free
[Email protected] image]# free-m
Total used free shared buffers Cached
mem:1011 989 21 0 1 875
-/+ buffers/cache:112 898
swap:1027 0 1027
Or check the Meminfo file grep swaptotal/proc/meminfo
- Fifth step: Start the newly added 2G swap space, using the command swapon
-
[Email protected] image]# Swapon/opt/image/swap
-
Sixth step: Confirm that the newly added 2G swap space is in effect, use the command free
[[email protected] image]# free-m
Total used free shared buffers Cached
mem:1011 995 15 0 4 877
-/+ buffers/cache:113 897
swap:3027 0 3027
Or check the Meminfo file grep swaptotal/proc/meminfo
-
Seventh Step: Modify the/etc/fstab file so that the newly added 2G swap space automatically takes effect after the system restarts
Added at the end of the document:/opt/image/swap swap defaults 0 0