默认的 Eve-NG 硬盘空间大小可用空间只有 36GB ,本文将对系统盘进行扩容并导入镜像。本文的每一条命令都是作者能够跑通实际测试过的,如果有问题可以下方评论区留言。
EVE-NG扩容
首先先看一下默认的各分区大小:
1 | root@eve-ng:~# df -h |
可以看到,默认的根分区/dev/mapper/eve--ng--vg-root
只有41GB的总空间,并且在默认状态下只有36GB的空闲空间。
这里提供两种思路,一种是扩容不超过2TB;一种是扩容大小大于2TB。这两种模式的区别主要是EVE-NG的主硬盘采用了MBR分区表格式,而MBR的分区表格式不支持大于2TB的结构管理。
修改:不再提供容量小于2TB的扩容方案,相对来说会比较复杂,也需要重启多次来应用更改。以下方案无论容量多少都可以采用。
注意:本文所提供的示例可能是有修改和删减的,具体以实际输出为准。
- 首先在EVE-NG的虚拟机上创建一个硬盘,容量自定,可以在不关机的状态下添加硬盘,注意硬盘接口一定要选择SATA。
这里以新增一块4TB的硬盘为例:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xeb1c7d5a
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 104855551 103854082 49.5G 5 Extended
/dev/sda5 1001472 104855551 103854080 49.5G 8e Linux LVM
Disk /dev/sdb: 4 TiB, 4398046511104 bytes, 8589934592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes - 在新加的硬盘上创建分区:首先输入
1
fdisk /dev/sdb
g
回车创建GPT分区表:然后输入1
2Command (m for help): g
Created a new GPT disklabel (GUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).n
创建新分区(如果没有特殊要求以下参数均可保持默认):最后输入1
2
3
4
5
6Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-8589934558, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-8589934558, default 8589934558):
Created a new partition 1 of type 'Linux filesystem' and of size 4 TiB.w
将更改写入硬盘:最后最后用1
2
3
4Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.fdisk -l
看一下分区和容量是否正确:1
2
3
4
5
6
7
8
9Disk /dev/sdb: 4 TiB, 4398046511104 bytes, 8589934592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Device Start End Sectors Size Type
/dev/sdb1 2048 8589934558 8589932511 4T Linux filesystem - 看一下 Volume Group 的名称:可见
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21root@eve-ng:~# vgdisplay
--- Volume group ---
VG Name eve-ng-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 49.52 GiB
PE Size 4.00 MiB
Total PE 12677
Alloc PE / Size 12677 / 49.52 GiB
Free PE / Size 0 / 0
VG UUID Mt9awT-x1IE-4b7W-Hlvy-NINH-x3Pb-SPuZZbVG Name
为eve-ng-vg
。 - 将新创建的分区加入到上面的组中:然后看一下组中是否有了新增的容量:
1
2
3root@eve-ng:~# vgextend eve-ng-vg /dev/sdb1
Physical volume "/dev/sdb1" successfully created
Volume group "eve-ng-vg" successfully extended1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21root@eve-ng:~# vgdisplay
--- Volume group ---
VG Name eve-ng-vg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 4.05 TiB
PE Size 4.00 MiB
Total PE 1061252
Alloc PE / Size 12677 / 49.52 GiB
Free PE / Size 1048575 / 4.00 TiB
VG UUID Mt9awT-x1IE-4b7W-Hlvy-NINH-x3Pb-SPuZZb - 扩容逻辑卷:
首先看一下目前逻辑卷的信息将加入 Volume Group 的全部空闲容量并入逻辑卷的路径下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17root@eve-ng:~# lvdisplay
--- Logical volume ---
LV Path /dev/eve-ng-vg/root
LV Name root
VG Name eve-ng-vg
LV UUID arklJp-Shb2-f1qp-sjeg-ekmw-fbRN-VUf4Rw
LV Write Access read/write
LV Creation host, time eve-ng, 2021-01-11 03:27:43 +0200
LV Status available
# open 1
LV Size 41.52 GiB
Current LE 10629
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0Resize一下:1
2
3root@eve-ng:~# lvextend -l +100%FREE /dev/eve-ng-vg/root
Size of logical volume eve-ng-vg/root changed from 41.52 GiB (10629 extents) to 4.04 TiB (1059204 extents).
Logical volume root successfully resized.1
2
3
4
5root@eve-ng:~# resize2fs /dev/eve-ng-vg/root
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/eve-ng-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 259
The filesystem on /dev/eve-ng-vg/root is now 1084624896 (4k) blocks long. - 最后看一下容量变化:扩容成功了,还有3.9T的空余空间。
1
2
3
4
5
6
7
8
9root@eve-ng:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 798M 14M 784M 2% /run
/dev/mapper/eve--ng--vg-root 4.0T 2.8G 3.9T 1% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 472M 119M 329M 27% /boot
导入镜像
镜像的导入就简单多了。
镜像分类
EVE-NG镜像共三种类型:
- Dynamips:思科设备真实IOS镜像,类似GNS3,电脑CPU利用率非常高。
- IOL:IOU模拟器的镜像,基本完全支持思科设备二、三层功能。
- QEMU:这已经不算是镜像文件,而是KVM虚拟机安装操作系统后生成的磁盘文件,通常用来模拟ASAv、ISE、F5、N9K等设备。每台设备相当于一台虚拟机,比较吃资源。
QEMU镜像
- 用scp工具(如WinSCP)连接到EVE-NG主机,IP地址在启动后可以看到,用户名为
root
,密码是首次初始化后自行设定的。 - 将镜像文件带文件夹上传至
/opt/unetlab/addons/qemu/
目录下。 - 执行如下命令修正权限,修正后即可使用镜像。
1
/opt/unetlab/wrappers/unl_wrapper -a fixpermissions
- 如果还需要再次导入镜像,则每次都需要执行第三步的修正权限。
IOL镜像
安装之前先说一下IOL需要的文件:
.bin
文件,是IOL镜像文件;iourc
是IOL的License文件;CiscoIOUKeygen.py
是License的生成工具。
安装IOL镜像的话分为两步:复制文件和生成License。
- 将上述所有文件上传到
/opt/unetlab/addons/iol/bin
目录下; - 看一下文件是否都在:
1
2
3
4
5
6
7
8
9root@eve-ng:/opt/unetlab/addons/iol/bin# ll -a
total 427024
drwxr-xr-x 2 root root 4096 Apr 3 16:58 ./
drwxr-xr-x 4 root root 4096 Jan 11 2021 ../
-rw-r--r-- 1 root root 1202 Mar 18 2020 CiscoIOUKeygen.py
-rw-r--r-- 1 root root 126226692 Mar 18 2020 i86bi_LinuxL2-AdvEnterpriseK9-M_152_May_2018.bin
-rw-r--r-- 1 root root 126249700 Mar 18 2020 i86bi_linux_l2-adventerprisek9-ms.SSA.high_iron_20190423.bin
-rw-r--r-- 1 root root 184759244 Mar 18 2020 i86bi_LinuxL3-AdvEnterpriseK9-M2_157_3_May_2018.bin
-rw-r--r-- 1 root root 37 Mar 18 2020 iourc - 生成License:
切换到目录之后执行命令:然后删掉原来的1
2
3
4
5
6
7
8
9
10
11
12root@eve-ng:/opt/unetlab/addons/iol/bin# python CiscoIOUKeygen.py
*********************************************************************
Cisco IOU License Generator - Kal 2011, python port of 2006 C version
Modified to work with python3 by c_d 2014
hostid=007f0101, hostname=eve-ng, ioukey=7f0343
Add the following text to ~/.iourc:
[license]
eve-ng = 972f30267ef51616;
You can disable the phone home feature with something like:
echo '127.0.0.127 xml.cisco.com' >> /etc/hostsiourc
文件,将上面[License]
和下一行写入该文件,保存退出即可。
注意License跟随主机的主机名变更,如果主机名变更,License也要重新生成。
以下是一个iourc
的示例文件:1
2[license]
eve-ng = 972f30267ef51616;
Dynamips镜像
手头没有这个镜像,不写了,之后有了再写。