User Tools

Site Tools


public:techstuff:libvirt

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
public:techstuff:libvirt [2012/09/17 09:09] nathanpublic:techstuff:libvirt [2020/04/25 13:05] (current) – external edit 127.0.0.1
Line 3: Line 3:
 ===== Creating a VM ===== ===== Creating a VM =====
  
-  virt-install \ +==== Creating an KVM VM ====
-  --name=<VM name> \ +
-  --ram=<memory>+
-  --location=http://ftp.nz.debian.org/debian/dists/stable/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 \ +
-  --network=bridge=int,model=virtio \ +
-  --extra-args=console=ttyS0,115200+
  
-===== Creating a VM from an existing image =====+  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 
 + 
 +==== Creating an LXC VM ==== 
 + 
 +  * Capped resources at 512mb of ram and 2 cpus 
 + 
 +  cd /img 
 +  mkdir <vmname> 
 +  sudo debootstrap wheezy <vmname> 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 \   virt-install \
-  --name <VM name> \ +  --connect lxc:/// 
-  --ram <memory> +  --name httpd_guest 
-  --vcpus 1 \ +  --ram 512 
-  --disk path=/img/<VM name>.img \+  --vcpus 2 
 +==== Existing KVM image ==== 
 + 
 +  virt-install 
 +  --name <VM name> 
 +  --ram <memory> 
 +  --disk path=/img/<VM name>.img
   --import --noautoconsole --force   --import --noautoconsole --force
 +
 +==== Other Useful Options ====
 +
 +  * Create VM with a bridge attached to eth0 
 +<code>--network=bridge=eth0,model=virtio</code>
 +
 +  * Run install over console
 +
 +<code>--extra-args=console=ttyS0,115200</code>
 +
 +  * Installing to an LVM Pool instead. Replace disk line with this one. You'll end up with a volume called <vmname>.img
 +
 +<code>--disk pool=<pool name>,size=<size in GB>,bus=virtio,cache=none</code>
 +
 +  * If you want a specific name you'll need to create the volume manually first.
 +
 +<code>virsh vol-create-as <pool name> <volume name> <size></code>
 +
 +And then use this line to specify it.
 +
 +<code>--disk vol=<poolname>/<volume name>,bus=virtio,cache=none</code>
  
 ===== Open Serial Console to VM ===== ===== Open Serial Console to VM =====
public/techstuff/libvirt.1347872991.txt.gz · Last modified: 2020/04/25 13:05 (external edit)