I am trying using automation install via KVM. The step is :
1. Load Kernel and initrd from disk
2. It will install customized Linux to HDD, and automatically reboot
3. Boot from HDD
So I use this command to install my customized linux :
virt-install --name Kernel_Test --ram 16384 --vcpus=8 --os-type=linux --os-variant=rhel6 --vnc --hvm --disk path=/kvm_images//Kernel_Test.qcow2,device=disk,format=qcow2,size=50,bus=sata --boot hd,kernel=/tmp/my_vmlinuz,initrd=/tmp/my_image,kernel_args="append stage2=initrd:" --network bridge=bridge1,model=virtio --network bridge=bridge1,model=virtio --network bridge=bridge0,model=virtio
However, it will stuck in loop. It will boot from kernel/initrd -> installation completed and restart -> boot from kernel/initrd -> installation completed and restart -> (loop).
I have tried to use follow command to strip kernel related configuration but have no use :
virsh dumpxml <VMNAME> >> vmname.xml (do something to change vmname.xml, strip kernel/initrd boot part) virsh define vmname.xml
It will still keep looping, and when I dumpxml again, it still holds kernel/initrd boot configuration.
Because I need to automatic installation, how can I let KVM only boot once from destinated kernel/initrd? I have set boot sequence “–boot hd, ” in front of “kernel= …”, but it just skip it and keep booting from local kernel/initrd.
If a direct kernel boot is present, it will always be used, and the regular boot order will be ignored.
The best way to handle this is to not use direct kernel boot for installing the system, but rather pass a
--location where the Linux distribution you are installing lives (which can be on a local disk or a remote web server, FTP or NFS server). This also allows you to inject a local kickstart or preseed file for a completely automated installation. For example:
--boot hd --location http://mirror.centos.org/centos/7/os/x86_64 --initrd-inject=my_vm.ks --extra-args="ks=file:/my_vm.ks"
If you can’t do that for some reason, then pass
--noreboot and hack the XML after virt-install exits. You will have to restart the VM manually. Remember that virt-install can exit before the installation completes, so simply restarting the VM won’t work reliably and could interrupt an installation in progress.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.