kvm

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
kvm [2019/02/09 09:53] – [Harddisks] adminkvm [2021/02/14 09:36] (current) – [Edit networks] dani
Line 95: Line 95:
 virsh --connect qemu:///system console centos7 virsh --connect qemu:///system console centos7
 </code> </code>
-  * Start a console session for a VM:<code bash>+  * Setup autostart (when booting the KVM server) for a VM:<code bash>
 virsh --connect qemu:///system autostart centos7 virsh --connect qemu:///system autostart centos7
 </code> </code>
 +
 +| **Note:**  | To remove autostart toggle, just run this command again!  |
  
 ===== Installation of VM’s ===== ===== Installation of VM’s =====
Line 151: Line 153:
   * Attach a network interface to a virtual machine (domain):<code bash>   * Attach a network interface to a virtual machine (domain):<code bash>
 virsh attach-interface --domain <vm name> --type bridge --source virbr0 --model virtio --config --live virsh attach-interface --domain <vm name> --type bridge --source virbr0 --model virtio --config --live
-</code> +</code><code bash>
- +
- +
- +
-<code bash>+
 virsh attach-interface --domain <vm name> --type direct --source enp0s31f6 --model virtio --config --live virsh attach-interface --domain <vm name> --type direct --source enp0s31f6 --model virtio --config --live
 </code> </code>
 +
 | **Note:**  | The ''%%--live%%'' switch only works, if the VM is started!  | | **Note:**  | The ''%%--live%%'' switch only works, if the VM is started!  |
 +
   * Unordered List ItemIf you want to figure out the IP addresss of one or more VM’s, you can use the following command executed on the KVM host:<code bash>   * Unordered List ItemIf you want to figure out the IP addresss of one or more VM’s, you can use the following command executed on the KVM host:<code bash>
 vm=fedora27 vm=fedora27
Line 184: Line 184:
   <bridge name='virbr0' stp='on' delay='0'/>   <bridge name='virbr0' stp='on' delay='0'/>
   <mac address='52:54:00:65:80:59'/>   <mac address='52:54:00:65:80:59'/>
-  <ip address='192.168.122.1' netmask='255.255.255.0'> (1)+  <ip address='192.168.xxx.1' netmask='255.255.255.0'> (1)
     <dhcp>     <dhcp>
-      <range start='192.168.122.40' end='192.168.122.254'/> +      <range start='192.168.122.40' end='192.168.xxx.254'/> 
-      <host mac='52:54:00:f3:30:0f' ip='192.168.122.10'/> (2) +      <host mac='52:54:00:f3:30:0f' ip='192.168.xxx.xx'/> (2) 
-      <host mac='52:54:00:f3:30:1f' ip='192.168.122.11'/> +      <host mac='52:54:00:f3:30:1f' ip='192.168.xxx.xx'/> 
-      <host mac='52:54:00:f3:30:2f' ip='192.168.122.12'/> +      <host mac='52:54:00:f3:30:2f' ip='192.168.xxx.xx'/>
-      <host mac='52:54:00:f3:30:3f' ip='192.168.122.13'/> +
-      <host mac='52:54:00:f3:30:4f' ip='192.168.122.14'/> +
-      <host mac='52:54:00:f3:30:5f' ip='192.168.122.15'/> +
-      <host mac='52:54:00:f3:30:6f' ip='192.168.122.16'/> +
-      <host mac='52:54:00:43:56:0e' ip='192.168.122.17'/> +
-      <host mac='52:54:00:43:56:1e' ip='192.168.122.18'/> +
-      <host mac='52:54:00:43:56:2e' ip='192.168.122.19'/> +
-      <host mac='52:54:00:43:56:3e' ip='192.168.122.20'/> +
-      <host mac='52:54:00:43:56:4e' ip='192.168.122.21'/> +
-      <host mac='52:54:00:43:56:5e' ip='192.168.122.22'/> +
-      <host mac='52:54:00:43:56:6e' ip='192.168.122.23'/> +
-      <host mac='52:54:00:43:56:7e' ip='192.168.122.24'/>+
     </dhcp>     </dhcp>
   </ip>   </ip>
Line 214: Line 202:
 </code> </code>
   * Delete a vm (host) in a network (here ''default'' net):<code bash>   * Delete a vm (host) in a network (here ''default'' net):<code bash>
-virsh net-update default delete ip-dhcp-host "<host mac='52:54:00:f3:30:2f' name='ds' ip='192.168.122.12'/>" --live --config+virsh net-update default delete ip-dhcp-host "<host mac='52:54:00:f3:30:2f' name='hostname' ip='192.168.xxx.xxx'/>" --live --config 
 +</code> 
 +  * Add a network configuration (host) live:<code bash> 
 +virsh net-update default add ip-dhcp-host "<host mac='52:54:00:43:56:84' name='hostname' ip='192.168.xxx.xxx'/>" --live --config
 </code> </code>
  
Line 224: Line 215:
 virsh attach-disk ds --source /dev/sysvg/ds_test --target vdb --persistent virsh attach-disk ds --source /dev/sysvg/ds_test --target vdb --persistent
 </code> \\ This adds a new disk to the ''%%ds%%'' VM as ''%%/dev/vdb%%'' persistently. </code> \\ This adds a new disk to the ''%%ds%%'' VM as ''%%/dev/vdb%%'' persistently.
 +
 | **Note:**  | The disk is a logical volume on the KVM host  | | **Note:**  | The disk is a logical volume on the KVM host  |
 +
 +==== Resize (LVM) disk ====
 +
 +  * First increase size of the LV on KVM host:<code bash>
 +lvresize -G <size>G /dev/sysvg/<lv name>
 +</code>
 +  * Configure the size of that domain and disk using ''virsh'':<code bash>
 +virsh blockresize <domain> /dev/sysvg/<lv name> --size <size>G
 +</code> \\ Now, you can resize the disk on the domain (VM).
 +
  
  • kvm.1549702438.txt.gz
  • Last modified: 2019/02/09 09:53
  • by admin