在 Debian 系统中,可以通过以下几种方式查看 swap(交换空间)大小:
free 命令(最常用)free -h
输出示例:
total used free shared buff/cache available
Mem: 7.7G 1.2G 5.1G 120M 1.4G 6.2G
Swap: 2.0G 0B 2.0G
Swap 一行显示的就是 swap 总大小、已用和剩余swapon 命令swapon --show
或
swapon -s
输出示例:
NAME TYPE SIZE USED PRIO
/dev/sda2 partition 2G 0B -2
SIZE 列就是 swap 大小/proc/swapscat /proc/swaps
输出示例:
Filename Type Size Used Priority
/dev/sda2 partition 2097148 0 -2
Size 单位是 KBtop / htoptop 命令顶部会显示:MiB Swap: 2048.0 total, 2048.0 free
lsblk
或
fdisk -l
可以看到类型为 swap 的分区及其大小。
ls -lh /swapfile
(路径可能不同)如果你是想 创建 / 调整 / 关闭 swap,也可以告诉我。