XEN howto - Printable Version +- Linux-Noob Forums (https://www.linux-noob.com/forums) +-- Forum: Distro Noob (https://www.linux-noob.com/forums/forum-10.html) +--- Forum: CentOS (https://www.linux-noob.com/forums/forum-101.html) +--- Thread: XEN howto (/thread-2171.html) |
XEN howto - hijinks - 2006-02-07 Ok so XEN just rules.. I use it at work to test new OS builds and such. I can have a complete development enviroment under my current desktop. So here is a quick little howto on getting XEN up and running on centos 4.0 as the host OS and ttylinux as a guest OS. ttylinux is a very stripped down version of linux.. around 16 megs.. so its good to get it running This will go into explaining how to install the binary version of XEN. If anyone is interested in the source howto I can do that too. If you do the source build.. you can custom build your kernel to meet your needs. Xen is a very active project so the latest xen kernel is 2.6.12.6 So first, i use a basic centos install with all the development libraries. Its no different really then a basic server install but with the development libraries installed. The xen install script will tell you if something is missing later on. I needed to use apt-get to install 1 package first Code: apt-get install bridge-utils So lets download and extract the xen binary version Code: wget http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/xen-3.0.1-install-x86_32.tgz Now lets run the install script. This basically just copies over the binaries in install/ dir into / Code: sh ./install.sh You should see something like this at the end Code: Checking to see whether prerequisite tools are installed... If one of those errors out you'll need to install that package to make it work. Just keep re-running the install.sh script Now for centos and I'm sure other distro's You have to create a ram image to preload the console info into ram before loading the kernel. If this isn't here I got errors about not being able to load the console Code: mkinitrd /boot/initrd-2.6.12.6-xen0.img 2.6.12.6-xen0 Now you want to edit your grub.conf.. in centos/fedora there is a symlink at /etc/grub.conf that points to the location of the grub config in /boot. So you want to add this line before the others Code: title XEN (2.6.12-zen) Below is my grub.conf file Code: default=0 You can put the XEN one at the bottom.. you just want to change the default= line to default boot your XEN kernel. 0 is the first listing and 1 would be the 2nd and so on. Now for fedora there is this thing called tls.. I am not gonna go into why we don't want that in XEN but just disable it. If this directory is present on your system Code: mv /lib/tls /lib/tls.disabled now reboot and you should be booted up with your new XEN kernel. you can verifiy by running the uname -a command like below Code: [root@unused xen-3.0.1-install]# uname -a Ok great now xen is running. So lets start the xen service and make sure it will run on bootup Code: service xend start Now we want to make our first guest system. Like i said above I will be using ttylinux which already provides a xen image.. so lets so that to test it out. So lets grab the image. I like to put the images in /opt/xen dir. So this part will think you are using that dir.. feel free to change it since some of these images you can make them as big as you want to meet the space needs of your guest system Code: mkdir /opt/xen Now we need to make the config file to load it all up So this create a new file in /etc/xen/ttylinux and put the contents in like this Code: kernel = "/boot/vmlinuz-2.6-xenU" don't change the kernel = line you can change the memory line to meet your needs.. just don't go over the memory allocated on your host the name= line can be changed if you want to use mulitple guests of the same image don't touch the vif= line you'll eant to change the ip = line to meet your needs the disk = line will change if you put the image in anywhere other then /opt/xen Now leave sda1 alone.. my host machine is not using scsi drives.. its just emulation some scsi devices on the guest OS so this is OK. and leave root = the same So now lets start it up and see if it works Code: xm create -c /etc/xen/ttyLinux You should see a boot cycle and it will go pretty quickly. You should be brought to a command prompt now where you can login with the root/root password Now you can login.. now for me I have to fill out nameserver info and also add the default route. For me it was like this.. feel free to use this dns server if you don't know yours off hand Code: echo "nameserver 66.193.31.10" > /etc/resolv.conf Later I will explain how to add that into the ttylinux image. Now with your nameserver info and default route added you can now ping hosts Code: root@tiny ~ # ping google.com Now you can detatch by using the following key combo ctrl+] now you could view the following to connect to the tiny HTTP server running on your guest [/url][url=http://192.168.1.3]http://192.168.1.3 That should show you Code: Congratulations! Now if you want to connect back into the running guest OS you would run the following command Code: xm console ttylinux Hit enter a few times and the prompt should show right back up.. You can get a running list of your domains by running Code: xm list You can destroy a dom by Code: xm destroy ttylinux I will get into how to do more advanced builds later.. this is just a stater.. hope you like it.. be sure to join us on #linux-noob on efnet and tell Jy how much he rules XEN howto - hijinks - 2006-02-07 So if you want to edit the image to add in the default gateway and nameserver info you do this Code: mkdir /mnt/image Now edit resolv.conf and add the following.. You can change the IPs to meet your needs or use these Code: nameserver 38.8.82.2 Now edit the file network.conf There is this line #GATEWAY="1.2.3.4" remove the # in front and change the ip with your gateways IP info Then look for NETWORKING="no" change the no to a yes now lets umount it and if you destroy your dom and create it again.. the nameserver and default gateway should be all setup Code: cd ~/ XEN howto - anyweb - 2006-02-07 nice post Jy ! will this work in Fedora by any chance ? cheers anyweb XEN howto - hijinks - 2006-02-08 yep it will work good in fedora.. but I believe core4 has xen kernel rpms XEN howto - dubkat - 2006-02-08 great how to, i tried to install from source myself because i have a 64bit arch. i havnt tried it out yet though. before i continue though, can you use Windows XP as a guest OS, and if so, could you do a how-to on that for those of us who only want windows for those few essential programs that can only work (smoothly) on windows? thanks. XEN howto - hijinks - 2006-02-09 no you can't use windows as a guest OS.. from what I know about windows and the gpl you can put gpl code into the windows kernel.. right now there are only some linux images here is the 64bit version [/url]http://www.cl.cam.ac.uk/Research/SRG/netos...tall-x86_64.tgz Here is a quick little howto on how to get a slackware image running. Jailtime.org has a few user contributed images you can run So lets grab the slackware image You can grab it at [url=http://jailtime.org/download:slackware:v10.2]http://jailtime.org/download:slackware:v10.2 That also tells you everything about what is installed and special instructions about the image. The first thing you notice is the image is only around 100megs. That is compressed.. now when you extract it the image file will actually be 1gig. This is due to having all the empty space being 0's so the compression can easily handle that and really shrink it down good So now lets put the image in /opt/xen like up before Code: tar zcfv slackware.10-2.20050917.img.tgz That has these files in them Code: slackware.10-2.img slackware.10-2.xen.cfg slackware.swap The image file is the 1gig image file. the .swap file is what is used for the guest OS's swap partition and the .cfg file should go into /etc/xen Code: mv slackware.10-2.xen.cfg /etc/xen now lets edit the /etc/xen/slackware.10-2.xen.cfg to meet our needs. Mine looks like this Code: kernel = "/boot/vmlinuz-2.6-xenU" Now as you notice I pass in the ip/netmask and gateway into the guest. You can remove them and just do ip = dchp and it will grab a IP from your dhcp server if you have one running Now lets run it Code: xm create -c /etc/xen/slackware.10-2.xen.cfg Now you should be brought to a prompt.. yay slackware guest OS up and running XEN howto - attojung - 2006-11-25 That's very nice tutorial. I am going to setup my testbed by using xen as well. But I still have some questions about this 1. How can I find image of Fedora or any other linux distributions ? 2. incase I have to create 10 guests, do i need to have 10 image files? is it possible to use just 1 image for 10 guests? if yes, how about the configuration in each guest system? 3. How to assign IP address to other interfaces of guest? Let's say, in the configuration file i use "nic=3" , but in the "IP" filed it's for eth0. How about eth1 and eth2. 4. Is it possible to connect each guest together? For example, i create 3 guests and use guest1 as a router to connect guest2 and guest3 together and create routing policy and so on. That's all it make me confuse right now... ^___^ Thx XEN howto - bigstone - 2007-04-26 Very nice post. I followed it and tried to create domain 1 to run ttylinux, but failed. See the attached file for the output. I am running it on Inspiron 4100 laptop, total memory=128M. Domain1 wasn't able to successfully start up. My question is: is my ttylinux correct? Why ttylinux wasn't able to start up? Thank you! xen_ttylinux.txt XEN howto - c4rdinal - 2007-08-15 Hi! Thanks for the nice article. However, I had a problem on the portion of xm create area. I downloaded a Fedora image at [/url][url=http://www.jailtime.org/]http://www.jailtime.org/ and mount it using your article. However, at the final stage I encountered this error, as follows: [root@vmsrv xen-images]# xm create fedora.fc6.xen3.cfg Using config file "./fedora.fc6.xen3.cfg". Error: Device 2049 (vbd) could not be connected. File /home/xen-images/fedora.fc6.img is loopback-mounted through /dev/loop0, which is mounted in the privileged domain, and so cannot be mounted by a guest. I placed the image: /home/xen-images/fedora.fc6.img And my config: kernel = "/boot/vmlinuz-2.6.20-2925.13.fc7xen" memory = 512 name = "fedora.fc6" vif = [ '' ] dhcp = "dhcp" disk = ['file:/home/xen-images/fedora.fc6.img,sda1,w', 'file:/home/xen-images/fedora.swap,sda2,w'] root = "/dev/sda1 ro" How can I resolve the problem? Please help me. I'm stuck for almost 2 weeks already. Can't seem to find definite solutions everywhere. Thank you so much. |