标签:set 方法 挂载 创建 ted def inux ant 2.0
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
标签:set 方法 挂载 创建 ted def inux ant 2.0
原文地址:https://www.cnblogs.com/imp-W/p/10750900.html