Home > xen

xen

From $1

 

 

Xen Install on Lenny Debian

This guide describes the way I intalled my home server. The server is a Debian Lenny installation containing a variaty of virtual servers. The virtualisation is done by xen. This guides describes the proceses needed, commands issued and so on.

Good luck!

 

Step 1 - Basic installation

First install a minimal Lenny from a network boot machine.
(I assume you will manage this without desciption)

 

Step 2 - Change settings

We need to change the IP address of the server as we want it to have a static address (instead of an address issued by DHCP):

# nano /etc/network/interfaces

Change the following parts of this file

[...]
# The primary network
interface 
allow-hotplug eth0 
iface eth0 inet static 
address      192.168.2.201 
netmask      255.255.255.0 
network      192.168.2.1 
broadcast    192.168.2.255 
gateway      192.168.2.1 
# IPtables settings
[...]

Now restart the network device:

# ifdown eth0
# ifup eth0

Now we need to install the ssh-server to make maintainance a bit easier:

# apt-get install openssh-server

 

Step 3 - Install xen

Finally it is time to install our mighty xen:

# apt-get install xen-hypervisor-i386 linux-image-2.6-xen-686 linux-headers-2.6-xen-686 xen-utils-3.2-1 xen-tools bridge-utils

To make the consoles work we also need to make some changes to the inittab:

# nano /etc/inittab

 

Step 4 - Edit xen to make it work properly

After the installation there are still a few adjustments to make in order to get it running smoothly. Firstly we make the consoles work. Therefore we need to make some changes to the inittab:

# nano /etc/inittab

Change the following parts of this file

[…]
#
1:2345:respawn:/sbin/getty 38400 hvc0 
2:23:respawn:/sbin/getty 38400 tty1 
#3:23:respawn:/sbin/getty 38400 tty3 
#4:23:respawn:/sbin/getty 38400 tty4 
#5:23:respawn:/sbin/getty 38400 tty5 
#6:23:respawn:/sbin/getty 38400 tty6 
[…]

Also edit the /etc/xen/xend-config.sxp

# nano /etc/xen/xend-config.sxp

See the desciption on: http://www.howtoforge.com/virtualization-with-xen-on-debian-lenny-amd64

Next edit the xen-tools.conf

# nano /etc/xen-tools/xen-tools.conf

See the desciption on: http://www.howtoforge.com/virtualization-with-xen-on-debian-lenny-amd64

Finally we also need to make some adjustments to prevent the famous “clocksource/0: Time went backwards” error (or similar problems) by not using the xen clock. First we need to install ntp on the dom0:

# apt-get install ntp

Also see: http://wiki.debian.org/Xen

Then, later, we also have to take some steps into account for the domU, but we see about them later!

 

Now it is time to load our new (xen)kernel. Therefore, reboot the server:

# reboot

 

Step 5 - Create a domU (virtual server)

Let's create a dumU:

# xen-create-image --hostname=<DOMAIN>.hanckmann.net --size=4Gb --swap=256Mb –ip=192.168.2.<IP ADDRESS> --memory=128Mb --arch=i386 –role=udev

For example:

# xen-create-image --hostname=apache.hanckmann.net --size=4Gb --swap=256Mb --ip=192.168.2.211 --memory=128Mb --arch=i386 –role=udev

 

Before we do anything else, we first prevent the famous “clocksource/0: Time went backwards” error. Edit the *.cfg file of the created domU domain:

# nano /etc/xen/<DOMAIN>.hanckmann.net.cfg

Now add (or expand) the extra line: 

[…]
extra=”clocksource=jiffies”
[…]

This domU runs a standard Debian Lenny installation on the i386 platform with 4Gb disk space, 256Mb swap space and 128Mb memory.

 

Step 6 - Start the domU

Now it is time to start this domU. This is done via the command "xm create ...cfg". In my example I would issue the command:

# xm create /etc/xen/apache.hanckmann.net.cfg

 

Check if the domU managed to start by typing:

# xm list

The domU should be in that list.

 

To work with the domU we have to connect to its console. We do this via:

# xm console apache.hanckmann.net

 

Step 7 - Adjusting the domU

The domU needs some minor adjustments to make it work nicely. First we, again, go on to prevent the famous “clocksource/0: Time went backwards” error. Type:

# nano /etc/sysctl.conf

and add the line: 

[…]
xen.independent_wallclock=1
[…]

Now install the ntp client on this machine:

# apt-get install ntp

 

To activate the changes without a reboot perform the following steps:

# sysctl -p
# echo "jiffies"> /sys/devices/system/clocksource/clocksource0/current_clocksource

 

Besides this it is a good idea to generate an rsa key so you can ssh into your virtual machine (sshserver is installed by default):

# ssh-keygen

You can also simply reboot the domU.

 

Step 8 - Exit the domU environment

To exit the domU environment type CTRL + ]

 

Step 9 - Read the following information sources

 

 

 

 

extra extra parameters

Hi,

I had to add "console=hvc0 xencons=tty" to the extra parameter. If not, I cannot access the dom0 console...

extra = "clocksource=jiffies console=hvc0 xencons=tty”

thanks for the tuto ++

 

Move an LVM-based virtual machine to another host

by Brad on Apr.26, 2008, under Linux, Tech Notes, Virtualization

For those running Xen on servers with no back-end SAN, the following instructions detail the steps necessary to move an LVM-based virtual machine to a new physical host. There may be more elegant ways to achieve this, but this is what worked for me.

Environment
Ok, so let’s set the scene:

  • vmhost is a RHEL 5 server running several virtual machines using the Xen virtualization technology. Each virtual machine is allocated a 60 GB logical volume within an LVM volume group. One of these virtual machines, “win2k3vm”, needs to be moved to a new server.
  • new-vmhost is almost identical to vmhost, but has updated hardware and more memory. This is the server that “win2k3vm” will be moved to.


Migrate the Virtual Machine
1. Create a snapshot of virtual machine LVM volume. This can be run on a live virtual machine, but it is probably safer to perform a graceful shutdown of your virtual machine first.

[root@vmhost]# lvcreate -s -L 300m -n win2k3vm-snap VolGroup01

2. Export the snapshot of the guest VM to a file that can be moved between physical servers.

[root@vmhost]# dd if=/dev/VolGroup01/win2k3vm-snap of=/mnt/temp/win2k3vm.img bs=4096

3. Remove the snapshot LVM volume.

[root@vmhost]# lvremove /dev/VolGroup01/win2k3vm-snap

4. Copy the file to the new VM host. Make sure you have sufficient free drive space.

[root@vmhost]# scp /mnt/temp/win2k3vm.img user@new-vmhost:/mnt/temp/

5. On the new VM host, create an LVM volume that is at least as big as the guest VM file.

[root@new-vmhost]# lvcreate -n win2k3vm -L 60G VMGroup

6. Transfer the guest VM file to the new LVM volume.

[root@new-vmhost]# dd if=win2k3vm.img of=/dev/VMGroup/win2k3vm bs=4096

7. Copy the VM config file from the old VM host to the new VM host server.

[root@vmhost]# scp /etc/xen/win2k3vm user@new-vmhost:

8. Copy the file to the appropriate directory.

[usr@new-vmhost]$ sudo mv ~/win2k3vm /etc/xen/

Summary of Commands
[root@vmhost]# lvcreate -s -L 300m -n win2k3vm-snap VolGroup01
[root@vmhost]# dd if=/dev/VolGroup01/win2k3vm-snap of=/mnt/temp/win2k3vm.img bs=4096
[root@vmhost]# lvremove /dev/VolGroup01/win2k3vm-snap
[root@vmhost]# scp /mnt/temp/win2k3vm.img user@new-vmhost:/mnt/temp/
[root@new-vmhost]# lvcreate -n win2k3vm -L 60G VMGroup
[root@new-vmhost]# dd if=win2k3vm.img of=/dev/VMGroup/win2k3vm bs=4096
[root@vmhost]# scp /etc/xen/win2k3vm user@new-vmhost:
[usr@new-vmhost]$ sudo mv ~/win2k3vm /etc/xen/

 dd if=/dev/arsndom/arsn.arsena.co.id-disk-snpsht conv=noerror,sync bs=64k | ssh root@10.1.1.32 'dd of=/dev/node0032/arsn.arsena.co.id-disk'


Retrieved from "http://wiki.adijaya.com/xen"

Tags:
 
Images (0)
 
Comments (0)
You must login to post a comment.