# #增加交换分区需要先模拟出虚拟磁盘 # from the Linux kernel build 0 device zero, write to the Newdisk file, specify the file block size 1M, 100 blocks [[email protected] ~]# DD If=/dev/zero of=/tmp /newdisk bs=1m count=100 recorded the 100+0 read record of the 100+0 write 104857600 bytes (MB) copied, 1.41021 seconds, 74.4 mb/s [[email protected] ~]# Du-sh/tmp/newdisk100m/tmp/newdisk[[email protected] ~]# mkswap!$ #格式化mkswap/tmp/newdisk Setting swap space version 1 , size = 102396 KiB no label, uuid=42417e22-8a9d-4d7c-af89-332eb74dbf81[[email protected] ~]# free-m total U SED free shared buffers cachedmem:987 321 665 6 0 173-/ + buffers/cache:147 839swap:2047 0 2047[[email protected] ~]# swapon/tmp/newd ISK #加载到现在的swapswapon:/tmp/newdisk: Unsafe Permissions 0644, 0600 is recommended. [[email protected] ~]# free-m total used free shared buffers Cachedmem: 987 321 665 6 0 173-/+ Buffers/cache: 147 839swap:2147 0 2147[[email protected] ~]# chmod 0600/tmp/newdisk# Delete swap partition [[Emai L protected] ~]# swapoff/tmp/newdisk[[email protected] ~]#!ffree-m Total used free Shared buffers cachedmem:987 321 665 6 0 173-/+ Buffers/cache: 147 839swap:2047 0 2047[[email protected] ~]# rm-f/tmp/newdisk
Linux4.4 manually adding swap space