Booting from a temporary boot device

You might want to start a virtual server with a guest that boots from a device other than the configured boot device, for example for maintenance or in a recovery situation. With virt-xml, you can override the boot device that is configured in the libvirt-internal configuration and start the virtual server with a temporary boot device.

Procedure

  1. Optional: Display the current virtual server configuration in XML format.
    Example:
    # virsh dumpxml vs002 
    <domain>
       <name>vs002</name>
       ... 
       <devices>
          ...
          <!-- DVD --> 
          <controller type="scsi" model="virtio-scsi" index="4"/>
          <disk type="file" device="cdrom">
             <driver name="qemu" type="raw" io="native" cache="none"/>
             <source file="/var/lib/libvirt/images/Linux­DVD1.iso"/>
             <target dev="sda" bus="scsi"/>
             <address type="drive" controller="4" bus="0" target="0" unit="0"/>
             <readonly/>
          </disk>
          ...
          <hostdev mode="subsystem" type="mdev" model="vfio-ccw">
             <source>
                <address uuid="90c6c135-ad44-41d0-b1b7-bae47de48627"/>
             </source>
             <address type="ccw" cssid="0xfe" ssid="0x0" devno="0x00a1"/>
          </hostdev>
          ... 
          <!-- IPL disk  --> 
          <disk type="block" device="disk">
             <driver name="qemu" type="raw" cache="none" 
                     io="native" iothread="1"/>
             <source dev="/dev/mapper/36005076305ffc1ae00000000000021d7"/>
             <target dev="vda" bus="virtio"/>
             <boot order="1"/>
          </disk>
          ...
       </devices>
    </domain>
    The sample XML snippet configures two disks to the guest.
    vda
    includes the boot element with attribute order="1", which configures this disk as the boot device.
    sda
    a DVD image file that is configured as another disk, which is to be the temporary boot device.

    The two devices need not be disks but can be any two bootable devices. The virt-xml command in the step that follows changes accordingly.

  2. Start the virtual server with a virt-xml command that includes the --no-define and --start options and that overrides the boot device.
    The options for overriding the boot device depend on the device configurations.
    Examples: With the domain configuration-XML example of the previous step, issue one of the following commands to start virtual server vs002 from a temporary boot device:
    • Using sda as the temporary boot device.
      # virt-xml vs002 --edit target="sda" --disk="boot_order=1" --no-define --start
    • Using a pass-through DASD with device bus-ID 0.0.00a1 on the virtual server as the temporary boot device.
      # virt-xml vs002 --edit address.devno="0x00a1" --hostdev="boot_order=1" --no-define --start
    The parameters in the command have the following meaning:
    --disk="boot_order=1"
    states that the temporary boot device is configured with a disk element.
    target="sda"
    among the configured disk devices, identifies sda as the temporary boot device.
    --hostdev="boot_order=1"
    states that the temporary boot device is configured with a hostdev element.
    address.devno="00a1"
    among the configured hostdev devices, identifies the device with attribute devno="00a1" within its address element as the temporary boot device.
    --no-define --start
    applies the changes to a transient copy of the libvirt-internal configuration and starts the virtual server with that transient copy. The persistent configuration remains unchanged.
    You always need the --no-define --start parameters. The specifications for identifying the temporary boot device vary according to the boot device configuration.

Results

The virtual server starts and boots the guest from the temporary boot device. A subsequent regular start of the virtual server boots the guest from the persistently configured boot device.