{"id":5803,"date":"2019-12-10T23:25:55","date_gmt":"2019-12-11T04:25:55","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5803"},"modified":"2019-12-11T23:26:11","modified_gmt":"2019-12-12T04:26:11","slug":"migrating-from-hyper-v-to-libvirt","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5803","title":{"rendered":"Migrating from Hyper-V to libvirt"},"content":{"rendered":"<p>We finally got a new server, and I&#8217;m starting to migrate our servers to the new box. We currently have a Windows virtualization platform (Hyper-V) &#8212; Windows Data Center edition was supposed to provide unlimited licenses for standard servers running on the host, so it seemed like a great deal. Except &#8220;all of the Windows servers&#8221; turned out to be, well, one. So we decided to use Fedora on the host. Worst case, that would mean re-installing a few servers. But I wanted to try converting the existing Hyper-V VMs.<\/p>\n<p><em>Install libvirt and associated packages:<\/em><\/p>\n<p>dnf -y install bridge-utils libvirt virt-install qemu-kvm virt-top libguestfs-tools qemu-img virt-manager<\/p>\n<p><em>Start libvirtd and set it to auto-start on boot:<\/em><\/p>\n<p>systemctl start libvirtd<br \/>\nsystemctl enable libvirtd<\/p>\n<p><em>Create an XML file with the definition for a new bridge:<\/em><\/p>\n<p>[root@localhost ~]# cat br5.xml<\/p>\n<p>&lt;network&gt;<br \/>\n&lt;name&gt;br5&lt;\/name&gt;<br \/>\n&lt;forward mode=&#8217;nat&#8217;&gt;<br \/>\n&lt;nat&gt;<br \/>\n&lt;port start=&#8217;1024&#8242; end=&#8217;65535&#8217;\/&gt;<br \/>\n&lt;\/nat&gt;<br \/>\n&lt;\/forward&gt;<br \/>\n&lt;bridge name=&#8217;br5&#8242; stp=&#8217;on&#8217; delay=&#8217;0&#8217;\/&gt;<br \/>\n&lt;ip address=&#8217;10.1.2.1&#8242; netmask=&#8217;255.255.255.0&#8242;&gt;<br \/>\n&lt;dhcp&gt;<br \/>\n&lt;range start=&#8217;10.1.2.200&#8242; end=&#8217;10.1.2.250&#8217;\/&gt;<br \/>\n&lt;\/dhcp&gt;<br \/>\n&lt;\/ip&gt;<br \/>\n&lt;\/network&gt;<\/p>\n<p><em>Build a new bridge from this definition and set it to auto-start on boot:<\/em><\/p>\n<p>[root@localhost ~]# virsh net-define br5.xml<br \/>\nNetwork br10 defined from br5.xml<\/p>\n<p>[root@localhost ~]# virsh net-autostart br5<br \/>\nNetwork br5 marked as autostarted<\/p>\n<p><em>Verify the network is running and set to auto-start<\/em><\/p>\n<p>[root@localhost ~]# virsh net-list &#8211;all<br \/>\nName State Autostart Persistent<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nbr5 active yes yes<\/p>\n<p><em>View the IP address associated with the bridge:<\/em><\/p>\n<p>[root@localhost ~]# ip addr show dev br5<br \/>\n5: br5: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc noqueue state DOWN group default qlen 1000<br \/>\nlink\/ether 52:54:00:33:3f:0c brd ff:ff:ff:ff:ff:ff<br \/>\ninet 10.1.2.1\/24 brd 10.1.2.255 scope global br10<br \/>\nvalid_lft forever preferred_lft forever<\/p>\n<p><em>Copy the VHDX from Hyper-V to the Linux host and convert it to a qcow2 image:<\/em><\/p>\n<p>qemu-img convert -O qcow2 fedora02.vhdx fedora02.qcow2<\/p>\n<p><em>If needed, sysprep to clean up system SSH host keys, persistent network MAC configuration, and removing user accounts. <\/em><br \/>\nvirt-sysprep -a fedora02.qcow2<\/p>\n<p>When finished, use virt-manager to create a host by importing an existing HDD. Provided the drive type remains the same (SATA, in my case), the server boots right up.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We finally got a new server, and I&#8217;m starting to migrate our servers to the new box. We currently have a Windows virtualization platform (Hyper-V) &#8212; Windows Data Center edition was supposed to provide unlimited licenses for standard servers running on the host, so it seemed like a great deal. Except &#8220;all of the Windows &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[861,859,860],"class_list":["post-5803","post","type-post","status-publish","format-standard","hentry","category-system-administration","tag-kvm","tag-libvert","tag-qemu"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5803"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5803\/revisions"}],"predecessor-version":[{"id":5804,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5803\/revisions\/5804"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}