* ***************************** Add an environment for Swap space in Linux: centOS 6.2 author: youseesan ******************************
Mkdir/var/swap www.2cto.com --- create file. swp 1024 byte 65536/1024 = 64 M [root @ localhost ~] # Dd if =/dev/zero of =/var/swap/file. swp bs = 1024 count = 65536 records 65536 + 0 read records 65536 + 0 write records
67108864 bytes (67 MB) Copied, 1.05399 seconds, 63.7 MB/second [root @ localhost ~] # ---- UUID = 7b2d46b8-6448-43d5-86e0-fffa0c798965 as the volume label [root @ localhost ~] # Mkswap/var/swap/file. swp mkswap:/var/swap/file. swp: warning: don't erase bootbits sectors on whole disk. use-f to force. setting up swapspace version 1, size = 65532 KiB no label, UUID = 7b2d46b8-6448-43d5-86e0-fffa0c798965
Vi/etc/fstab -- Add the following line. After the system starts, it automatically loads logs/var/swap/file. swp swap defaults 0 0 defaults www.2cto.com [root @ localhost ~] # Free-m total used free shared buffers cached Mem: 1266 364 901 0 17 181-/+ buffers/cache: 165 1100 2918 Swap: 2918 0 [root @ localhost ~] #
--- Enable swap to add [root @ localhost ~] # Swapon/var/swap/file. swp [root @ localhost ~] # Free-m total used free shared buffers cached Mem: 1266 364 901 0 17 181-/+ buffers/cache: 165 1100 2982 Swap: 2982 0 [root @ localhost ~] # Www.2cto.com --- disable swap to add [root @ localhost ~] # Swapoff/var/swap/file. swp [root @ localhost ~] # Free-m total used free shared buffers cached Mem: 1266 364 901 0 17 181-/+ buffers/cache: 165 1100 2918 Swap: 2918 0 [root @ localhost ~] #