TOPIC 3

Date: 2/5/2020
Server virtualization with KVM
Linux System Administration


Management user interface, virsh


  • KVM installation, as well as VM configuration, deployment have already been covered in the previous lessons.
  • Command virsh is a CLI alternative to the GUI based virt-manager.
    It can be used, for example, to see the list of running VMs:
    Exercises:
    
    virsh list
    
    List of all the VMs:
    
    virsh list --all
    
    Start a VM, kvm1 for example:
    
    virsh start kvm1
    

    To be able to shutdown a VM through virsh, service acpid needs to be installed and running on the VM.
    acpid stands for Advanced Configuration and Power Interface event daemon.
    Login to the VM, kvm1, through virt-manager and install acpid:
    
    apt-get install acpid
    
    Logout and try to shutdown it through virsh
    
    virsh shutdown kvm1
    
    Verify that it is down
    
    virsh list --all
    
    Start the VM again
    
    virsh start kvm1
    

  • In order to be able to access console on the VM, we need to enable ttyS0 service on the VM:
    Login to the VM, kvm1, through virt-manager as user hostadm.
    Elavate the privileges to root with command sudo:
    
    sudo -s
    
    Then edit file /etc/default/grub, and assign values to parameters GRUB_CMDLINE_LINUX_DEFAULT, and GRUB_TERMINAL as follows
    
    GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"
    
    GRUB_TERMINAL=serial
    
    Run command
    
    update-grub
    
    reboot the VM by executing command reboot:
    
    reboot
    

  • Close the virt-manager.
    Try to login to the VM console from the desktop terminal by using command virsh:
    
    virsh console kvm1
    
    To exit from the console, press ^]


  • Take me to the Course Website