利用LVM特性对EVE-NG硬盘分区扩容
下载的EVE-NG镜像中,存放模拟器镜像的分区太小了,上传几个cisco和juniper的模拟器就快满了,所以需要使用lvm特性对ubuntu server的硬盘分区进行扩容,首先先将eve-ng虚拟机关机,再将虚拟机磁盘进行扩展,扩展到1000G
查看分区信息
重新启动eve-ng,登录后先进行信息收集
df -h
/dev/mapper/eve--ng--vg-root 共有24G,已使用19G,剩余3.5G,已占用85%
fdisk -l
虚拟机扩展成功后,可以看到Disk /dev/sda:1000 GiB,系统中已经识别了扩展的容量
对硬盘分区
fdisk /dev/sda
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n 输入n
Partition type
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): p 输入p
Partition number (3,4, default 3): 3 输入3
选择第三个分区
First sector (999424-2097151999, default 999424): 62912512
因为fdisk -l中查看到sda2的end sector值为62912511,所以该数值+1就是sda3的start sector
Last sector, +sectors or +size{K,M,G,T,P} (62912512-2097151999, default 2097151999):
使用默认值,回车
Created a new partition 3 of type 'Linux' and of size 970 GiB.
Command (m for help): p
Command (m for help): w
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
root@eve-ng:~# reboot 重启后成效
新分区加入VG卷组
vgdisplay
扩容前为30G
将sda3加入到VG中
vgextend eve-ng-vg /dev/sda3
Physical volume "/dev/sda3" successfully created
Volume group "eve-ng-vg" successfully extended
扩容LV逻辑卷
查看LV路径
lvdisplay
路径为/dev/eve-ng-vg/root
将剩余容量扩容到/dev/eve-ng-vg/root路径下
lvextend -l +100%FREE /dev/eve-ng-vg/root
Size of logical volume eve-ng-vg/root changed from 23.52 GiB (6021 extents) to 993.52 GiB (254341 extents).
Logical volume root successfully resized.
重新定义文件系统大小
resize2fs /dev/eve-ng-vg/root
查看磁盘使用情况
df -h
本站所有文章均可随意转载,转载时请保留原文链接及作者。