Difference between revisions of "KVM"
Michael.mast (talk | contribs) |
Michael.mast (talk | contribs) |
||
Line 54: | Line 54: | ||
</pre> | </pre> | ||
− | == | + | ==Networking== |
− | === | + | ===Remove Default Network== |
To remove the default network from the host. This can conflict with other services running if this is a shared environment. In my case I run a DNS server off the host, and the default network uses DNS forwarding with dnsmasq. When dnsmasq is running it takes port 53 which prevents my DNS service from running. | To remove the default network from the host. This can conflict with other services running if this is a shared environment. In my case I run a DNS server off the host, and the default network uses DNS forwarding with dnsmasq. When dnsmasq is running it takes port 53 which prevents my DNS service from running. | ||
− | + | ||
<ref>https://libvirt.org/sources/virshcmdref/html/sect-net-destroy.html</ref><pre> | <ref>https://libvirt.org/sources/virshcmdref/html/sect-net-destroy.html</ref><pre> | ||
[root@nas ~]# virsh | [root@nas ~]# virsh | ||
Line 73: | Line 73: | ||
virsh # exit | virsh # exit | ||
+ | </pre> | ||
+ | ===Setup Bridged Network=== | ||
+ | I already had a bridge created for LXC containers, it only made sense to use it for KVM guests as well. | ||
+ | *Create the XML file<ref>https://libvirt.org/formatnetwork.html#examplesBridge</ref>. My existing bridge name is virb0. | ||
+ | <pre> | ||
+ | <network> | ||
+ | <name>bridge1</name> | ||
+ | <bridge name="virbr0" /> | ||
+ | <forward mode="bridge" /> | ||
+ | </network> | ||
+ | </pre> | ||
+ | *Create the network using virsh | ||
+ | <pre> | ||
+ | virsh # net-list | ||
+ | Name State Autostart Persistent | ||
+ | ---------------------------------------------------------- | ||
+ | |||
+ | vvirsh # net-define --file br.xml | ||
+ | Network bridge1 defined from br.xml | ||
+ | |||
+ | virsh # net-list | ||
+ | Name State Autostart Persistent | ||
+ | ---------------------------------------------------------- | ||
+ | |||
+ | virsh # net-start --network bridge1 | ||
+ | Network bridge1 started | ||
+ | |||
+ | virsh # net-list | ||
+ | Name State Autostart Persistent | ||
+ | ---------------------------------------------------------- | ||
+ | bridge1 active no yes | ||
+ | |||
+ | </pre> | ||
+ | *Set to auto start | ||
+ | <pre> | ||
+ | virsh # net-autostart --network bridge1 | ||
+ | Network bridge1 marked as autostarted | ||
</pre> | </pre> |
Revision as of 10:59, 29 September 2018
Contents
Fedora 28
I had removed zfs-fuse, which also removed a number of kvm modules that I needed. To re-install I was able to follow the following link [1]
sudo dnf install libvirt-daemon sudo systemctl enable libvirtd sudo systemctl start libvirtd sudo dnf install qemu-kvm qemu-img libvirt-python python-virtinst libvirt-client virt-install virt-viewer device-mapper-libs libvirt-daemon-driver-qemu libvirt-daemon-config-network libvirt-daemon-kvm
Create Storage Domain
I have a ZFS pool already established, with several volumes in use. I will be creating a new volume dedicated to this purpose and will set it as one of two pools. The other being the ISO directory where I keep ISOs.
virsh # pool-list Name State Autostart ------------------------------------------- default active yes michael active yes qemu active yes virsh # pool-autostart --pool default --disable Pool default unmarked as autostarted virsh # pool-autostart --pool michael --disable Pool michael unmarked as autostarted virsh # pool-autostart --pool qemu --disable Pool qemu unmarked as autostarted virsh # pool-list Name State Autostart ------------------------------------------- default active no localstorage active no michael active no qemu active no
Now I can create the new pool. I am going to use the most basic config options.
virsh # pool-create-as localstorage --type dir --target /raid5/libvirt Pool localstorage created virsh # pool-autostart --pool localstorage Pool localstorage marked as autostarted virsh # pool-list Name State Autostart ------------------------------------------- default active no localstorage active yes michael active no qemu active no virsh #
Networking
=Remove Default Network
To remove the default network from the host. This can conflict with other services running if this is a shared environment. In my case I run a DNS server off the host, and the default network uses DNS forwarding with dnsmasq. When dnsmasq is running it takes port 53 which prevents my DNS service from running.
[root@nas ~]# virsh Welcome to virsh, the virtualization interactive terminal. Type: 'help' for help with commands 'quit' to quit virsh # net-destroy default Network default destroyed virsh # net-list Name State Autostart Persistent ---------------------------------------------------------- virsh # exit
Setup Bridged Network
I already had a bridge created for LXC containers, it only made sense to use it for KVM guests as well.
- Create the XML file[3]. My existing bridge name is virb0.
<network> <name>bridge1</name> <bridge name="virbr0" /> <forward mode="bridge" /> </network>
- Create the network using virsh
virsh # net-list Name State Autostart Persistent ---------------------------------------------------------- vvirsh # net-define --file br.xml Network bridge1 defined from br.xml virsh # net-list Name State Autostart Persistent ---------------------------------------------------------- virsh # net-start --network bridge1 Network bridge1 started virsh # net-list Name State Autostart Persistent ---------------------------------------------------------- bridge1 active no yes
- Set to auto start
virsh # net-autostart --network bridge1 Network bridge1 marked as autostarted