# Notas sobre la creación de VM ## Comando general para lanzar la VM Lo encontré en (este enlace)[https://wiki.debian.org/KVM#Introduction] ## Corregir error de desconexión de monitor Para que no de error de que se desconecta del monitor, hay que modificar el fichero /etc/libvirt/qemu.conf y añadir las siguientes líneas (yo las puse al final del fichero) user = "root" group = "root" # Especificar initrd y kernel | Distro |Kernel path|RAM disk path| |Fedora|/isolinux/vmlinuz|/isolinux/initrd.img| |RHEL5/CentOS5|/isolinux/vmlinuz|/isolinux/initrd.img| |openSUSE|/boot/i386/loader/linux|/boot/i386/loader/initrd| |Mandriva|/i586/isolinux/alt0/vmlinuz|/i586/isolinux/alt0/all.rdz| |Ubuntu|/casper/vmlinuz|/casper/initrd.gz or /casper/initrd| |Debian|/install.386/vmlinuz/|/isolinux/initrd.img| ## Relocate an existing libvirtd (KVM) images directory By default, KVM (libvirtd) images on Ubuntu and most other Linux distributions are found in /var/lib/libvirt/images. This can be inconvenient if you don't have a separate /var partition that can grow over time to accommodate multiple large images. You _can_ simply rename the images folder to something else and then symlink to a larger space with it (e.g. ```ln -s /data1/libvirt/images /var/lib/libvirt/images```). That's what I used to do. But that can lead to all sorts of unanticipated trouble. The _right_ way to have your images on a bigger disk is to change the path for libvirt's default storage pool to a partition on that big disk, which is logically where KVM is going to create them. NOTE: The Ubuntu package for libvirt-daemon-system automatically sets up a [libvirt group](https://documentation.ubuntu.com/server/how-to/virtualisation/libvirt/) for libvirt admins (that includes members of the sudo group by default). Members of libvirt can run virsh commands without sudo. YMMV if not a member of the sudo group, or not on Ubuntu. First check to make sure a default pool exists: ```bash $ virsh pool-list --all Name State Autostart ------------------------------- default active yes ``` **NOTE: If no default pool exists, follow the instructions in [this gist](https://gist.github.com/plembo/13ce29c9279807adfd9bd6b959f43fac) to create one on your preferred storage volume.** Assuming a default pool exists, find the current default pool's path: ```xml $ virsh pool-dumpxml default default 91c6d1b3-4e42-4a1f-989e-89b2127da056 133070688256 25177309184 107893379072 /var/lib/libvirt/images 0711 64055 108 ``` Before going further it is best to shut down ("destroy") all existing virtual machines). Now use ```virsh edit``` to change the disk path in each virtual machines's configuration to the default pool's new location. Assuming this will be "/data1/libvirt/images", you would proceed like this: ```xml $ virsh edit example ... - + ``` (the line will then read ``` 2. Edit the VM's XML: virsh edit This will open the VM's XML file in a text editor. Find the section for the network you want to change. - +
3. Save and close the editor. Apply the changes: virsh start The VM will start with the new network configuration. ## Renombrar máquina virsh dumpxml myvm > foo.xml virsh undefine myvm virsh define foo.xml