Difference between revisions of "Xen-test-debian"

From VNUML-WIKI
Jump to: navigation, search
m (Uselful references)
Line 3: Line 3:
 
== Installing Xen basic packages in Debian ==
 
== Installing Xen basic packages in Debian ==
  
Udpate the APT repository
+
First of all, update the APT repository
  
 
   apt-get update
 
   apt-get update
  
Install the Xen hypervisor. Note that the version may have changed: search for the current one using 'apt-get search xen-hypervisor'. Default hypervisor supports up to 4GB of physical RAM, the -pae version up to 64GB of physical RAM (we are considering the former here).
+
==== Xen Hypervisor ====
 +
 
 +
Install the Xen hypervisor. Note that the version may have changed: search for the current one using 'apt-get search xen-hypervisor'.
  
 
   apt-get install xen-hypervisor-3.0.3-1-i386
 
   apt-get install xen-hypervisor-3.0.3-1-i386
  
Install the Xen kernel:
+
In the case you get "CPU0 panic" errors when booting this hypervisor, try with the PAE version instead:
 +
 
 +
  apt-get install xen-hypervisor-3.0.3-1-i386-pae
 +
 
 +
==== Install the Xen kerne l====
  
 
   apt-get install linux-image-xen-686
 
   apt-get install linux-image-xen-686
  
Install Xen tools:
+
==== Install Xen tools ====
  
 
   apt-get install xen-tools
 
   apt-get install xen-tools
  
Install the libc6-xen (I'm not sure what it's for or even if this installation could be omitted):
+
==== Install the libc6-xen ====
 +
 
 +
I'm not sure what it's for or even if this installation could be omitted :)
  
 
   apt-get install libc6-xen
 
   apt-get install libc6-xen
  
All packages in the same command:
+
== Tunning Xen ==
 +
 
 +
==== Grub boot configuration ====
 +
 
 +
Kernel boot configuration should be upgraded when installing linux-image-xen-686 package. However, this automatic upgrade doesn't seem to work properly, so manual editing of /boot/grub/menu.lst is required.
 +
 
 +
Considering the linux-image-xen-686 installed /boot/vmlinuz-2.6.18-4-xen-686 (exact version may change, so check it), you should configure the following booting option in your /boot/grub/menu.lst file:
 +
 
 +
  title          Debian GNU/Linux, kernel 2.6.18-4-xen-686
 +
  root            (hd0,0)
 +
  kernel          /xen-3.0.3-1-i386-pae.gz
 +
  module          /vmlinuz-2.6.18-4-xen-686 root=/dev/sda2 ro
 +
  module          /initrd.img-2.6.18-4-xen-686
 +
  savedefault
 +
  boot
 +
 
 +
==== Configure networking ====
 +
 
 +
I needed to edit /etc/xen/xend-config.sxp and configure the network-script option, in order virtual machines get direclty bridged to the external interface (eth1 in my case, change it appropiately):
  
  apt-get install xen-hypervisor-3.0.3-1-i386 linux-image-xen-686 xen-tools libc6-xen
+
  (network-script 'network-bridge netdev=1')
  
== Create the first virtual machine ==
+
==== Configure loop ====
  
Create a working directory (e.g., /root/xen.test)
+
If you want to run many virtual machines simulteneously (more than 8) you have to use max_loop option for loop module (http://lists.xensource.com/archives/html/xen-users/2006-06/msg01150.html). For example:
  
  mkdir /root/xen-test
+
    rmmod loop
 +
    modprobe loop max_loop=64
  
Edit the /etc/xen-tools/xen-tools.conf file. The gateway= value used here could be not appropiated for you.
+
(It would be prefereable to put it in the right place so 'modprobe loop' works; but I don't know/remember which configuration file tune :)
  
  dir    = /root/xen-test
+
== Creating a virtual machine ==
  size  = 1Gb
 
  memory = 32Mb
 
  swap  = 128Mb
 
  fs    = ext3
 
  dist  = sarge
 
  image  = sparse
 
  gateway = 192.168.247.2
 
  netmask = 255.255.255.0
 
  passwd  = 1
 
  kernel  = /boot/vmlinuz-2.6.18-3-xen-686
 
  initrd  = /boot/initrd.img-2.6.18-3-xen-686
 
  mirror  = <nowiki>http://ftp.us.debian.org/debian/</nowiki>
 
  
Create the first virtual machine (it will take a LONG time). Use a proper IP for you.
+
Use the following configuration file (let's say test.cfg):
  
  xen-create-image --hostname=test --ip=192.168.247.140 --passwd --debootstrap
+
  kernel  = '/boot/vmlinuz-2.6.18-4-xen-686'
 +
  ramdisk = '/boot/initrd.img-2.6.18-4-xen-686'
 +
  memory  = '50'
 +
  root    = '/dev/sda1 ro'
 +
  disk    = [ "file:/usr/share/vnuml/filesystems/xen_fs,sda1,w" ]
 +
  name    = 'occ0-v'
 +
  vif    = [ '' ]
 +
  on_poweroff = 'destroy'
 +
  on_reboot  = 'restart'
 +
  on_crash    = 'restart'
  
This creates the necesary files under /root/xen-test. However, the key file descring the virtual machine is /etc/xen/test.cfg. What xen-create-image has put in test.cfg is the following:
+
Comments:
  
  kernel  = '/boot/vmlinuz-2.6.18-3-xen-686'
+
<ul>
  ramdisk = '/boot/initrd.img-2.6.18-3-xen-686'
+
<li>You can use the VNUML filesystems as xen_fs. It is highly recomendable to install kernel modules before. The commands are (exact version may change, so check it):</li>
  memory  = '32'
 
  root    = '/dev/sda1 ro'
 
  disk    = [ 'file:/root/xen-test/domains/test/disk.img,sda1,w', 'file:/root/xen-test/domains/test/swap.img,sda2,w' ]
 
  name    = 'test'
 
  vif    = [ 'ip=192.168.247.140' ]
 
  on_poweroff = 'destroy'
 
  on_reboot  = 'restart'
 
  on_crash    = 'restart'
 
  
In order to boot the machine (note that you don't have to specify the complete pathname of test.cfg, it seems that xm looks in /etc/xen by default).
+
  mount /usr/share/vnuml/filesystems/xen_fs /mnt/loop -o loop
 +
  cd /mnt/loop/lib/modules
 +
  cp -va /lib/modules/2.6.18-4-xen-686 .
 +
  cd /
 +
  umount /mnt/loop
 +
 
 +
<strong><span color="style:red">Warning:</span></strong>: differently from the usual configuration with VNUML, <strong>this filesystem doesn't work in COW mode, all modification performed during virtual machine operation will be stored in the xen_fs</strong>. In order to avoid changes in the root_fs file, I recommend you to use a copy and not directly the one you are using for your COW-ed based VNUML scenarios.
 +
 
 +
<li>The vif line configures a network interface in the virtual machine (named 'eth0'). I haven't alaready checked, but it is supossed that additional vif lines will add additional interfaces (eth1, eth2, etc.</li>
 +
<li>This configuration uses 50MB of memory</li>
 +
<li>This configuration does not use swap memory</li>
 +
 
 +
</ul>
 +
 
 +
In order to boot the machine (note that you don't have to specify the complete pathname of test.cfg if it is located in a default directory; it seems that xm looks in /etc/xen by default).
  
 
   xm create test.cfg -c
 
   xm create test.cfg -c
Line 80: Line 110:
 
To connect to the virtual machine console:
 
To connect to the virtual machine console:
  
   xm console test
+
   xm console <domU>
  
 
To finish with the virtual machine:
 
To finish with the virtual machine:
  
   xm destroy test
+
   xm destroy <domU>
 
 
== Using VNUML filesystems ==
 
 
 
Root filesystem prepared to work with VNUML also work with Xen. In order to use a VNUML filesystem just edit the disk line in /etc/xen/test.cfg so it looks like:
 
 
 
  disk    = [ 'file:/usr/share/vnuml/filesystems/root_fs_tutorial-0.4.1-xen,sda1,w', 'file:/root/xen-test/domains/test/swap.img,sda2,w' ]
 
  
WARNING: in order to avoid changes in the root_fs file, I recommend you to use a copy and not directly the one you are using for your COW-ed based VNUML scenarios.
+
To get performance info:
 
 
Maybe you get a lot of warning messages like the following one:
 
 
 
  4gb seg fixup, process syslogd (pid 1107), cs:ip 73:b7efc5f0
 
  4gb seg fixup, process syslogd (pid 1107), cs:ip 73:b7efc570
 
  4gb seg fixup, process klogd (pid 1113), cs:ip 73:b7e2e5f0
 
  4gb seg fixup, process klogd (pid 1113), cs:ip 73:b7eafd10
 
  printk: 38 messages suppressed.
 
  4gb seg fixup, process named (pid 1128), cs:ip 73:b7bc5c1c
 
  
In order to avoid them, see the Troubleshooting section below (TODO)
+
  xm top
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Line 117: Line 132:
 
<li>If you run Xen in a VMware virtual machine using NAT, you should use an special MAC prefix for your Xen virtual machine: 00:0C:29. Edit the /etc/xen/test.cfg file and edit the vif line so looks (for example):</li>
 
<li>If you run Xen in a VMware virtual machine using NAT, you should use an special MAC prefix for your Xen virtual machine: 00:0C:29. Edit the /etc/xen/test.cfg file and edit the vif line so looks (for example):</li>
  
   vif  = [ 'mac=00:0C:29:11:22:33, ip=192.168.247.140']
+
   vif  = [ 'mac=00:0C:29:11:22:33' ]
  
 
the problem is quite similar to the one described in the following post in the vnuml-users list: https://lists.dit.upm.es/pipermail/vnuml-users/2005-September/000204.html
 
the problem is quite similar to the one described in the following post in the vnuml-users list: https://lists.dit.upm.es/pipermail/vnuml-users/2005-September/000204.html
Line 123: Line 138:
 
<li>Although the xen-create-image command --ip options maps to</li>
 
<li>Although the xen-create-image command --ip options maps to</li>
  
  vif = [ 'ip=192.168.247.140' ]
+
</ul>
  
the interface is not brought up (neither assigned an IP address) during the 'xm create'. Actually, the 'man xmdomain.cfg' shows:
+
== Open issues ==
  
      vif An array of virtual interface stanzas in the form:
+
The strange messages that appear in the virtual machine consoles:
 
 
              vif = [ "stanza1", "stanza2", ... ]
 
 
 
          Each stanza specifies a set of name = value options separated by
 
          commas, in the form: "name1=value1, name2=value2, ..."
 
 
 
          OPTIONS
 
 
 
          bridge
 
              The network bridge to be used for this device.  This is espe-
 
              cially needed if multiple bridges exist on the machine.
 
 
 
          mac The MAC address for the virtual interface.  If mac is not spec-
 
              ified, one will be randomly chosen by xen with the 00:16:3e
 
              vendor id prefix.
 
  
In summary, that ip is not a valid option in vif. Maybe is was used in a previous Xen version but xen-create-image has not been correctly updated to the new options set?
+
  4gb seg fixup, process syslogd (pid 1107), cs:ip 73:b7efc5f0
 
+
  4gb seg fixup, process syslogd (pid 1107), cs:ip 73:b7efc570
</ul>
+
  4gb seg fixup, process klogd (pid 1113), cs:ip 73:b7e2e5f0
 +
  4gb seg fixup, process klogd (pid 1113), cs:ip 73:b7eafd10
 +
  printk: 38 messages suppressed.
 +
  4gb seg fixup, process named (pid 1128), cs:ip 73:b7bc5c1c
  
 
== Uselful references ==
 
== Uselful references ==

Revision as of 14:12, 29 March 2007

Xen HOWTOS for Debian

Installing Xen basic packages in Debian

First of all, update the APT repository

 apt-get update

Xen Hypervisor

Install the Xen hypervisor. Note that the version may have changed: search for the current one using 'apt-get search xen-hypervisor'.

 apt-get install xen-hypervisor-3.0.3-1-i386

In the case you get "CPU0 panic" errors when booting this hypervisor, try with the PAE version instead:

 apt-get install xen-hypervisor-3.0.3-1-i386-pae

Install the Xen kerne l

 apt-get install linux-image-xen-686

Install Xen tools

 apt-get install xen-tools

Install the libc6-xen

I'm not sure what it's for or even if this installation could be omitted :)

 apt-get install libc6-xen

Tunning Xen

Grub boot configuration

Kernel boot configuration should be upgraded when installing linux-image-xen-686 package. However, this automatic upgrade doesn't seem to work properly, so manual editing of /boot/grub/menu.lst is required.

Considering the linux-image-xen-686 installed /boot/vmlinuz-2.6.18-4-xen-686 (exact version may change, so check it), you should configure the following booting option in your /boot/grub/menu.lst file:

  title           Debian GNU/Linux, kernel 2.6.18-4-xen-686
  root            (hd0,0)
  kernel          /xen-3.0.3-1-i386-pae.gz
  module          /vmlinuz-2.6.18-4-xen-686 root=/dev/sda2 ro
  module          /initrd.img-2.6.18-4-xen-686
  savedefault
  boot

Configure networking

I needed to edit /etc/xen/xend-config.sxp and configure the network-script option, in order virtual machines get direclty bridged to the external interface (eth1 in my case, change it appropiately):

  (network-script 'network-bridge netdev=1')

Configure loop

If you want to run many virtual machines simulteneously (more than 8) you have to use max_loop option for loop module (http://lists.xensource.com/archives/html/xen-users/2006-06/msg01150.html). For example:

   rmmod loop
   modprobe loop max_loop=64

(It would be prefereable to put it in the right place so 'modprobe loop' works; but I don't know/remember which configuration file tune :)

Creating a virtual machine

Use the following configuration file (let's say test.cfg):

  kernel  = '/boot/vmlinuz-2.6.18-4-xen-686'
  ramdisk = '/boot/initrd.img-2.6.18-4-xen-686'
  memory  = '50'
  root    = '/dev/sda1 ro'
  disk    = [ "file:/usr/share/vnuml/filesystems/xen_fs,sda1,w" ]
  name    = 'occ0-v'
  vif     = [  ]
  on_poweroff = 'destroy'
  on_reboot   = 'restart'
  on_crash    = 'restart'

Comments:

  • You can use the VNUML filesystems as xen_fs. It is highly recomendable to install kernel modules before. The commands are (exact version may change, so check it):
  •   mount /usr/share/vnuml/filesystems/xen_fs /mnt/loop -o loop
      cd /mnt/loop/lib/modules
      cp -va /lib/modules/2.6.18-4-xen-686 .
      cd /
      umount /mnt/loop
    

    Warning:: differently from the usual configuration with VNUML, this filesystem doesn't work in COW mode, all modification performed during virtual machine operation will be stored in the xen_fs. In order to avoid changes in the root_fs file, I recommend you to use a copy and not directly the one you are using for your COW-ed based VNUML scenarios.

  • The vif line configures a network interface in the virtual machine (named 'eth0'). I haven't alaready checked, but it is supossed that additional vif lines will add additional interfaces (eth1, eth2, etc.
  • This configuration uses 50MB of memory
  • This configuration does not use swap memory

In order to boot the machine (note that you don't have to specify the complete pathname of test.cfg if it is located in a default directory; it seems that xm looks in /etc/xen by default).

 xm create test.cfg -c

It also can take a while to boot the virtual machine. The '-c' is to get the booting output and loging in the same console where xm is invoked (this is very useful to know when the virtual machine has been booted). To come back to the host enviroment just press Ctrl+].

Uselful management operations

To list active domains:

 xm list

To connect to the virtual machine console:

 xm console <domU>

To finish with the virtual machine:

 xm destroy <domU>

To get performance info:

 xm top

Troubleshooting

  • If you have problems related with memory when booting virtual machines, you may find useful the dom0_mem kernel switch. Edit your GRUB configuration so your kernel line looks like this:
  •  kernel /boot/xen-3.0.3-1-i386.gz dom0_mem=512M
    

    changing 512 for the desired memory in your case, of course. NOte that if you use a dom0_mem value to close to your actual physical RAM memory you will get a panic error when booting the host: as a hint dom0_mem<= phy_mem-32M (assuming the Xen hypervirso consumes less than 32MB).

  • If you run Xen in a VMware virtual machine using NAT, you should use an special MAC prefix for your Xen virtual machine: 00:0C:29. Edit the /etc/xen/test.cfg file and edit the vif line so looks (for example):
  •  vif  = [ 'mac=00:0C:29:11:22:33' ]
    

    the problem is quite similar to the one described in the following post in the vnuml-users list: https://lists.dit.upm.es/pipermail/vnuml-users/2005-September/000204.html

  • Although the xen-create-image command --ip options maps to

Open issues

The strange messages that appear in the virtual machine consoles:

 4gb seg fixup, process syslogd (pid 1107), cs:ip 73:b7efc5f0
 4gb seg fixup, process syslogd (pid 1107), cs:ip 73:b7efc570
 4gb seg fixup, process klogd (pid 1113), cs:ip 73:b7e2e5f0
 4gb seg fixup, process klogd (pid 1113), cs:ip 73:b7eafd10
 printk: 38 messages suppressed.
 4gb seg fixup, process named (pid 1128), cs:ip 73:b7bc5c1c

Uselful references