Deploy a guest virtual machine on a bare metal system


Bare metal servers are powerful systems that provide users with sole access to the entire server. A pure bare metal server is a single server that is offered without a hypervisor. Bare metal servers can be acquired in a preconfigured or a custom-configured form to exact specifications. Refer to bare metal systems for more information.

This tutorial explains how to install guests, that is, VMs on an IBM® Power Systems™ bare metal server. The operating system installed on the bare metal system is the host system, whereas the virtual machine we are trying to install as per the instructions in this tutorial is the guest system. You can install guest VMs using both text-based and graphical user interface (GUI) based methods. This tutorial explains both.


You need to make sure that the following prerequisites are fulfilled before installing a guest VM on a bare metal system:

  1. Make sure that the bare metal system is already installed with Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), or Ubuntu operating system as the host operating system.

  2. Perform these additional steps on the bare metal system on which you will deploy the guest VM. In this example, RHEL is installed on the bare metal system as the host operating system and RHEL will also be installed as the guest operating system.

    1. Install all necessary packages and RPMs for RHEL by setting up a repository to perform yum update.

    2. Run the following commands to install the mandatory packages to set up guests on your host operating system.

         yum install qemu-*
         yum install virt-*
         yum install libvirt-daemon
         yum install libvirt-daemon-driver-*
    3. Start the libvirt service using the following command:

      service libvirtd start


    4. Verify if the setup is done properly using the following command:

      virsh list -all


    The output of the command with the ID, name, and state shows that the setup is done properly. In this example, the virsh list is blank because no guests are installed yet on our host operating system.

    After performing these steps, the host operating system is now ready for you to deploy the required operating system (RHEL, SLES, or Ubuntu) on the guest virtual machines.

Estimated time

In an ideal scenario (if everything runs smoothly), it takes around 45 minutes to 1 hr to install all the packages, RPMs and the guest virtual machine.


Installing a guest VM on a bare metal system

There are two ways to install a guest VM on a bare metal system:

  • Using the virt command (text-based installation)

  • Using XML file (GUI-based installation)

Text-based installation of guest (using virt command)

Perform the following steps for text-based installation of a guest operating system using the virt command:

  1. Copy the OS image (ISO) file to path /var/lib/libvirt/images/ of your system.

  2. Create a directory named data (in var/lib/libvirt/images/) to place a virtual hard disk where we will mount the OS.

    mkdir data

  3. Run the following command to create a virtual image disk of size 30 GB from the path /var/lib/libvirt/images/data/.

    qemu-img create -f qcow2 vm-name.qcow2 30G

    For example:

    qemu-img create -f qcow2 Myvm1.qcow2 30G

    Name of the VM: Myvm1 (guest name can be anything)

    The following output is displayed.



  4. Install the OS using the virt-install command and specify the ISO path as well as qcow image path. Navigate to the data folder, var/lib/libvirt/images/data, and then run the virt-install command.

     virt-install --name Myvm1 --ram 2048 --disk path=/var/lib/libvirt/images/data/Myvm1.qcow2,size=8 --vcpus 4 --os-type linux --os-variant generic --network bridge=virbr0 --graphics none --console pty,target_type=serial --cdrom /var/lib/libvirt/images/isoimage.iso

    isoimage.iso is the ISO image of the operation system you want to install as guest.


  5. During the installation process, provide the necessary input.

    Refer to the following link for text-based installation:

  6. Proceed with the remaining steps to complete the installation process.

  7. If your installer prompts, log in to the guest operating system (that is, the VM)

  8. If required, press Ctrl+] to exit from the guest operating system.

  9. To verify if the guest is installed successfully run the following command:

    virsh list -all


    Status running indicates that the guest Myvm1 is installed successfully and is running.

  10. Again, if required, log in to the guest system using the following command:

    virsh console <VM number or VM name>

    For example:

    virsh console 4
    virsh console Myvm1


GUI-based installation of guest (using an XML file)

This section explains the step-by-step method for installing the guest VM using the GUI-based method.

Perform the following steps to install a guest VM on a host:

  1. Create a file (guestname.xml) at the path /var/lib/libvirt/images/data/

    Refer to the sample XML file in the Appendix.

    For example: Myvm2.xml


  2. Create a qcow image at the path /var/lib/libvirt/images/data/

    qemu-img create -f qcow2 guestname.qcow2 30G

    For example:

    qemu-img create -f qcow2 Myvm2.qcow2 30G


  3. Define the XML file created in step 1 using the following command:

    virsh define guestname.xml

    For example:

    virsh define Myvm2.xml


  4. Start the guest system using the virsh start command:

    virsh start guestname

    For example:

    virsh start Myvm2


  5. Enable Virtual Network Computing (VNC) to view the GUI console.

    VNC is a graphical desktop sharing system that uses the RFB (remote framebuffer) protocol to remotely control another computer.

    virsh vncdisplay guestname

    For example:

    virsh vncdisplay Myvm2


  6. Enable the TCP port 5900 to connect to VNC (a platform independent desktop sharing and remote control application).

    sudo iptables -I INPUT 1 -p tcp --dport 5900 -j ACCEPT

  7. Run the ifconfig command to check the IP of the system to connect to VNC:


  8. Provide the host IP and port number in the VNC viewer as mentioned in following example and start installation:

    For example:

    Note: If VNC is not connecting to, disable the system firewall using the following command and try to reconnect to VNC:

    service firewalld stop


    After completing the installation, log in to your guest system.

    The following screen capture shows that the two VMs are present in the host operating system.


  9. Connect with the latest guest system installed by using the GUI method.


    Refer to Table 1 to identify the virsh commands to start, edit, or stop your guest system.

Table 1. Description of virsh commands
virsh command Example Description
virsh List virsh list -all Lists all the guest VMs present in your system
virsh console virsh console <guest name/guest number> Selects the guest VM
virsh start virsh start <guest name/guest number> Starts the guest VM
virsh edit virsh edit <guest name/guest number> Edits the guest VM
virsh destroy virsh destroy <guest name/guest number> Stops the guest VM


By using the steps outlined in this tutorial, you can easily install a guest VM on a bare metal system, which is considered quite complicated when compared to using a hypervisor.

Sample XML file

In the sample XML file shown in this section, you can just change the guest name, qcow image path, and the ISO path and use it to install a guest on a bare metal system.

Before copying the ISO image, make sure that your image is copied completely, otherwise you will not be able to proceed with the steps smoothly.

Sample XML file

   <domain type='kvm'>
     <memory unit='KiB'>4194304</memory>
     <currentMemory unit='KiB'>4194304</currentMemory>
     <vcpu placement='static'>10</vcpu>
     <type arch='ppc64le' machine='pseries-rhel7.5.0'>hvm</type>
     <boot dev='cdrom'/>
     <topology sockets='2' cores='5' threads='1'/>
     <clock offset='utc'/>
     <disk type='file' device='disk'>
     <driver name='qemu' type='qcow2' cache='none'/>
     <source file='/var/lib/libvirt/images/data/Myvm2.qcow2'/>
     <target dev='vda' bus='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     <disk type='file' device='cdrom'>
     <driver name='qemu' type='raw'/>
     <source file='/var/lib/libvirt/images/OS.iso'/>
     <target dev='sda' bus='scsi'/>
     <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     <controller type='usb' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     <controller type='pci' index='0' model='pci-root'/>
     <controller type='scsi' index='0'>
     <address type='spapr-vio' reg='0x2000'/>
     <interface type='bridge'>
     <mac address='52:54:c0:08:70:95'/>
     <source bridge='virbr0'/>
     <model type='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
     <serial type='pty'>
     <target port='0'/>
     <address type='spapr-vio' reg='0x30000000'/>
     <console type='pty'>
     <target type='serial' port='0'/>
     <address type='spapr-vio' reg='0x30000000'/>
     <input type='keyboard' bus='usb'/>
     <input type='mouse' bus='usb'/>
     <graphics type='vnc' port='5900' autoport='yes' listen=''>
     <listen type='address' address=''/>
      <model type='vga' vram='16384' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
      <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
      </memballoon><panic model='pseries'/>
      <seclabel type='dynamic' model='selinux' relabel='yes'/>