Friday, May 18, 2007

Xen Installation in debian etch

Install Xen first

#apt-get update
#apt-get install xen-hypervisor-3.0.3-1-i386 xen-utils-3.0.3-1
#apt-get install linux-image-2.6.18-4-xen-686

give the version no according to you deb repository.

edit /etc/xen/xend-config.sxp
------------------------------
uncomment this two line
(network-script network-bridge)
(vif-script vif-bridge)

Install tools for xen
#apt-get install bridge-utils iproute sysfsutils libc6-xen xen-tools

Create a directory
#mkdir /home/xen

edit /etc/xen-tools/xen-tools.conf

here is my sample config file
(Here I am showing only uncomment part)
dir = /home/xen
debootstrap = 1
# Disk and Sizing options.
##
#
size = 1Gb # Disk image size.
memory = 128Mb # Memory size
swap = 128Mb # Swap size
# noswap = 1 # Don't use swap at all for the new system.
fs = ext3 # use the EXT3 filesystem for the disk image.
dist = etch # Default distribution to install.
image = full # Specify sparse vs. full disk images.

##
# Networking setup values.
##

#
# Uncomment and adjust these network settings if you wish to give your
# new instances static IP addresses.
#
gateway = 192.168.7.1
netmask = 255.255.255.0
#
# Uncomment this if you wish the images to use DHCP
#
# dhcp = 1

# Uncomment the following line if you wish to interactively setup
# a new root password for images.
#
passwd = 1

# Default kernel and ramdisk to use for the virtual servers
#
kernel = /boot/vmlinuz-2.6.18-4-xen-686
initrd = /boot/initrd.img-2.6.18-4-xen-686

# The default mirror for debootstrap which can be used to install
# Debian Sid, Sarge, and Etch.
#
mirror = http://ftp.debian.org/debian/


To create an image (here I am showing with debootstraping)
#xen-create-image --hostname=test --ip=192.168.7.90 --passwd
it will ask for the root passwd after finish the debootstrap.


edit /etc/xen/test.cfg

check the kernel version is correct for your system
kernel = '/boot/vmlinuz-2.6.18-4-xen-686'
ramdisk = '/boot/initrd.img-2.6.18-4-xen-686'

xen-tools generate the disk sda for me. Later I change it to hda
root = '/dev/hda1 ro'
disk = [ 'file:/home/xen/domains/test/disk.img,hda1,w', 'file:/home/xen/domains/test/swap.img,hda2,w' ]

check you ip
if = [ 'ip=192.168.7.90' ]





To start the vm
#xm create test.cfg -c

it will start to boot (simple output)
-------------------------------------
checking file systems...fsck 1.40-WIP (14-Nov-2006)
done.
Setting kernel variables...done.
Mounting local filesystems...done.
Activating swapfile swap...done.
Setting up networking....
Configuring network interfaces...done.
INIT: Entering runlevel: 2
Starting system log daemon: syslogd.
Starting kernel log daemon: klogd.
* Not starting internet superserver: no services enabled.
Starting OpenBSD Secure Shell server: sshdNET: Registered protocol family 10
lo: Disabled Privacy Extensions
IPv6 over IPv4 tunneling driver
.
Starting periodic command scheduler: crond.

Debian GNU/Linux 4.0 test tty1

test login:

or use
#xenman
file-->open Domain File
and select the /etc/xen/test.cfg





Here is the nmap output for ip 192.168.7.90
Interesting ports on test (192.168.7.90):
Not shown: 1696 closed ports
PORT STATE SERVICE
22/tcp open ssh
MAC Address: 00:16:3E:1F:8F:58 (Xensource)
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.17.9 (X86)
Uptime: 198.839 days (since Tue Oct 31 15:09:34 2006)
Network Distance: 1 hop



Now I can ssh to my 192.168.7.90
#debian:/home/salahuddin# ssh root@192.168.7.90
root@192.168.7.90's password:
Last login: Fri May 18 05:50:41 2007
Linux test 2.6.18-4-xen-686 #1 SMP Mon Mar 26 21:49:04 UTC 2007 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
test:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:15:BC:3F
inet addr:192.168.7.90 Bcast:192.168.7.255 Mask:255.255.255.0
inet6 addr: fe80::216:3eff:fe15:bc3f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:92 errors:0 dropped:0 overruns:0 frame:0
TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15420 (15.0 KiB) TX bytes:5239 (5.1 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

test:~#halt

Broadcast message from root@test (ttyp0) (Fri May 18 06:16:58 2007):

The system is going down for system halt NOW!
test:~# Connection to 192.168.7.90 closed by remote host.
Connection to 192.168.7.90 closed.
debian:/home/salahuddin#



Note:
Change your kernel path and disk config according to your system.
First time I tried with image = sparse in /etc/xen-tools/xen-tools.conf but it did not work for me.
Later I give image = full.


for more doc:

http://wiki.debian.org/Xen

http://www.debian-administration.org/articles/396
http://www.howtoforge.com/perfect_setup_xen3_debian

https://help.ubuntu.com/community/XenVirtualMachine/XenOnUbuntuEdgy

No comments: