{"id":1854,"date":"2014-07-16T14:01:59","date_gmt":"2014-07-16T12:01:59","guid":{"rendered":"http:\/\/possiblelossofprecision.net\/?p=1854"},"modified":"2021-05-15T11:46:37","modified_gmt":"2021-05-15T09:46:37","slug":"installing-kvm-on-fedora-20","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=1854","title":{"rendered":"Installing kvm on Fedora 20"},"content":{"rendered":"<p>Installing <a href=\"http:\/\/www.linux-kvm.org\">kvm<\/a> on a recent Fedora OS is quite easy. Fedora already ships all the necessary software packages and kernel modules for running a kernel virtualised machine.<\/p>\n<h2>0. Prerequisites<\/h2>\n<p>Since late 2005 \/ early 2006 almost every x86 processor is capable of hardware virtualization. To <strong>check<\/strong> if your CPU supports <a href=\"http:\/\/en.wikipedia.org\/wiki\/VT-d#Intel_virtualization_.28VT-x.29\">Intel&#8217;s VT-d<\/a> or <a href=\"http:\/\/en.wikipedia.org\/wiki\/VT-d#AMD_virtualization_.28AMD-V.29\">AMD&#8217;s Pacifica<\/a>, which is a requirement for <a href=\"http:\/\/www.linux-kvm.org\/page\/FAQ#What_is_Intel_VT_.2F_AMD-V_.2F_hvm.3F\">hardware virtualization with kvm<\/a>, run:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# egrep '(vmx|svm)' --color=always \/proc\/cpuinfo\r\n<\/pre>\n<p>To <strong>install<\/strong> the necessary software packages, run:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# yum -y install qemu-kvm libvirt virt-install bridge-utils \r\n<\/pre>\n<h2>1. Bridge configuration<\/h2>\n<p>There are a couple of ways to give your virtual machines access to your network. For a reference, have a look at the <a href=\"http:\/\/www.linux-kvm.org\/page\/Networking\">Networking page<\/a> of the <a href=\"http:\/\/www.linux-kvm.org\/page\/Documents\">kvm documentation<\/a>. The easiest way is to add the <strong>virtual NICs<\/strong> of your virtual machines as well as the <strong>physical NIC<\/strong> on your server to a common <strong>bridge<\/strong>. <\/p>\n<p>Let&#8217;s assume, you have the following ethernet configuration file for your first ethernet device<\/p>\n<pre class=\"brush: plain; title: \/etc\/sysconfig\/network-scripts\/ifcfg-eth0; notranslate\" title=\"\/etc\/sysconfig\/network-scripts\/ifcfg-eth0\">\r\n# Generated by parse-kickstart\r\nUUID=a9e7f9b1-245a-42d6-84b3-865120c16dd6\r\nDNS1=192.168.1.1\r\nBOOTPROTO=none\r\nDEVICE=eth0\r\nONBOOT=yes\r\nIPV6INIT=yes\r\nHWADDR=00:8C:00:AA:8C:B8\r\nTYPE=Ethernet\r\nIPADDR0=192.168.1.254\r\nPREFIX0=24\r\nGATEWAY0=192.168.1.1\r\nDEFROUTE=yes\r\nIPV4_FAILURE_FATAL=no\r\nIPV6_AUTOCONF=yes\r\nIPV6_DEFROUTE=yes\r\nIPV6_PEERDNS=yes\r\nIPV6_PEERROUTES=yes\r\nIPV6_FAILURE_FATAL=no\r\nNAME=&quot;System eth0&quot;\r\n<\/pre>\n<p>Let&#8217;s create a new <strong>bridge<\/strong> device (<code>br0<\/code>) and add our ethernet device (<code>eth0<\/code>) to that bridge. First, create a new file called <code>\/etc\/sysconfig\/network-scripts\/ifcfg-br0<\/code> with the following content:<\/p>\n<pre class=\"brush: plain; title: \/etc\/sysconfig\/network-scripts\/ifcfg-br0; notranslate\" title=\"\/etc\/sysconfig\/network-scripts\/ifcfg-br0\">\r\nDNS1=192.168.1.1\r\nBOOTPROTO=none\r\nDEVICE=br0\r\nONBOOT=yes\r\nIPV6INIT=no\r\nTYPE=Bridge\r\nIPADDR0=192.168.1.254\r\nPREFIX0=24\r\nGATEWAY=192.168.1.1\r\nDEFROUTE=yes\r\nIPV4_FAILURE_FATAL=yes\r\nNM_CONTROLLED=no\r\n<\/pre>\n<p>Second, we&#8217;ll need to alter the configuration file for the <strong>ethernet<\/strong> device to add the device to the bridge<\/p>\n<pre class=\"brush: plain; title: \/etc\/sysconfig\/network-scripts\/ifcfg-eth0; notranslate\" title=\"\/etc\/sysconfig\/network-scripts\/ifcfg-eth0\">\r\nDEVICE=eth0\r\nONBOOT=yes\r\nHWADDR=00:8C:00:AA:8C:B8\r\nBRIDGE=br0\r\nTYPE=Ethernet\r\nNM_CONTROLLED=no\r\n<\/pre>\n<p>To retrieve the <strong>MAC address<\/strong> of your ethernet device (<code>eth0<\/code>) you can use <code>ip link show<\/code>:<\/p>\n<pre class=\"brush: bash; highlight: [4,5]; title: ; notranslate\" title=\"\">\r\n# ip link show \r\n1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default \r\n    link\/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\r\n2: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000\r\n    link\/ether 00:8c:00:aa:8c:B8 brd ff:ff:ff:ff:ff:ff\r\n<\/pre>\n<p>Finally, disable the <code>NetworkManager<\/code> service, enable the <code>network<\/code> service and <strong>reboot<\/strong> the machine.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# systemctl disable NetworkManager.service\r\n# systemctl enable network.service\r\n# reboot\r\n<\/pre>\n<h2>2. Enable libvirt-daemon<\/h2>\n<p>The Fedora packages already have a proper systemd init script, which makes enabling and starting the libvirt-daemon rather easy:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# systemctl enable libvirtd.service \r\nln -s '\/usr\/lib\/systemd\/system\/libvirtd.service' '\/etc\/systemd\/system\/multi-user.target.wants\/libvirtd.service'\r\n# systemctl start libvirtd.service\r\n<\/pre>\n<p>You can now go ahead and connect to the <code>libvirt-daemon<\/code> with a GUI, like <a href=\"http:\/\/virt-manager.org\/\">virt-manager<\/a> or install a virtual machine with <a href=\"https:\/\/access.redhat.com\/site\/documentation\/en-US\/Red_Hat_Enterprise_Linux\/6\/html\/Virtualization_Host_Configuration_and_Guest_Installation_Guide\/sect-Virtualization_Host_Configuration_and_Guest_Installation_Guide-Guest_Installation-Creating_guests_with_virt_install.html\">virt-install<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing kvm on a recent Fedora OS is quite easy. Fedora already ships all the necessary software packages and kernel modules for running a kernel virtualised machine. 0. Prerequisites Since late 2005 \/ early 2006 almost every x86 processor is capable of hardware virtualization. To check if your CPU supports Intel&#8217;s VT-d or AMD&#8217;s Pacifica, which is a requirement for&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=1854\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,38],"class_list":["post-1854","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-fedora","tag-kvm"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1854"}],"version-history":[{"count":9,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1854\/revisions"}],"predecessor-version":[{"id":2186,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1854\/revisions\/2186"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}