KVMとKickstart - 終了できません

KVMとKickstart - 終了できません

KVMサーバーを管理するのに役立つツールを作成しています。 kickstart ファイルを使用して KVM ゲストを自動的にインストールするコマンドを生成します。以下は、Ubuntu 16.04クライアントのインストールを自動化するために生成されるサンプルコマンドです。

virt-install --connect qemu:///system  \
--nographics \
--os-type linux \
--accelerate \
--hvm \
--network network=default,model=virtio \
--name testing124 \
--os-variant ubuntu16.04 \
--ram 1024 \
--vcpus 2 \
--location http://us.archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/ \
--disk /home/stuart/code-copy/vms/testing124/disk.raw,bus=virtio,format=raw,cache=writethrough \
--extra-args "console=ttyS0 ks=http://pastebin.com/raw/6TznVUuN"

これまでに行ったように、印刷して手動でコピーして貼り付けるのではなく、execコマンドを使用してツール内でこのコマンドを実行したいと思います。問題はコマンドは完了しません。仮想コンソールは常に開いているためです。デフォルトでは、ゲストはコンソールが接続された状態で再起動されます。shutdown代わりに指定すると、rebootインストールはこの段階で中止されます。

ここに画像の説明を入力してください。

代わりにhaltまたはを指定すると、ゲストは終了しますが、コンソールはまだ空の画面で停止します。 Virshもまるであなたが処刑したかのようにゲストに表示されます。poweroffshutdownrunningvirsh list --all

KVMゲストのインストールを正しく完了するには、コマンドまたはkickstartファイルをどのように変更する必要がありますか?

付録

参照ファイルが変更または欠落している場合は、以下のキックスタートファイルをコピーしてください。

# Ubuntu server 64bit example kickstart/seed with shutdown

# System language
#lang en_US
lang en_GB

# Language modules to install
#langsupport en_US
langsupport en_GB

# System keyboard
keyboard us

# System mouse
mouse

# System timezone
#timezone America/Chicago
timezone --utc America/Chicago

# Root password
rootpw --disabled

# Initial user
user ubuntu --fullname "" --password ubuntu
preseed user-setup/allow-password-weak boolean true

# pick only one of these actions to take after installation completed
#reboot
#shutdown
#halt
poweroff

# Use text mode install
text

# Install OS instead of upgrade
install

# Use http installation media
url --url http://archive.ubuntu.com/ubuntu

# System bootloader configuration
bootloader --location=mbr

# Clear the Master Boot Record
zerombr yes

# Partition clearing information
clearpart --all --initlabel

# Partition setup
part / --fstype ext4 --size 1 --grow
#part /boot --fstype ext2 --size 200 --asprimary
#part swap  --size 1024
#part pv.01 --size 1 --grow
#volgroup rootvg pv.01
#logvol / --fstype ext4 --vgname=rootvg --size=1 --grow --name=rootvol
#preseed partman-lvm/confirm_nooverwrite boolean true

# If you have swap commented out/not specified then you need to have this line.
preseed --owner partman-basicfilesystems partman-basicfilesystems/no_swap boolean false

# System authorization infomation
auth  --useshadow  --enablemd5

# Firewall configuration
firewall --disabled

# Do not configure the X Window System
skipx

# Make sure to install the acpid package so that virsh commands such
# as virsh shutdown will take effect
%packages
@ubuntu-server
@openssh-server
@acpid

ベストアンサー1

--noautoconsoleこれがオプションの完全な選択であることがわかりましたvirt-install

説明:マニュアルページ:

ゲストコンソールに自動的に接続しようとしないでください。デフォルトの動作は、VNCクライアントを起動してグラフィカルコンソールを表示するか、 "virsh" "console"コマンドを実行してテキストコンソールを表示することです。このパラメータを使用すると、この動作は無効になります。

これで、プログラムで実行されるvirt-installコマンドはコンソールに接続されず、ゲストがインストールが完了するのを待たないため、ほとんどすぐに実行され返されます。コンソールに何も接続されていなくても、ゲストはkickstartスクリプトを使用してバックグラウンドでインストールを続行します。キックスタートファイルに問題がない場合、ゲストはフルインストールを実行し、完了時に終了します(キックスタートファイルにシャットダウンが指定されている場合)。virsh list --allゲストが表示されなくなるまでポーリングして、ゲストがインストールを完了したことを確認できますrunning

更新されたコマンドは次のとおりです。

virt-install --connect qemu:///system  \
--nographics \
--os-type linux \
--accelerate \
--hvm \
--network network=default,model=virtio \
--name testing124 \
--os-variant ubuntu16.04 \
--ram 1024 \
--vcpus 2 \
--location http://us.archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/ \
--disk /home/stuart/code-copy/vms/testing124/disk.raw,bus=virtio,format=raw,cache=writethrough \
--noautoconsole \
--extra-args "console=ttyS0 ks=http://pastebin.com/raw/6TznVUuN"

おすすめ記事