1

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 get stuck in a loop, as follows:

  1. Boot from kernel/initrd -> installation completed
  2. Restart
  3. Boot from kernel/initrd -> installation completed
  4. Restart
  5. (loop)

I have tried to use the following command to strip kernel related configuration, without success:

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 skips it and keesp booting from local kernel/initrd.

1 Answer 1

1

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.

2
  • Thanks! --noreboot seems exactly what I need. I can keep probing VM status and when it shut off, I can virsh dumpxml virsh define to change configuration then virsh start.
    – Rayer
    Dec 4, 2015 at 1:36
  • @Rayer That will work. But I still strongly recommend you use --location instead, if you are installing one of its supported distributions (RHEL/CentOS, Fedora, Debian, Ubuntu, SuSE, and a couple of more obscure ones listed in the man page). But if you insist on going that route, I have a few bash functions that might help you out. Dec 4, 2015 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .