zoukankan      html  css  js  c++  java
  • 使用DD 创建SWAP

    1创建所需swap空间的文件

                if=获取数据  of=输出位置   块大小(每次复制大小)  块个数(复制次数)  
    [root@web01 ~]# dd if=/dev/zero of=/tmp/100m   bs=1M       count=100 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 2.01386 s, 52.1 MB/s
    [root@web01 ~]# ll -h /tmp/100m
    -rw-r--r--. 1 root root 100M Apr 21 13:44 /tmp/100m

    2 格式化文件成为SWAP

    [root@web01 ~]# mkswap  /tmp/100m 
    mkswap: /tmp/100m: warning: don't erase bootbits sectors
            on whole disk. Use -f to force.
    Setting up swapspace version 1, size = 102396 KiB
    no label, UUID=f90d8d0c-4972-42fc-83f8-4b98c651554e
    [root@web01 ~]# file /tmp/100m   查看文件类型是否更改为swap
    /tmp/100m: Linux/i386 swap file (new style) 1 (4K pages) size 25599 pages

    3 让文件生效成SWAP

    [root@web01 ~]# free -h    
                 total       used       free     shared    buffers     cached
    Mem:          3.7G       2.2G       1.6G       232K       1.0G       164M
    -/+ buffers/cache:       972M       2.8G
    Swap:         1.5G         0B       1.5G

    [root@web01 ~]# swapon /tmp/100m
    [root@web01 ~]# free -h
    total used free shared buffers cached
    Mem: 3.7G 2.2G 1.6G 232K 1.0G 164M
    -/+ buffers/cache: 972M 2.8G
    Swap: 1.6G 0B 1.6G

    4 检查swap 是由及部分组成

    [root@web01 ~]# swapon -s
    Filename                Type        Size    Used    Priority
    /dev/sda2               partition   1048572   0      -1
    /tmp/500m               file        511996    0      -2
    /tmp/100m               file        102396    0      -3

    5 永久挂载/开机挂载

    方法1:写入 /etc/rc.local
    [root@web01 ~]# cat /etc/rc.local #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local #bin/mount /dev/sdc1 /date swapon /tmp/100m
    方法2
    [root@web01 ~]# cat /etc/fstab
    /tmp/100m swap swap defaults 0 0
  • 相关阅读:
    如何理解面向对象和面向过程
    IIS端口被占用
    SQL UNION操作符
    SQL(MSSQLSERVER)服务启动错误代码3414
    WCF学习之路(一)
    AJAX技术学习总结
    AJAX之XMLHttpRequest对象
    软考之汇编语言
    IP地址的分配
    数组偏移量
  • 原文地址:https://www.cnblogs.com/imp-W/p/10750900.html
Copyright © 2011-2022 走看看