Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: using linux as domU. --- done!!!



Cem Kayali, 11/19/08 19:44:
Hi,

I'm neither NetBSD developer nor tester, but an end-user and i am really very happy to use NetBSD as my primary operating system on my notebook. As an end-user, i was planning to launch a blog type web site to publish an end-user's NetBSD experience and small tricks.

Xen, NetBSD and a linux distro... I've searched many resources and couldn't find a good tutorial mentioning about to use an existing linux distribution as Xen guest domain. NetBSD's offical one seems to be complex even for average users.

I partitioned the hard disk using Ubuntu's Gparted software on Ubuntu live cd, and then installed Grub while installing Ubuntu. Much easier. And then, i have installed NetBSD too. After installing some of packages and editing some of configuration files, result is perfectly working 'NetBSD as dom0 and Ubuntu as domU'.

Link to tutorial is http://netbsd.eticaret.com.tr/index.php?sayfa=xen-netbsd-linux

Please try at your own risk.

Best Regards,
Cem


Hello!

This post is archiving purposes only... We will remove netbsd.eticaret.com.tr subdomain, and its content as of Jan 1 st, 2009 and will re-publish later.

So, it is good idea to send the content publicly.

Regards,
Cem



###################################################

Xen: NetBSD as host domain (dom0) and pre-installed linux as guest domain (domU)

###################################################

Your use of any information offered in this tutorial is totally at your own risk!

Hello!

In this tutorial, i would like to mention about how to setup NetBSD as host domain, dom0 and a linux distribution as guest domain, domU using Xen environment.

First of all, we thank you NetBSD friends, for great instructions: http://www.netbsd.org/ports/xen/howto.html. Though, we will install NetBSD as host domain as is mentioned in NetBSD site, we will install guest linux distribution using standard way, using its installation CD - or we will use an existing linux distribution.

# Obtaining installation CDs and softwares:

First of all obtain following (or newer) iso images from NetBSD and Ubuntu official sites and burn them into standard CDs.

- NetBSD 5.99.01; (ie; amd64)
- Ubuntu 8.04; (ie; amd64)

Secondly we will need NetBSD Xen dom0 kernel, you can download it from NetBSD ftp site, now or later ie; ftp://ftp.netbsd.org/pub/NetBSD-daily/HEAD/{date}/{arch}/binary/kernel/netbsd-XEN3_DOM0.gz. Make sure it is compatible with your NetBSD installation. You can compile your own if you know how to compile a kernel properly.

# Partitioning hard disk

Let me mention about how i partitioned the disk using Ubuntu's Gparted software which is included Ubuntu installation CD.

- Primary partition 1: Linux ext2, we will install Ubuntu onto this partition. Dont forget to set this partition as active! - Primary partition 2: Shared swap, my personal choice. I dont like extended partitions really.
- Primary partition 3: NetBSD, we will install NetBSD onto this one.
- Primary partition 4: Linux ext2, our plan is to install another linux distribution, it will be empty now.

# Installing Ubuntu and softwares

Installing Ubuntu is not difficult task really, because it provides a good looking installation instructions. According to our hard disk partitions, we will install Ubunto onto first primary partition.

After starting Installation CD and selecting 'Try Ubuntu without change in your computer' from menu, it boots. You will see install icon in desktop, and start installation.

There are two important issues while installing:

- Use manual partitioning while selecting installation partitions. According to above settings, select hda1/sda1 as / partition and hda2/sda2 as swap. I suggest you to use ext2 format for / partition. - Just before it starts installation, there is window and a button named as advanced. Click on the button and select first primary partition ie; /dev/sda1 as boot loader installation device. This is probably second choice in drop down list. Personally i do not prefer to install Grub onto master boot record. We will edit boot configuration file.

Now let's install Xen and Xen kernels. Open up a terminal window and type:

$sudo apt-get install ubuntu-xen-server

This will install all required Xen packages. We will move domU kernel and initrd file to NetBSD partition later. Now lets modify grub boot configuration file so that we can boot NetBSD properly (later):

$sudo chmod 666 /boot/grub/menu.lst

And then open /boot/grub/menu.lst using a Ubuntu's text editor and insert following lines into it:

title NetBSD chain
root (hd0,2)
chainloader +1

You need to adjust root parameter above according to your original partition settings. We will install NetBSD onto 3rd primary partition and you need to use partition_number minus 1 as root value: root (hd0,2)

Also comment following line by inserting #in front of it:

hiddenmenu

If you have already installed Ubuntu distribution, you probably have Grub installed into master boot record. Please check Ubuntu web site, and search for how you can activate new configuration. Be carfull with this issue.

Ubuntu installation is complete and grub on first primary partition is ready to start NetBSD once we install it.

Shutdown

# Installing NetBSD and softwares

Please install NetBSD to your hard disk. A perfect guide is at NetBSD site: http://www.netbsd.org/docs/guide/en/chap-inst.html and do not allow NetBSD to modify master boot record. Install NetBSD boot code to its own partition.

Reboot the computer. If Ubuntu grub has been modified properly, you can select NetBSD in grub menu and start NetBSD. If there is a problem, just boot Ubuntu and check /boot/grub/menu.lst file and NetBSD root value.

Adjust your rc.conf file, your other settings and make sure you have internet connection enabled NetBSD system now. A perfect guide is at NetBSD site: http://www.netbsd.org/docs/guide/en/part-config.html

Please install NetBSD pkgsrc package management system. A perfect guide is at NetBSD site: http://www.netbsd.org/docs/pkgsrc/introduction.html

Please install following packages using pkgsrc as is mentioned at at NetBSD site: http://www.netbsd.org/ports/xen/howto.html. You do not need to install grub, because we installed grub while installing Ubuntu distribution.

- sysutils/xentools3
- sysutils/xentools3-hvm
- sysutils/xenkernel3

Well, your xen kernel is at /usr/pkg/xen3-kernel directory. Copy xen.gz to your root folder, as /xen.gz

#cp /usr/pkg/xen3-kernel/xen.gz /xen.gz

Please also copy and unzip your NetBSD dom0 kernel, etiher downloaded from NetBSD site (see above, netbsd-XEN3_DOM0.gz), or your own compiled one to your root folder, as /netbsd-DOM0. You can unzip it using gunzip command.

$gunzip netbsd-XEN3_DOM0.gz ; cp netbsd-XEN3_DOM0 /netbsd-DOM0

Let's now prepare multiboot, Xen enabled boot configuration file. Please open /boot.cfg add following line into it:

#vi /boot.cfg
menu=Boot Xen:modules enabled;load /netbsd-DOM0; multiboot xen.gz dom0_mem=512000 console=vga -- bootdev=wd0a ro console=pc #This should be one line entry

Please adjust host dom0 memory amount according to your physical memory.

Please also copy following rc.d scripts into /etc/rc.d directory... If you do not boot Xen kernel, this may cause a warning message while booting but no problem:

#cp /usr/pkg/share/examples/rc.d/xend /etc/rc.d/xend
#cp /usr/pkg/share/examples/rc.d/xenbackendd /etc/rc.d/xenbackendd

NetBSD is almost ready. You need to start above services either manually or automatically. You would prefer manual start because you may not boot Xen enabled kernel every boot. Manual start command is as:

#/etc/rc.d/xend onestart
#/etc/rc.d/xenbackendd onestart

Now, let's mount Ubuntu partition and copy Xen linux kernel and images. Ubuntu's guest linux kernel has name similar to this one: vmlinuz-*-xen.(gz)

#mount /dev/wd0e /mnt
#cp /mnt/boot/vmlinuz-2.6.24-21-xen.gz /vmlinuz-2.6.24-21-xen.gz
#cp /mnt/boot/initrd.img-2.6.24-21-xen /initrd.img-2.6.24-21-xen
#umount /mnt

Please check your partition names using disklabel wd0 comand, because name of Ubuntu partition may be different than wd0e. Well if vmlinuz-*-xen.(gz) kernel is in gzip format, please unzip it:

#gunzip vmlinuz-2.6.24-21-xen.gz

Before rebooting using multiboot option, let's create Xen configuration file:

#vi /mnt/usr/pkg/etc/xen/linux

Please insert following lines into it:

memory=512
name="linux"
cpu="^1"
vif=['mac=aa:00:00:50:02:f0, bridge=bridge0']
disk=['phy:/dev/wd0e,hda1,w']
root="/dev/hda1 ro"
kernel="/vmlinuz-2.6.24-21-xen"
ramdisk="/initrd.img-2.6.24-21-xen"
extra="TERM=xterm xencons=tty console=tty0"

You need adjust paths and value of other variables. You can use vif=[''] first of all. Do not delete extra variable.

Reboot, select NetBSD from Grub menu and once you see NetBSD boot menu select Xen enabled kernel.

Once you logged in as root, and started X window, start Xen services:

#/etc/rc.d/xend onestart
#/etc/rc.d/xenbackendd onestart

Now we are ready to boot Ubuntu. Make sure /dev/wd0e is unmounted and use following command to start Ubuntu as Xen guest domain.

#xm create -c /usr/pkg/etc/xen/linux

If everything is as should be, Ubunto boots properly.

Shutdown it using command below

#xm shutdown linux

Forcefully destroy it using command below

#xm destory linux



by Cem Kayali / cemkayali(at)eticaret.com.tr

###################################################












Home | Main Index | Thread Index | Old Index