Linux Virtualisation Cheat Sheet

This is a collection on mostly Xen administration commands and can be used as a cheat sheet or link collection. If you find errors or want to add something please post a comment below!

Amazon AWS

OpenVZ

  • OpenVZ Commands
    vzlist                               # List running instances
    vzlist -a                            # List all instances
    
    vzctl stop <instance>
    vzctl start <instance>
    vzctl status <instance>
    
    vzctl exec <instance> <command>      # Run a command
    
    vzctl enter <instance>               # Get console
    
    vzyum <instance> install <package>   # Install a package
    
    
    # Change properties
    vzctl set <instance> –hostname <hostname> –save
    vzctl set <instance> –ipadd <IP> –save
    vzctl set <instance> –userpasswd root:<password> –save
    

KVM

  • KVM Commands
    virsh list                # List running
    virsh list --all          # List all
    
    # Control instances
    virsh start <instance>
    virsh shutdown <instance>
    virsh destroy <instance>
    virsh suspend <instance>
    virsh resume <instance>
    
    virsh console <instance>
    
    # Define instances
    virsh dumpxml <instance> >dump.xml
    virsh create dump.xml   # Create from XML
    virsh edit <instance>
    virsh undefine <instance>
    
    virsh dominfo
    virsh vcpuinfo
    virsh nodeinfo
    
    virsh quit   # Leave CLI
    

Xen

  • Xen vs. Xen Server
  • Xen - Commands
    xm list           # List all domains
    xm list vm1       # List status of a single VM
    xm list vm1 -l    # Details for a VM 
    xm create vm1     # Starts/Creates a VM
    xm reboot vm1     
    xm shutdown vm1
    xm destroy vm1
    
    xm network-list vm1
    
    xm console vm1     # Open console to VM (escape like telnet)
    
    xm info            # HV infos
    xm top             # Monitor HV and domains
    xm log             # View HV log
    
    xm dominfo
    xm vcpuinfo
    xm nodeinfo
    
  • Ensure guest auto start on boot:
    ln -s /etc/xen/<instance> /etc/xen/auto/<instance>
  • Find out which dom0 you are on:
    dmesg | grep "command line"
    
    # Should give you something like:
    #
    # Kernel command line:  ro root=/dev/VolGroup00/LogVol00 console=xvc0 hostip=10.0.0.17
    #
    # Where "hostip" is the IP of the hypervisor
    
  • Find out which IP a VM has:
    # Grep and resolve MAC:
    xm list -l <VM name> | grep mac
    arp -a | grep -i <MAC address>

Xen Server

  • Feature Matrix XenServer Free vs. Enterprise: Whats the difference and what features are provided by "xe" what "xm" doesn't have...
  • XenServer GUI Comparison Free vs. Enterprise
  • Xen Server - Hanging Operation on Shutdown: This happens when for example a reboot doesn't work and you want to perform a shutdown to quickly restore an unresponding VM. The first task (reboot) is ineffective and won't complete and thereby will block the second task (the shutdown). Destroying the VM domain solves the issue:
    xe vm-list                                          # 1. Resolve VM UUID with 
    list_domains | grep <uuid>                          # 2. Get Domain Id
    /opt/xensource/debug/destroy_domain -domid <domid>  # 3. Kill Domain Id
    xe vm-reboot uuid=<uuid> force=true                 # 4. Force Action

    An alternative is described here and involves determining the hanging task and cancelling it:

    xe task-list                          # Get task uid
    xe task-cancel uuid=<task uuid>       # And cancel it
    
  • XenServer - Add Another Physical Disk:
    xe host-list                         # to get host UUID
    xe sr-create host-uuid=<host UUID> shared=false type=lvm content-type=user device-config:device=/dev/sdb1 name-label="Another disk"
  • XenServer - VM Paravirtualization: How to configure a single VM to be paravirtualized:
    # Configure boot
    xe vm-param-set uuid=<VM UUID> HVM-boot-policy=''
    xe vm-param-set uuid=<VM UUID> PV-bootloader=pygrub
    
    # Configure console to work in XenCenter
    xe vm-param-set uuid=<VM UUID> PV-args="console=tty0 xencons=tty"
    
    # Determine boot disk and set it bootable for XenServer
    xe vbd-list vm-uuid=$VMUUID type=Disk
    xe vbd-param-set uuid=<disk UUID> bootable=true
  • XenServer - Configure LACP Bonding: When you want to run your XenServer with interface trunking.
    # Determine UUIDs of interfaces to add
    xe pif-list
    
    # Create new network (will return network UUID)
    xe network-create name-label=bond0
    
    # Create bonding (will return bonding UUID)
    xe bond-create network-uuid=<network UUID> pif-uuids=<first pif UID>,<second pif UID>[,...]
    
    # Set bonding flags for bond0
    xe pif-param-set uuid=<bond0 UUID> other-config:bond-mode=802.3ad
    xe pif-param-set uuid=<bond0 UUID> other-config:bond-mode=lacp
    
    # Once your switch is configured check bond0 with
    cat /proc/net/bonding/bond0
    
    # Also try
    ovs-appctl bond/show bond0
    
  • XenServer - Restore VM from Image: Use "xe vm-import" to create a new VM with a new UUID: xe vm-import filename=image.xva preserve=true
  • Xen Server - Ubuntu bug: read-only filesystem

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

To prevent automated spam submissions leave this field empty.
Syndicate content