This section explains how to run Clear Linux* OS in a virtualized environment using KVM.

Install QEMU-KVM

  1. Enable the Intel® Virtualization Technology (Intel® VT) and the Intel®Virtualization Technology for Directed I/O (Intel® VT-d) in the host machine’s BIOS.

  2. Log in, open a terminal emulator, and get root privilege on the host machine:

    sudo -s
    
  3. Install QEMU*-KVM on the host machine. Below are some example distros.

    • On Clear Linux OS:

      swupd bundle-add desktop-autostart kvm-host
      
    • On Ubuntu* 16.04 LTS Desktop:

      apt-get install qemu-kvm
      
    • On Mint* 18.1 “Serena” Desktop:

      apt-get install qemu-kvm
      
    • On Fedora* 25 Workstation:

      dnf install qemu-kvm
      

Download and launch the virtual machine

  1. Download the latest pre-built Clear Linux OS KVM image file from the image directory. Look for clear-<version>-kvm.img.xz. You can also use this command:

    curl -O https://download.clearlinux.org/image/$(curl https://download.clearlinux.org/image/latest-images | grep '[0-9]'-kvm)
    
  2. Uncompress the downloaded image:

    unxz clear-<version>-kvm.img.xz
    
  3. Download the OVMF file file that provides UEFI support for virtual machines from the image directory.

  4. Download the sample QEMU-KVM launcher script from the image directory. This script will launch the Clear Linux OS VM and provide console interaction within the same terminal emulator window.

  5. Make the script executable:

    chmod +x start_qemu.sh
    
  6. Start the Clear Linux OS KVM virtual machine:

    ./start_qemu.sh clear-<version>-kvm.img
    
  7. Log in as root user and set a new password.

SSH access into the virtual machine

To interact with the Clear Linux OS VM through SSH instead of the console it was launched from, follow these steps.

  1. Enable SSH in the Clear Linux OS VM:

    cat > /etc/ssh/sshd_config << EOF
      PermitRootLogin yes
      EOF
    
  2. From the host, SSH into the Clear Linux OS VM. The port number 10022 is defined in the start_qemu.sh script.

    ssh -p 10022 root@localhost
    

Add the GNOME Display Manager (GDM)

To add GDM to the Clear Linux OS VM, follow these steps:

  1. Shutdown the active Clear Linux OS VM.

    shutdown now
    
  2. Install a VNC viewer on the host machine. Below are some example distros.

    • On Clear Linux:

      swupd bundle-add desktop-apps-extras
      
    • On Ubuntu* 16.04 LTS Desktop:

      apt-get install vncviewer
      
    • On Mint* 18.1 “Serena” Desktop:

      apt-get install vncviewer
      
    • On Fedora* 25 Workstation:

      dnf install tigervnc
      
  3. Modify the start_qemu.sh script to increase memory (-m), add graphics driver (-vga), and add VNC (-vnc, -usb, and -device) support.

    qemu-system-x86_64 \
        -enable-kvm \
        -bios OVMF.fd \
        -smp sockets=1,cpus=4,cores=2 -cpu host \
        -m 4096 \
        -vga qxl \
        -vnc :0 -nographic \
        -usb \
        -device usb-tablet \
        -drive file="$IMAGE",if=virtio,aio=threads,format=raw \
        -netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375 \
        -device virtio-net-pci,netdev=mynet0 \
        -debugcon file:debug.log -global isa-debugcon.iobase=0x402 $@
    
  4. Due to changes in the start_qemu.sh script from the previous step, the UEFI NvVars information for the previously-booted Clear Linux OS VM will need to be reset.

    1. Relaunch the Clear Linux OS VM. The UEFI shell will appear.

      ./start_qemu.sh clear-<version>-kvm.img
      
    2. At the UEFI shell, delete the NvVars file:

      Shell> del FS0:\NvVars
      
    3. Exit out of the UEFI shell:

      Shell> reset -s
      
    4. Relaunch the Clear Linux OS VM:

      ./start_qemu.sh clear-<version>-kvm.img
      
  5. From the host machine, open a new terminal emulator window and VNC into the Clear Linux OS VM:

    vncviewer 0.0.0.0
    
  6. Log in as root user into the Clear Linux OS VM.

  7. Add GDM to the Clear Linux OS VM:

    swupd bundle-add desktop-autostart
    
  8. Reboot the Clear Linux OS VM to enable GDM:

    reboot
    
  9. Go through GDM’s out-of-box experience (OOBE).

  10. The default aspect ratio of the GDM GUI for the Clear Linux OS VM is 4:3. To change it, use GDM’s Displays setting tool (located at the top-right corner).