启动msfconsole 报内存不够
kali下启动msfconsole 报错:
/opt/metasploit-framework/embedded/lib/ruby/gems/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``': Cannot allocate memory - infocmp (Errno::ENOMEM)
from /opt/metasploit-framework/embedded/lib/ruby/gems/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/kernel/agnostics.rb:7:in
from /opt/metasploit-framework/embedded/lib/ruby/gems/2.4.0/gems/rb-readline-0.5.5/lib/rbreadline.rb:1815:in get_term_capabilities'
from /opt/metasploit-framework/embedded/lib/ruby/gems/2.4.0/gems/rb-readline-0.5.5/lib/rbreadline.rb:2027:in _rl_init_terminal_io'
…
意思为内存不足。
解决:增加 swap 交换分区文件大小即(扩大虚拟内存):
查看内存状态
free -m
# 查看内存状态
total | used | free | shared | buff/cache | available | |
---|---|---|---|---|---|---|
Mem: | 992 | 189 | 79 | 13 | 722 | 614 |
Swap: | 0 | 0 | 0 |
#Swap 也就是虚拟内存,为 0
选择一个较大的分区,建立分区文件
dd if=/dev/zero of=/opt/swap bs=1024 count=4096000
4096000+0 records in
4096000+0 records out
4194304000 bytes (4.2 GB) copied, 42.7798 s, 98.0 MB/s
#在 opt 分区建立名为 swap,大小为 4G 的虚拟内存文件
更改 swap 文件的权限
chmod 600 /opt/swap
格式化 swap 分区
mkswap /opt/swap
Setting up swapspace version 1, size = 4095996 KiB
no label, UUID=1c2c6a98-0aee-4c5d-8338-84529e564942
激活swap,启用分区交换文件
swapon /opt/swap
将分区设置为开机自动挂载
vim /etc/fstab
增加内容:
/opt/swap swap swap defaults 0 0
(不够大可卸载swap分区再重复上面步骤)
卸载 swap 分区
停止swap分区
swapoff /opt/swap
删除swap文件
rm -rf /opt/swap