{"id":241,"date":"2015-07-06T11:17:53","date_gmt":"2015-07-06T11:17:53","guid":{"rendered":"http:\/\/www.howtolearnlinux.com\/?p=241"},"modified":"2015-07-06T13:34:49","modified_gmt":"2015-07-06T13:34:49","slug":"xen-installation-and-basic-configuration","status":"publish","type":"post","link":"http:\/\/shijuvarghese.com\/?p=241","title":{"rendered":"Xen installation and basic configuration"},"content":{"rendered":"<p>This page lists the procedure to be followed to create a CentOS 5 domU in Xen, without using virt-manager, or and other GUI tool.<\/p>\n<p>The first step is to install Xen on your host. This could be done with the two steps listed below, rebooting the host and selecting the new xen kernel at bootup from grub menu:<\/p>\n<p><b> # yum install kernel-xen<br \/>\n# yum install xen <\/b><\/p>\n<h4><span style=\"color: green;\"> The first step is to create an image. <\/span><\/h4>\n<p>This image will be the portion on your hard disk that will reserve and hold data related to your particular domU. This will be your domU&#8217;s virtual disk.<\/p>\n<p><b># dd if=\/dev\/zero of=\/srv\/xen\/newserver.img oflag=direct bs=1M seek=2047 count=1<\/b><\/p>\n<p>This will create a small image file that can grow. If you want to build the while image \/ reserve the full space of 2048MB now itself, the command to be used is:<\/p>\n<p><b># dd if=\/dev\/zero of=\/srv\/xen\/newserver.img oflag=direct bs=1M count=2048<\/b><\/p>\n<p>Make sure root has read-write permission. The group and others should have only read rights.<\/p>\n<p>Xen uses a form of virtualization known as paravirtualization on most CPUs. Here the guest operating system must be modified to use a special hypercall ABI instead of certain architectural features.<\/p>\n<h4>Kernel and initrd.img<\/h4>\n<p><span style=\"font-family: verdana; font-size: small;\">You can download the kernel and the initrd.img from:<br \/>\nhttp:\/\/mirror.centos.org\/centos\/5\/os\/i386\/images\/xen\/<br \/>\nor<br \/>\nhttp:\/\/mirror.centos.org\/centos\/5\/os\/x86_64\/images\/xen\/<\/span><\/p>\n<p>Put the files in &#8220;\/boot&#8221; folder after renaming them to &#8220;\/boot\/vmlinuz-xen-install&#8221; and &#8220;\/boot\/initrd-xen-install&#8221; respectively.<\/p>\n<p>When we try to boot up a virtual host these will be the files that will be used.<\/p>\n<p>The next step is to create a configuration file this will be the file user to start the domU. It will have information about the files we discussed above.<\/p>\n<p><span style=\"color: green;\"> # cat \/etc\/xen\/newserver.cfg<\/span><\/p>\n<p>kernel = &#8220;\/boot\/vmlinuz-xen-install&#8221;<br \/>\nramdisk = &#8220;\/boot\/initrd-xen-install&#8221;<br \/>\nextra = &#8220;text ks=http:\/\/localhost\/minimal-ks.cfg&#8221;<br \/>\nname = &#8220;newserver&#8221;<br \/>\nmemory = &#8220;256&#8221;<br \/>\ndisk = [ &#8216;tap:aio:\/srv\/xen\/newserver.img,xvda,w&#8217;, ]<br \/>\nvif = [ &#8216;bridge=xenbr0&#8217;, ]<br \/>\nvcpus=1<br \/>\non_reboot = &#8216;destroy&#8217;<br \/>\non_crash = &#8216;destroy&#8217;<\/p>\n<p>This file pulls the <span style=\"color: green;\">minimal-ks.cfg<\/span> from the local web server. To make sure everything is fine, access the url http:\/\/localhost\/minimal-ks.cfg.<\/p>\n<h4>Listed below is a simple kickstart file.<\/h4>\n<p><span style=\"font-family: verdana; font-size: small;\"># cat \/var\/www\/html\/minimal-ks.cfg. <\/span><\/p>\n<p>install<br \/>\nurl &#8211;url http:\/\/mirror.centos.org\/centos\/5\/os\/i386<br \/>\nlang en_US.UTF-8<br \/>\nnetwork &#8211;device eth0 &#8211;bootproto dhcp<\/p>\n<p># Bogus password, change to something sensible!<\/p>\n<p>rootpw bogus<br \/>\nfirewall &#8211;enabled &#8211;port=<br \/>\nauthconfig &#8211;enableshadow &#8211;enablemd5<br \/>\nselinux &#8211;enforcing &#8211;port=22:tcp<br \/>\ntimezone &#8211;utc Europe\/Amsterdam<br \/>\nbootloader &#8211;location=mbr &#8211;driveorder=xvda &#8211;append=&#8221;console=xvc0&#8243;<br \/>\nreboot<\/p>\n<p># Partitioning<\/p>\n<p>clearpart &#8211;all &#8211;initlabel &#8211;drives=xvda<br \/>\npart \/boot &#8211;fstype ext3 &#8211;size=100 &#8211;ondisk=xvda<br \/>\npart pv.2 &#8211;size=0 &#8211;grow &#8211;ondisk=xvda<br \/>\nvolgroup VolGroup00 &#8211;pesize=32768 pv.2<br \/>\nlogvol \/ &#8211;fstype ext3 &#8211;name=LogVol00 &#8211;vgname=VolGroup00 &#8211;size=1024 &#8211;grow<br \/>\nlogvol swap &#8211;fstype swap &#8211;name=LogVol01 &#8211;vgname=VolGroup00 &#8211;size=256 &#8211;grow &#8211;maxsize=512<\/p>\n<p>%packages<\/p>\n<p>@core<\/p>\n<h4>We can start the installation now.<\/h4>\n<p><span style=\"font-family: verdana; font-size: small;\"># cd \/etc\/xen\/<br \/>\n# xm create newserver<br \/>\n# xm console newserver.cfg<\/span><\/p>\n<h4>Post-install configuration<\/h4>\n<p><span style=\"font-family: verdana; font-size: small;\">Now you have a fully functional virtual host with base configuration, and its all stored in the image file &#8220;newserver.img&#8221;. Copy that to an other image file that can be used as a template.<\/span><\/p>\n<p><b># cp \/srv\/xen\/newserver.img \/srv\/xen\/cenos_template.img<\/b><\/p>\n<p>Now as the os is installed the configuration file needs to be changed so that installation will not happen again.<\/p>\n<p>The previous configuration file was to install the OS. Since its already done now we need to change the file to start the host.<\/p>\n<p><b># cat \/etc\/xen\/newserver.cfg<\/b><\/p>\n<p><span style=\"color: green;\"> name = &#8220;nameserver&#8221;<br \/>\nmemory = &#8220;256&#8221;<br \/>\ndisk = [ &#8216;tap:aio:\/srv\/xen\/nameserver.img,xvda,w&#8217;, ]<br \/>\nvif = [ &#8216;bridge=xenbr0&#8217;, ]<br \/>\nbootloader=&#8221;\/usr\/bin\/pygrub&#8221;<br \/>\nvcpus=1<br \/>\non_reboot = &#8216;restart&#8217;<br \/>\non_crash = &#8216;restart&#8217;<br \/>\n<\/span><br \/>\nNow we should be set to start the virtual host.<\/p>\n<p><b> # cd \/etc\/xen\/<br \/>\n# xm create newserver<br \/>\n# xm console newserver.cfg<\/b><br \/>\nWe can verify if the host is up by using the command<\/p>\n<p><b># xm list<\/b><br \/>\nThe command to shutdown the host is:<\/p>\n<p><b># xm shutdown mailserver<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><center>Ref: http:\/\/wiki.centos.org\/HowTos\/Xen\/InstallingCentOSDomU<\/center>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>This page lists the procedure to be followed to create a CentOS 5 domU in Xen, without using virt-manager, or and other GUI tool. The <a class=\"mh-excerpt-more\" href=\"http:\/\/shijuvarghese.com\/?p=241\" title=\"Xen installation and basic configuration\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":253,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,13],"tags":[],"class_list":["post-241","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-virtualization"],"_links":{"self":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=241"}],"version-history":[{"count":2,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/241\/revisions"}],"predecessor-version":[{"id":243,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/241\/revisions\/243"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/media\/253"}],"wp:attachment":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=241"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}