• Clone virtual machine:
    virt-clone -o template-wheezy --prompt
  • Serial console:
    virsh console <domain>
  • Enable autostart:
    virsh autostart <domain>
  • Edit configuration:
    virsh edit <domain>
  • Undefine virtual machine:
    virsh undefine <domain>
  • Delete volume:
    virsh vol-delete <volume path>
  1. Resize qcow image:
    qemu-img resize <qcow.img> +100G
  2. Map qcow image:
    modprobe nbd
    qemu-nbd -c /dev/nbd1 /path/to/qcow/image
  3. If needed, resize LVM container (delete old partition and create a new one):
    cfdisk /dev/nbd1
  4. Resize LVM Physical Volume:
    pvresize /dev/nbd1p2
  5. Enable Volume Group:
    vgchange -ay <vg>
  6. Resize Logical Volumes:
    lvresize /dev/<vg>/<lv> -L +2G
  7. Resize file system:
    resize2fs /dev/<vg>/<lv>
  8. Unmap qcow image:
    qemu-nbd -d /dev/nbd1
  1. Create logical volume:
    lvcreate -L 20G -n <lv> <vg>
  2. Convert qcow image to raw:
    qemu-img convert -p vm.img -O raw vm.raw
  3. Copy raw image to previously created LV:
    dd if=vm.raw of=/dev/<vg>/<lv>
  • sysadmin/virtualisation.txt
  • Last modified: 2017/02/01 19:43
  • by Benjamin Collet