系统环境:
系统环境:debian-12.4.0-amd64-netinst.iso
内核版本:debian 6.1.0-15-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.66-1 (2023-12-09) x86_64 GNU/Linux
KVM版本:
安装 Debian12 虚拟机报错 使用下载在本地 iso 文件安装虚拟机,结果报:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 leazhi@debian:~$ virt-install --name vm001-debian12 --ram 4096 --disk path=/dat a/kvm/storage/vm001-debian12.4.qcow2,size=50 --vcpus 4 --os-variant debian11 -- network bridge=br0 --graphics none --console pty,target_type=serial --extra-ar gs 'console=ttyS0,115200n8' --arch x86_64 --autostart --location /data/kvm/ima ges/debian-12.4.0-amd64-netinst.iso,kernel=install/vmlinuz,initrd=install/initr d.gz WARNING KVM acceleration not available, using 'qemu' Starting install... ERROR Couldn't find kernel for install tree. Domain installation does not appear to have been successful. If it was, you can restart your domain by running: virsh --connect qemu:///session start vm001-debian12 otherwise, please restart your installation.
根据从网上找到的资料,基本上都是说不同系统所需的内核参数不同,如下:
1 2 3 4 5 6 7 Distro Kernel path RAM disk path Fedora /isolinux/vmlinuz /isolinux/initrd.img RHEL5/CentOS5 /isolinux/vmlinuz /isolinux/initrd.img openSUSE /boot/i386/loader/linux /boot/i386/loader/initrd Mandriva /i586/isolinux/alt0/vmlinuz /i586/isolinux/alt0/all.rdz Ubuntu /casper/vmlinuz /casper/initrd.gz Debian /install.386/vmlinuz/ /isolinux/initrd.img
也有的说使用 isoinfo 查看内核文件所在路径(但是执行后发现不显示路径):
1 2 3 4 5 6 7 8 9 leazhi@debian:~$ sudo apt install -y genisoimage leazhi@debian:~$ sudo isoinfo -J -i /data/kvm/images/debian-12.4.0-amd64-netinst.iso -l |egrep -i '(vmlinuz|initrd)' ---------- 0 0 0 22608175 Dec 10 2023 [ 97962 00] initrd.gz ---------- 0 0 0 8140672 Dec 10 2023 [ 93987 00] vmlinuz ---------- 0 0 0 58967974 Dec 10 2023 [ 65194 00] initrd.gz ---------- 0 0 0 8140672 Dec 10 2023 [ 93987 00] vmlinuz ---------- 0 0 0 54759078 Dec 10 2023 [ 109006 00] initrd.gz ---------- 0 0 0 8140672 Dec 10 2023 [ 93987 00] vmlinuz ---------- 0 0 0 4172 Sep 21 2018 [ 218404 00] initrd-kickseed_0.63_all.udeb
而实际情况根据自己亲自测试,发现都无法行得通。
最终,解决方法如下:
1.将下载到本地的 iso 文件挂载到本地的 /media/cdrom 目录:
1 sudo mount /data/kvm/images/debian-12.4.0-amd64-netinst.iso /media/cdrom/
2.其次,进入挂载目录,查找内核文件所在目录:
1 2 3 4 5 6 7 8 9 10 cd /media/cdromleazhi@debian:/media/cdrom$ find ./* -type f |egrep -i '(vmlinuz|initrd)' ./install.amd/gtk/initrd.gz ./install.amd/gtk/vmlinuz ./install.amd/initrd.gz ./install.amd/vmlinuz ./install.amd/xen/initrd.gz ./install.amd/xen/vmlinuz ./pool/main/k/kickseed/initrd-kickseed_0.63_all.udeb
从上面查找到的文件可以看到,系统的内核文件都在 install.amd
目录下。所以,我们需要将安装命令中所传的内核参数做如下修改(正确的指定内核文件所在的目录)即可!:
1 leazhi@debian:/media/cdrom$ virt-install --name vm002-debian12 --ram 4096 --disk path=/data/kvm/storage/vm002-debian12.4.qcow2,size=50 --vcpus 4 --os-variant debian11 --network bridge=br0 --graphics none --console pty,target_type=serial --extra-args 'console=ttyS0,115200n8' --arch x86_64 --autostart --location /data/kvm/images/debian-12.4.0-amd64-netinst.iso,kernel=install.amd/vmlinuz,initrd=install.amd/initrd.gz