linux 创建swap分区

来源:互联网 发布:搬瓦工 不适合 建站 编辑:程序博客网 时间:2024/05/21 13:24
1.查看SWAP[root@192 oc]# cat /proc/swapsFilename                                Type            Size    Used    Priority/dev/sda3                               partition       8024    104     -1[root@192 oc]# 2.通过DD创建文件 dd if=/dev/zero of=/swapfile bs=512 count=4000000 dd if=/dev/zero of=/swapfile bs=512 count=80000002000000+0 records in2000000+0 records out1024000000 bytes (1.0 GB) copied, 23.4213 seconds, 43.7 MB/s[root@192 oc]#[root@192 oc]# ll总计 1001012drwx------ 2 root root      16384 06-03 06:56 lost+found-rw-r--r-- 1 root root 1024000000 06-12 10:24 swapdrwxr-xr-x 4 root root       4096 06-08 16:15 tmp[root@192 oc]#3.转化为swap格式[root@backoffice01 ~]# mkswap /swapfilemkswap: /swapfile: warning: don't erase bootbits sectors        on whole disk. Use -f to force.Setting up swapspace version 1, size = 1999996 KiBno label, UUID=92896c21-e21b-4e16-b5de-9319931b31ac[root@192 oc]# free             total       used       free     shared    buffers     cachedMem:       1035108    1018168      16940          0      14716     892500-/+ buffers/cache:     110952     924156Swap:         8024        104       7920[root@192 oc]#启用,加入到swap池中。[root@192 oc]# swapon  /swapfile[root@192 oc]# free             total       used       free     shared    buffers     cachedMem:       1035108    1018228      16880          0      14748     892592-/+ buffers/cache:     110888     924220Swap:      1008016        104    1007912[root@192 oc]# [root@192 oc]# cat /proc/swapsFilename                                Type            Size    Used    Priority/dev/sda3                               partition       8024    104     -1/oc/swap                                file            999992  0       -4[root@192 oc]# 从swap池中拿掉[root@192 oc]# swapoff /oc/swap[root@192 oc]# free             total       used       free     shared    buffers     cachedMem:       1035108    1018780      16328          0      15096     892760-/+ buffers/cache:     110924     924184Swap:         8024        104       7920[root@192 oc]# cat /proc/swapsFilename                                Type            Size    Used    Priority/dev/sda3                               partition       8024    104     -1[root@192 oc]# 开机自动启动:/swapfile               swap                    swap    defaults        0 0 另:将整个设备划为swap分区fdisk时代码为82 linux swap,分区后:# mkswap /dev/sdc3# swapon /dev/sdc3

0 0
原创粉丝点击