User Tools

Site Tools


public:techstuff:libvirt

This is an old revision of the document!


libvirt

Creating a VM

Basic install

virt-install
--name=<VM name>
--ram=<memory in MB>
--location=http://ftp.nz.debian.org/debian/dists/<version>/main/installer-amd64/
--os-type=linux
--os-variant=debiansqueeze
--disk=/img/<vm name>.img,device=disk,bus=virtio,size=<disk size GB>,sparse=true,format=raw

Existing image

virt-install
--name <VM name>
--ram <memory>
--disk path=/img/<VM name>.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 <vmname>.img
--disk pool=<pool name>,size=<size in GB>,bus=virtio,cache=none
  • If you want a specific name you'll need to create the volume manually first.
virsh vol-create-as <pool name> <volume name> <size>
  • And then use this line to specify it.
--disk vol=<poolname>/<volume name>,bus=virtio,cache=none

Open Serial Console to VM

virsh console <VM name>

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.

public/techstuff/libvirt.1348318229.txt.gz · Last modified: 2020/04/25 13:05 (external edit)