Linux扩充虚拟内存(swap)
Linux扩充虚拟内存(swap)
虚拟内存swap一般设置为物理内存的2倍即可,多了也是浪费硬盘。
(base) [mca@clu08 bin]$ free -m
total used free shared buff/cache available
Mem: 7809 5995 954 11 859 1496
Swap: 6143 465 5678
# 使用root用户操作
(base) [mca@clu08 bin]$ su -
Password:
Last login: Fri Dec 3 17:14:49 CST 2021 on pts/8
Last failed login: Mon Dec 6 14:43:33 CST 2021 from 10.0.9.118 on ssh:notty
There were 2 failed login attempts since the last successful login.
# count的值为实际想要的内存,一般设置为物理内存的2倍
[root@clu08 ~]# dd if=/dev/zero of=/root/swapfile2 bs=1M count=16383
10240+0 records in
10240+0 records out
10737418240 bytes (11 GB) copied, 108.758 s, 98.7 MB/s
[root@clu08 ~]# chmod 0600 /root/swapfile2
[root@clu08 ~]# mkswap /root/swapfile2
Setting up swapspace version 1, size = 10485756 KiB
no label, UUID=365528fa-cc2f-4d7a-a7c5-e726c7d6956e
[root@clu08 ~]# swapon /root/swapfile2
# 再次查看,虚拟内存得到扩充
[root@clu08 ~]# free -m
total used free shared buff/cache available
Mem: 7809 5919 188 11 1701 1564
Swap: 16383 465 15918
正文完
评论区