4

I would like install 3 KVM guests automatically using kickstart. I have no problem installing it manually using virt-install command.

virt-install \
-n dal \
-r 2048 \
--vcpus=1 \
--os-variant=rhel6 \
--accelerate \
--network  bridge:br1,model=virtio \
--disk path=/home/dal_internal,size=128 --force \
--location="/home/kvm.iso" \
--nographics \
--extra-args="ks=file:/dal_kick.cfg console=tty0 console=ttyS0,115200n8 serial" \
--initrd-inject=/opt/dal_kick.cfg \
--virt-type kvm

I have 3 scripts like the one above - i would like to install all 3 at the same time, how can i disable the console? or running it in the background?

Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

3

Based on virt-install man page: http://www.tin.org/bin/man.cgi?section=1&topic=virt-install

--noautoconsole

Don't automatically try to connect to the guest console. The
           default behaviour is to launch virt-viewer(1) to display the
           graphical console, or to run the "virsh" "console" command to
           display the text console. Use of this parameter will disable this
           behaviour.

virt-install will connect console automatically. If you don't want, just simply add --noautoconsole in your cmd like

virt-install \
-n dal \
-r 2048 \
--vcpus=1 \
--quiet \
--noautoconsole \
...... other options
kalu Wang
  • 191
  • 1
  • 4
0

We faced the same problem and at the end the only way we found was to create new threads with the &.

We also include the quiet option, not mandatory. ---quiet option (Only print fatal error messages).

virt-install \
-n dal \
-r 2048 \
--vcpus=1 \
--quiet \
--os-variant=rhel6 \
--accelerate \
--network  bridge:br1,model=virtio \
--disk path=/home/dal_internal,size=128 --force \
--location="/home/kvm.iso" \
--nographics \
--extra-args="ks=file:/dal_kick.cfg console=tty0 console=ttyS0,115200n8 serial" \
--initrd-inject=/opt/dal_kick.cfg \
--virt-type kvm &
Ferrandinand
  • 444
  • 3
  • 11
0

I know this is kind of old, but I wanted to share my thoughts. I ran into the same problem, but due to the environment we work in, we need to use sudo with a password (compliance reasons). The solution I came up with was to use timeout instead of &. When we fork it right away, it would hang due to the sudo prompt never appearing. So using timeout with your example above: (we obviously did timeout 10 sudo virt-instal...)

timeout 15 virt-install \
-n dal \
-r 2048 \
--vcpus=1 \
--quiet \
--os-variant=rhel6 \
--accelerate \
--network  bridge:br1,model=virtio \
--disk path=/home/dal_internal,size=128 --force \
--location="/home/kvm.iso" \
--nographics \
--extra-args="ks=file:/dal_kick.cfg console=tty0 console=ttyS0,115200n8 serial" \
--initrd-inject=/opt/dal_kick.cfg \
--virt-type kvm

This allowed us to interact with our sudo prompt and send the password over, and then start the build. The timeout doesnt kill the process, it will continue on and so can your script.