EVE扩大虚拟内存

1、首先通过df -lh命令查看虚拟机的根目录下是否有足够大的硬盘空间。

root@eve-ng:~# df -h
Filesystem                    Size  Used Avail Use% Mounted on
udev                          7.9G     0  7.9G   0% /dev
tmpfs                         1.6G   18M  1.6G   2% /run
/dev/mapper/eve--ng--vg-root  196G  8.1G  179G   5% /
tmpfs                         7.9G     0  7.9G   0% /dev/shm
tmpfs                         5.0M     0  5.0M   0% /run/lock
tmpfs                         7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/sda1                     472M   83M  365M  19% /boot

2、通过free -m命令查看当前交换分区的大小,当前系统的交换分区为0.95GB。

root@eve-ng:~# free -m
              total        used        free      shared  buff/cache   available
Mem:          16045         418       15237          26         389       15261
Swap:           979           0         979

3、通过dd if=/dev/zero of=/swap-1 bs=1024M count=20,在系统根目录下创建一个名字为swap-1的20GB交换文件,当然如果20GB不够用可以通过调整count后面的数字来创建更大的交换文件。这个过程稍微多等一下。

root@eve-ng:~# dd if=/dev/zero of=/swap-1 bs=1024M count=20
20+0 records in
20+0 records out
21474836480 bytes (21 GB, 20 GiB) copied, 21.194 s, 1.0 GB/s

通过cd /和ls命令查看交换文件是否已经建好。

 

 

 4、通过mkswap /swap-1和swapon /swap-1命令对刚才创建的文件格式进行转换并挂载

root@eve-ng:/# mkswap /swap-1
mkswap: /swap-1: warning: wiping old swap signature.
Setting up swapspace version 1, size = 20 GiB (21474832384 bytes)
no label, UUID=6d581f29-b368-4dd6-83f2-74b34ab44a2c
root@eve-ng:/# swapon /swap-1
swapon: /swap-1: insecure permissions 0777, 0600 suggested.

5、通过swapon -s和free -m命令查看交换文件是否挂载成功和查看系统当前交换分区的大小,下图中的交换分区大小已经从原始的0.9G增加到0.9+20总计21GB大小

root@eve-ng:/# swapon -s
Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       1003516 1260    -1
/swap-1                                 file            20971516        0       -2
root@eve-ng:/# free -m
              total        used        free      shared  buff/cache   available
Mem:          16045         430        1167          26       14448       15180
Swap:         21459           1       21458

6、通过WinScp工具对/etc下的fstab文件进行修改,以达到系统开机时自动挂载刚才创建好的交换文件,当然也可以在虚拟机中通过vim的方式进行修改。

 

 

 

 在fstab文件中增加一行/swap-1 swap swap default 0 0并保存文件

7、通过shutdown -r now重启虚拟机,并通过free -m和swapon -s来验证创建好的交换文件是否自动挂载实现对交换分区的扩容。

root@eve-ng:~# free -m
              total        used        free      shared  buff/cache   available
Mem:          16045         405       15271          27         368       15282
Swap:         21459           0       21459
root@eve-ng:~#
root@eve-ng:~# swapon -s
Filename                                Type            Size    Used    Priority
/swap-1                                 file            20971516        0       -1
/dev/dm-1                               partition       1003516 0       -2
root@eve-ng:~#

 

跟着EmulatedLab学习中!

转载于:https://www.cnblogs.com/MomentsLee/p/11604415.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值