赞
踩
root@eve-ng:/opt/unetlab/addons/qemu# mkdir linux-rocky-8
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
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
root@eve-ng:/opt/unetlab/addons/qemu/linux-rocky-8# rm cdrom.iso
POD ID:在首页上方第二个manaement的user management中查看pod
lab UUID获取:点击左侧的LAB DETAILS,ID: 0bb92614-1544-4090-b631-b453fe512320
虚拟机编号:右键点击linux主机node后,主机名()里面内容就是虚拟机编号,例如Linux(1)
根据获取到的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.
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
参考:https://www.eve-ng.net/index.php/documentation/howtos/howto-create-own-linux-host-image/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。