linux 增加swap空间

来源:互联网 发布:nike跑步鞋推荐 知乎 编辑:程序博客网 时间:2024/04/19 13:39
[root@localhost ~]# free -m  查看swap容量
             total       used       free     shared    buffers     cached
Mem:          1006        969         36          0          9        467
-/+ buffers/cache:        492        514
Swap:         2015         32       1983


[root@localhost ~]# dd if=/dev/zero of=/home/swap bs=1024 count=3024000
记录了3024000+0 的读入
记录了3024000+0 的写出
3096576000字节(3.1 GB)已复制,60.442 秒,51.2 MB/秒


[root@localhost ~]# mkswap /home/swap
mkswap: /home/swap: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 3023996 KiB
no label, UUID=8157820b-1402-4ace-8b25-205f88509fe9


启用交换分区文件
[root@localhost ~]# swapon /home/swap


[root@localhost ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1006        985         21          0          2        489
-/+ buffers/cache:        492        513
Swap:         4969         32       4936


[root@localhost ~]# vi /etc/fstab   包含了系统在启动时挂载文件系统和存储设备的详细信息,添加下列信息
/home/swap               swap                    swap    defaults        0 0


系统下次引导时,它就会启用新建的交换文件
0 0