当前位置:   article > 正文

eve-ng 自定义linux镜像_eve linux映像

eve linux映像

1. 创建目录

root@eve-ng:/opt/unetlab/addons/qemu# mkdir linux-rocky-8
  • 1

2. 上传镜像并改名

root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# ll
total 2213072
drwxr-xr-x  2 root root       4096 Aug  5 10:54 ./
drwxr-xr-x 47 root root       4096 Aug  5 09:14 ../
-rw-r--r--  1 root root 2265972736 Aug  5 10:57 Rocky-8.6-x86_64-minimal.iso
root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# mv Rocky-8.6-x86_64-minimal.iso cdrom.iso
root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# ll
total 2213072
drwxr-xr-x  2 root root       4096 Aug  5 10:57 ./
drwxr-xr-x 47 root root       4096 Aug  5 09:14 ../
-rw-r--r--  1 root root 2265972736 Aug  5 10:57 cdrom.iso
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

3. 创建虚拟磁盘qcow2

qcow2文件大小决定了虚拟机最大的磁盘使用量,根据实际使用来占用磁盘空间

root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# qemu-img create -f qcow2 virtioa.qcow2 30G
Formatting 'virtioa.qcow2', fmt=qcow2 size=32212254720 cluster_size=65536 lazy_refcounts=off refcount_bits=16
root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# ll
total 2213072
drwxr-xr-x  2 root root       4096 Aug  5 10:57 ./
drwxr-xr-x 47 root root       4096 Aug  5 09:14 ../
-rw-r--r--  1 root root 2265972736 Aug  5 10:57 cdrom.iso
-rw-r--r--  1 root root     197088 Aug  5 10:54 virtioa.qcow2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

4. 登录eve网页

  • 新建node,并选择linux-Rocky-8,建议新建lab只建要自定义的镜像node,方便后续查询编号。
  • 开机进行系统安装。
  • 安装完成,重启之前,删除cdrom.ios
root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# rm cdrom.iso
  • 1

5. 查找lab UUID和虚拟机编号

POD ID:在首页上方第二个manaement的user management中查看pod
lab UUID获取:点击左侧的LAB DETAILS,ID: 0bb92614-1544-4090-b631-b453fe512320
虚拟机编号:右键点击linux主机node后,主机名()里面内容就是虚拟机编号,例如Linux(1)

6. 将系统提交成模板

根据获取到的UUID和虚拟机编号进入运行中的实验目录找到镜像,目录:
/opt/unetlab/tmp/POD ID/UUID/虚拟机编号

root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# cd /opt/unetlab/tmp/0/0bb92614-1544-4090-b631-b453fe512320/1
root@eve-ng:/opt/unetlab/tmp/0/0bb92614-1544-4090-b631-b453fe512320/1# ll
total 2525984
drwxrwsr-x  5 root unl        4096 Aug  5 11:00 ./
drwxrwsr-x  3 root unl        4096 Aug  5 11:00 ../
drwxr-sr-x  3 root root       4096 Jul 12 12:33 dev/
drwxr-xr-x  5 root root       4096 Jun 15 16:04 jail/
lrwxrwxrwx  1 root root          8 May  3 07:46 lib -> jail/lib/
lrwxrwxrwx  1 root root         10 May  3 07:46 lib64 -> jail/lib64/
drwxr-sr-x 14 root root       4096 Jun 15 16:09 opt/
-rw-rw-r--  1 root unl           0 Aug  5 11:00 .prepared
lrwxrwxrwx  1 root root          8 May  3 07:46 usr -> jail/usr/
-rw-r--r--  1 root unl  2586640384 Aug  5 11:25 virtioa.qcow2
-rw-rw-r--  1 root unl         112 Aug  5 11:25 wrapper.txt
root@eve-ng:/opt/unetlab/tmp/0/0bb92614-1544-4090-b631-b453fe512320/1# qemu-img commit virtioa.qcow2
Image committed.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

7. 压缩镜像(可选)

root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# eve-sparsify  --compress virtioa.qcow2 compressedvirtioa.qcow2
[   0.1] Create overlay file in /tmp to protect source disk
[   0.2] Examine source disk
◓ 25% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒═══════════════════════════════════════════════════════════════════════════════════⟧ --:--
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[  77.4] Fill free space in /dev/sda1 with zero
[  78.1] Clearing Linux swap on /dev/sda2
[  79.6] Fill free space in /dev/sda3 with zero
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[ 524.7] Copy to destination and make sparse

[1273.0] Sparsify operation completed with no errors.
virt-sparsify: Before deleting the old disk, carefully check that the
target disk boots and works correctly.
root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8#
root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# ll -h
total 3.4G
drwxr-xr-x  2 root root 4.0K Aug  5 11:40 ./
drwxr-xr-x 47 root root 4.0K Aug  5 09:14 ../
-rw-r--r--  1 root root 964M Aug  5 11:52 compressedvirtioa.qcow2
-rw-r--r--  1 root root 2.5G Aug  5 11:29 virtioa.qcow2
root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# mv compressedvirtioa.qcow2 virtioa.qcow2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

参考:https://www.eve-ng.net/index.php/documentation/howtos/howto-create-own-linux-host-image/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/186919
推荐阅读
相关标签
  

闽ICP备14008679号