View swap partitions and add partitions

Source: Internet
Author: User
Java code 1. view the system's Swap space using [root @ jumperusr] # freetotalusedfreesharedbufferscachedMem: 513980493640203400143808271780-/+ buffers/cache: 78052435928 Swap: 10522482...

Java code
1. View system Swap space usage
 
[Root @ jumper usr] # free
Total used free shared buffers cached
Mem: 513980 493640 20340 0 143808 271780
-/+ Buffers/cache: 78052 435928
Swap: 1052248 21256 1030992
 
2. create a swap file in a suitable space
 
[Root @ jumper usr] # mkdir swap
[Root @ jumper usr] # cd swap
[Root @ jumper swap] # dd if =/dev/zero of = swapfile bs = 1024 count = 1000000 // increase by 1G
10000 + 0 records in
10000 + 0 records out
[Root @ jumper swap] # ls-al
Total 10024
Drwxr-xr-x 2 root 4096 July 28 14:58.
Drwxr-xr-x 19 root 4096 July 28 14:57 ..
-Rw-r -- 1 root 10240000 July 28 14:58 swapfile
 
 
[Root @ jumper swap] # mkswap swapfile
Setting up swapspace version 1, size = 9996 KiB
 
 
3. activate the swap file
[Root @ jumper swap] # swapon swapfile
[Root @ jumper swap] # ls-l
Total 10016
-Rw-r -- 1 root 10240000 July 28 14:58 swapfile
[Root @ jumper swap] # free
Total used free shared buffers cached
Mem: 513980 505052 8928 0 143900 282288
-/+ Buffers/cache: 78864 435116
Swap: 1062240 21256 1040984
 
If you want to enable it at boot, you need to modify the swap lines in the file/etc/fstab:

/Root/swap/swapfile swap defaults 0 0

Author "kevenfeng"
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.