Site Tools


chuleta_kvm

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
chuleta_kvm [2018/02/27 22:50] etfiatchuleta_kvm [2023/03/17 17:00] (current) – [Modos de red] etfiat
Line 1: Line 1:
  
 ===== KVM ===== ===== KVM =====
 +==== Crear imagen ====
 +<code>
 +qemu-img create -f qcow2 image.img 10G
 +</code>
 +==== Get images info ====
 +<code>
 +qemu-img info /route/example.img
 +</code>
 +==== Convert image from qcow2 to raw ====
 +<code>
 +qemu-img convert -f qcow1 -O raw /var/lib/libvirt/images/kvm2.img /var/lib/libvirt/images/kvm2_new.img
 +qemu-img convert -f vpc -O qcow2
 +</code>
 +==== Snapshots ====
 +<code>
 +qemu-img create -f qcow2 -F qcow2 -b win10.qcow2 win10_UOC_DB.img
 +</code>
  
-=== KVM con I/O iscsi paravirtualizado soporte trim optimizados ceros===+=== KVM con I/O iscsi paravirtualizado soporte trim optimizados ceros y teclado español===
  
 <code> <code>
-qemu-system-x86_64 -enable-kvm -m 4000  -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd  -drive if=none,discard=on,detect-zeroes=on,file=debian.cow,id=hd +qemu-system-x86_64 -enable-kvm -m 4000  -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd  -drive if=none,discard=on,detect-zeroes=on,file=debian.cow,id=hd -k es
 </code> </code>
  
Line 38: Line 55:
 ==== Ubuntu + KVM + VNC ==== ==== Ubuntu + KVM + VNC ====
   * El arranque correcto con vnc requiere quitar de la linea boot la opción "splash"   * El arranque correcto con vnc requiere quitar de la linea boot la opción "splash"
 +
 +==== KVM con BIOS uefi ====
 +
 +<code>
 +kvm -bios /usr/share/ovmf/OVMF.fd -m 2G cosa.img
 +</code>
 +
 +==== KVM con BIOS uefi nueva sintaxis ====
 +
 +<code>
 +cp /usr/share/OVMF/OVMF_VARS.fd .
 +kvm  -drive if=pflash,format=raw,readonly=on,file=/usr/share/ovmf/OVMF.fd \
 +     -drive if=pflash,format=raw,file=OVMF_VARS.fd  # requiere copia editable de OVFM_VARS.fd
 +</code>
 ==== Modos de red ==== ==== Modos de red ====
-+ info http://www.linux-kvm.org/page/Networking+  * + info http://www.linux-kvm.org/page/Networking 
 === User Networking === === User Networking ===
 +
 +== Redirección de puertos ==
 +<code>
 +qemu-system-x86_64  -net nic,model=rtl8139 -net user,hostfwd=tcp::3389-:3389,hostfwd=tcp::1992-:1992
 +</code>
 +
 **Cuando usar:**     **Cuando usar:**    
     * Un modo simple para que la máquina virtual tenga acceso al host, a internet y a recursos de la red local     * Un modo simple para que la máquina virtual tenga acceso al host, a internet y a recursos de la red local
Line 106: Line 144:
 kvm  -drive file=debian-8.3.0-amd64-netinst.iso,media=cdrom  -drive file=debian.img,if=virtio,format=raw -m 2048 -net bridge -net nic,model=virtio kvm  -drive file=debian-8.3.0-amd64-netinst.iso,media=cdrom  -drive file=debian.img,if=virtio,format=raw -m 2048 -net bridge -net nic,model=virtio
 </code> </code>
 +
 +
 +
 +
 +
 +
 +
 +
 +<code bash>
 +
 +# The loopback network interface
 +auto lo
 +iface lo inet loopback
 +
 +
 +allow-hotplug enp10s3f0
 +iface enp10s3f0 inet manual
 +
 +auto br0
 +iface br0 inet static
 +   address 155.210.4.98
 +   netmask 255.255.255.240
 +   network 155.210.4.0
 +   broadcast 155.210.4.111
 +   gateway 155.210.4.110
 +   dns-nameservers 155.210.12.9 155.210.3.12
 +   dns-search unizar.es
 +
 +   bridge_ports enp10s3f0
 +   bridge_stp off
 +   bridge_fd 0
 +   bridge_maxwait 0
 +
 +
 +auto br1  
 +iface br1 inet static
 +        address 10.148.97.254  
 +        broadcast 10.148.97.255  
 +        netmask 255.255.255.0
 +        network 10.148.97.0
 +        dns-nameservers 155.210.12.9 155.210.3.12
 +        dns-search unizar.es
 +
 +</code>
 +
 +
 +==== Pasar dispositivo usb a la VM ====
 +
 +<code>
 +
 +sudo kvm -m 4000  -cdrom Descargas/Fedora-Games-Live-x86_64-33-1.2.iso -usb --device usb-host,vendorid=0x258a,productid=0x0027
 +
 +</code>
 +
 +==== Bridges en interfaces con vlan ====
 +
 +<code>
 +
 +# This file describes the network interfaces available on your system
 +# and how to activate them. For more information, see interfaces(5).
 +
 +source /etc/network/interfaces.d/*
 +
 +# The loopback network interface
 +auto lo
 +iface lo inet loopback
 +
 +# The primary network interface
 +vlan-raw-device eno1
 +
 +#auto eno1.516
 +#iface eno1.516 inet static
 +#       address 10.0.4.207
 +#       netmask 255.255.255.0
 +#       gateway 10.0.4.254
 +
 +auto eno1.516
 +iface eno1.516 inet manual
 +
 +auto brblades
 +iface brblades inet static
 +        address 10.0.4.207
 +        netmask 255.255.255.0
 +        gateway 10.0.4.254
 +
 +        bridge_ports eno1.516
 +        bridge_stp off
 +        bridge_fd 0
 +        bridgeç_maxwait 0
 +
 +
 +
 +#auto eno1.1105
 +#iface eno1.1105 inet static
 +#       address 172.16.200.101
 +#       netmask 255.255.255.0
 +
 +auto eno1.1105
 +iface eno1.1105 inet manual
 +
 +auto brceph
 +        iface brceph inet static
 +        address 172.16.200.101
 +        netmask 255.255.255.0
 +
 +        bridge_ports eno1.1105
 +        bridge_stp off
 +        bridge_fd 0
 +        bridge_maxwait 0
 +
 +
 +
 +</code>
 +
 +
 +
 +==== Bridged network sintaxis nueva ====
 +
 +<code>
 +
 +
 +qemu-system-x86_64 -enable-kvm                                                           \
 + -m 4096 frontal.img                                                                      \
 + -device e1000,netdev=net0,mac=DE:AD:BE:EF:00:FA                                         \
 + -netdev tap,id=net0,script=/etc/kvm/kvm-brblades-ifup,downscript=/etc/kvm/kvm-ifdown    \
 + -device e1000,netdev=net1,mac=DE:AD:BE:EF:00:FB                                         \
 + -netdev tap,id=net1,script=/etc/kvm/kvm-brceph-iup,downscript=/etc/kvm/kvm-ifdown       \
 +
 +
 +
 +$ cat /etc/kvm/kvm-brceph-ifup  
 +#!/bin/sh 
 +
 +# Script called by kvm on tap interface creation 
 +
 +KVM_BR=`basename $0 -ifup | sed -e 's/^[^-]*-\?//'
 +KVM_BRIDGE=${KVM_BR:-$KVM_BRIDGE} 
 +echo "$0:" 
 +echo "Adding $1 to bridge interface $KVM_BRIDGE" 
 +brctl addif "$KVM_BRIDGE" "$1" 
 +ip link set "$1" up
 +
 +
 +$ cat /etc/kvm/kvm-ifdown  
 +#!/bin/sh 
 +
 +# Script called by kvm on tap interface deletion 
 +
 +KVM_BR=`basename $0 -ifdown|sed -e 's/^[^-]*-\?//'
 +KVM_BRIDGE=${KVM_BR:-$KVM_BRIDGE} 
 +echo "$0:" 
 +echo "Removing $1 from bridge $KVM_BRIDGE" 
 +ip link set "$1" down 
 +brctl delif "$KVM_BRIDGE" "$1"
 +
 +</code>
 +
 +
 +
 +
chuleta_kvm.1519771805.txt.gz · Last modified: by etfiat