[root@localhost mnt]# free
total used free shared buffers cached
Mem: 2043052 1890960 152092 368 1131280 192736
-/+ buffers/cache: 566944 1476108
Swap: 2047996 430892 1617104 --------- 查看当前swap分区,一共有2G
fdisk /dev/sda 创建一个新的分区/dev/sda3 ,类型为82
Command (m for help): p
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 16812031 8200192 8e Linux LVM
/dev/sda3 16812032 17860607 524288 82 Linux swap / Solaris ------- 新的swap分区
[root@localhost mnt]# mkswap /dev/sda3 -------- 格式化文件系统
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=46f52a50-d032-47b8-b939-d26d89b052d1
[root@localhost mnt]# vim /etc/fstab ------- 永久挂载swap分区
[root@localhost mnt]# tail -1 /etc/fstab
/dev/sda3 swap swap defaults 0 0 ------ 配置项
[root@localhost mnt]# swapon -a ------- 使挂载生效
[root@localhost mnt]# free
total used free shared buffers cached
Mem: 2043052 722996 1320056 388 1716 195760
-/+ buffers/cache: 525520 1517532
Swap: 2572280 428480 2143800 ------- 查看最新的,增加到2.5G
[root@localhost mnt]# swapon -s --------- 查看现有swap状态,可以看到挂载到两个设备
Filename Type Size Used Priority
/dev/dm-1 partition 2047996 428256 -1
/dev/sda3 partition 524284 0 -2