zoukankan      html  css  js  c++  java
  • Linux增加swap空间

    1.添加交换文件并设置其大小为12G,使用如下命令

    # dd if=/dev/zero of=/home/swapfile bs=1024 count=12288000
    12288000+0 records in
    12288000+0 records out
    12582912000 bytes (13 GB) copied, 29.1362 s, 432 MB/s
    

    2.创建(设置)交换空间,使用命令mkswap

    # mkswap /home/swapfile
    mkswap: /home/swapfile: warning: don't erase bootbits sectors
            on whole disk. Use -f to force.
    Setting up swapspace version 1, size = 12287996 KiB
    no label, UUID=061a5f99-4c31-4df9-ba11-c35d7a4492b8
    # mkswap -f /home/swapfile
    Setting up swapspace version 1, size = 12287996 KiB
    no label, UUID=60b0706c-a81e-40cc-a70b-34d72d37bf30
    

    3.检查现有的交换空间大小,使用命令free

    # free -m 
                 total       used       free     shared    buffers     cached
    Mem:        516916      16713     500202          0         68      12753
    -/+ buffers/cache:       3891     513025
    Swap:         4095          0       4095
    

    或者检查meminfo文件grep SwapTotal  /proc/meminfo

    # grep SwapTotal /proc/meminfo
    SwapTotal:       4194296 kB
    

    4.启动新增加的交换空间,使用命令swapon

    # swapon /home/swapfile
    

    5.确认新增加的16G交换空间已经生效,使用命令free

    # free -m 
                 total       used       free     shared    buffers     cached
    Mem:        516916      16722     500193          0         68      12753
    -/+ buffers/cache:       3900     513015
    Swap:        16095          0      16095 
    

    或者检查meminfo文件grep SwapTotal  /proc/meminfo

    6.修改/etc/fstab文件,使得新加的交换空间在系统重新启动后自动生效

    # vi /etc/fstab
    在文件最后加入:
    /home/swapfile           swap           swap    defaults        0 0
    
  • 相关阅读:
    <转>ajax 同步异步问题
    Jquery中父,子页面之间元素获取及方法调用
    python基础知识
    python数据类型
    sed,awk
    zabbix 4.0版本
    Redis 5.0
    ansible
    MariaDB集群配置(主从和多主)
    读写分离
  • 原文地址:https://www.cnblogs.com/abclife/p/5054476.html
Copyright © 2011-2022 走看看