概要
KVMゲストマシン作成"後"のブートデバイスの指定方法をまとめた。
ゲストマシン作成"時"はこちら。
none06.hatenadiary.org
サマリ
ブートデバイスの指定例
定義 | 意味 | 備考 |
---|---|---|
<boot dev='hd'/> | HDDブート | 併せてdiskディレクティブの定義が必要 |
<boot dev='cdrom'/> | ODDブート | 併せてdiskディレクティブの定義が必要 |
<boot dev='network'/> | NWブート | 併せてinterfaceの定義が必要 |
設定場所:osタグ内
<os> <type arch='x86_64' machine='pc-i440fx-rhel7.6.0'>hvm</type> <boot dev='network'/> <boot dev='cdrom'/> <boot dev='hd'/> </os>
併せて必要な定義例
# 可変部を重複がないように修正すれば流用いただける想定。
hd
「bus='ide'」の場合
<disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/guest01.img'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk>
「bus='virtio'」の場合
<disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/guest01.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> </disk>
cdrom
「bus='ide'」の場合
<disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/tmp/CentOS-7-x86_64-Minimal-1908.iso'/> <target dev='hdb' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk>
「bus='virtio'」の場合
<disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/tmp/CentOS-7-x86_64-Minimal-1908.iso'/> <target dev='vdb' bus='virtio'/> <readonly/> <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/> </disk>
network
「type='e1000'」の場合
<interface type='bridge'> <mac address='52:54:00:fb:ae:43'/> <source bridge='br0'/> <model type='e1000'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>
「type='virtio'」の場合
<interface type='bridge'> <mac address='52:54:00:0d:61:24'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface>
設定場所:devicesタグ内
<devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/guest01.img'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk>
あると便利な定義(オプション)
定義 | 意味 | 備考 |
---|---|---|
<bootmenu enable='yes' timeout='3000'/> | ブートメニューを有効化 | 3秒間無操作でブートメニューをスキップ |
<bios useserial='yes'/> | BIOSのシリアルコンソール接続を有効化 | virsh consoleからブートメニューを操作できるようになる |
# bios useserialが無効の場合はGUIのコンソールからブートメニューを操作するしかないと思われる。
設定場所:osタグ内
<os> <type arch='x86_64' machine='pc-i440fx-rhel7.6.0'>hvm</type> <boot dev='hd'/> <bootmenu enable='yes' timeout='3000'/> <bios useserial='yes'/> </os>
参考
・hd/cdromの「bus」やnetworkの「model type」はどこで決まるのか?
→virt-installのオプション指定で差が出た。
オプション「--os-variant centos7.0」 | hd | cdrom | network |
---|---|---|---|
なし | ide | ide | e1000 |
あり | virtio | sata | virtio |