1.文件类型
(1)dd if=/dev/zero of=/swapfile bs=1M count=1024
(2)mkswap /tmp/swapfile
(3)swapon /tmp/swapfile
free -m //查看swap前后变化
2.分区类型
(1)fdisk /dev/sdb1
Command (m for help): p
Command (m for help): n
p
1
Command (m for help): t
1
l
82
Command (m for help):w
(2)mkswap /dev/sdb1
(3)swapon /dev/sdb1
free -m //查看swap前后变化