====== libvirt ====== ===== Creating a VM ===== ==== Creating an KVM VM ==== virt-install --name= --ram= --location=http://ftp.nz.debian.org/debian/dists//main/installer-amd64/ --os-type=linux --os-variant=debiansqueeze --disk=/img/.img,device=disk,bus=virtio,size=,sparse=true,format=raw ==== Creating an LXC VM ==== * Capped resources at 512mb of ram and 2 cpus cd /img mkdir sudo debootstrap wheezy http://mirror.byte.net.nz/debian/ sudo virt-install --connect lxc:/// --name cubert --ram 512 --vcpu 2 --filesystem /img/cubert/,/ --noautoconsole -w network=vm virt-install \ --connect lxc:/// --name httpd_guest --ram 512 --vcpus 2 ==== Existing KVM image ==== virt-install --name --ram --disk path=/img/.img --import --noautoconsole --force ==== Other Useful Options ==== * Create VM with a bridge attached to eth0 --network=bridge=eth0,model=virtio * Run install over console --extra-args=console=ttyS0,115200 * Installing to an LVM Pool instead. Replace disk line with this one. You'll end up with a volume called .img --disk pool=,size=,bus=virtio,cache=none * If you want a specific name you'll need to create the volume manually first. virsh vol-create-as And then use this line to specify it. --disk vol=/,bus=virtio,cache=none ===== Open Serial Console to VM ===== virsh console ===== Enable Kernel output over serial ===== On the VM edit /etc/default/grub and update GRUB_CMDLINE_LINUX GRUB_CMDLINE_LINUX="text console=tty0 console=ttyS0,115200n8" Finally run update-grub as root.