swap space shortage problem solved

The first step: Use the free -m to view the current swap space swap, 1019M, can also use grep SwapTotal / proc / meminfo View

[root @ localhost swapImage] # free -m
            Total Used as Free Shared buffers cached
Mem: 1010 995 15 0 847. 1
- / + buffers / Cache: 145 865
Swap: 1019 0 1019

with df -h disk space usage view
[the root @ localhost ~] # df -h
the Filesystem Size used Avail the use% Mounted ON
/ dev / sda2 4OG 4G 10% 36G /
/ dev / sda3. 15G 13G 1.7G 13 is% / Home
/ dev / sda1 46M 11M 33M 25% / Boot
tmpfs 506m 506m 0 0% / dev / SHM

Step 2: ensure the system has enough space to do swap swap space, after df -h to view.

# Dd if = / dev / zero of = / tmp / swap2 bs = 32k count = 819200 ----- (32 * 819200 = 26214400 (KB), is also equal 25600MB)

 

After executing the above command, will be created in the / tmp directory swap2 file a 25600MB again -h to view disk space usage with df, / home may be the size of a 38G has become a 1G, that is, by the above dd operation, we have successfully allocated swap space for the exchange of 25G)

the third step: use mkswap command to create (or set) swap space, the swap file format file format
[root @ localhost swapimage] # mkswap  / tmp / swap2

Step four: Use the swapon command to enable the new swap space 25G

[root @ localhost swapimage] # swapon  / tmp / swap2
such modified SWAP has increased 25G, using the free -m confirm the new swap swap space already in force

Check the swap
  command code
  #swapon -s


Step Five: Modify / etc / fstab file, the new 25G swap space automatically take effect after a system restart

[root @ localhost swapImage] # vi / etc / fstab
/ tmp / swap2 swap swap Defaults 0 0

 

Delete SWAP partitions:
1) swapoff / tmp / swap2;
2) modify / etc / fstab file

 

Links: http://blog.itpub.net/30936525/viewspace-2018397/

Guess you like

Origin www.cnblogs.com/nanshanmayuan/p/11975006.html
Recommended