FreeBSD/Xen Howto


NOTE: All these works here are still under testing and may not be suitable for production environment. We only support FreeBSD/i386 for now. As for the dom0 suppport of FreeBSD, we still need some time to get it ready. Stay tuned :-)

How to install FreeBSD as domU

There are several files needed if one wants to install FreeBSD as a domU domain: kernel (freebsd-XENU_INSTALL & freebsd-XENU), config (freebsd_xen_INSTALL) and of course an image file if you install FreeBSD into a file instead of a real hard disk.

1. If you prefer a file backed system, then the first thing should do is to create an image file. It could be done like the following:

dd if=/dev/zero of=freesd_xen_INSTALL.img bs=1024k count=1000

This will create a 1GB blank image file for use. Feel free to change the parameters to match your own needs.

2. Make sure the kernel file and config file are in proper place. Typically, the config file would be placed in /etc/xen/vm, and the kernel's location is specified in that config file.

3. To install FreeBSD as domU, make sure these two lines are used in config file:

kernel = "/Path/To/Kernel/freebsd-XENU_INSTALL"
#kernel = "/Path/To/Kernel/freebsd-XENU"
extra += ",vfs.root.mountfrom=ufs:/dev/md0"
#extra += ",vfs.root.mountfrom=ufs:/dev/md0/xbd769s1a"

4. Now we could start installing. Just create the domain as usual:

xm create -c /Path/To/Config/freebsd_xen_INSTALL

After the domain boots, it will ask you to choose a console to continue the intallation process. "2 ...................... VT100 or compatible terminal." is a good choice here. Then we will be brought to the familiar Sysinstall Menu dialog. The very first thing needs to do here is change the Release Name from 7.0-CURRENT to the RELEASE version that you intend to install, since we port Xen in 7.0-CURRENT and don't offer a RELEASE kernel with Xen support currently. This could be done in the menu entry "Options".

NOTE: The installation will hang when "Extracting base in / directory" if you choose to install 6.1-RELEASE , while 6.0-RELEASE works fine in my machine using a file backed system. So it's up to you whether or not to test 6.1-RELEASE.

5. After choosing a proper FreeBSD release, continue the installation process as you usually do. When it is time to come into FDISK Partition Editor dialog, you would find that the DISK Geometry showing here is 0 cyls/0 heads/0 sectors, which ends up with a 0MB disk for us to use. Make sure to use "G" to set Drive Geometry manually. Just to type something like "1000/1000/1000" is enough, as sysintall will first complain the geometry we typed makes no sense and then offer us some certain disk geometry workable. Then continue.

6. The whole installation made via FTP has been tested and works very well. Other methods for installation via network should also work. Choose your own preferred installation media and let sysinstall finish the left installation.

7. When the installing process is finished, almost everything has been done. DO NOT reboot this domain immediately, we still need to do one more trick. In the Main Installation Menu, go into Configure entry, select "TTYs" item, and press "Yes" to edit /etc/ttys. What should be done here is simple: Add one line and comment all the ttyv lines or turn them off.

The modified ttys file would look like this:

xc0 "/usr/libexec/getty Pc" vt100 on secure
#ttyv0 "/usr/libexec/getty Pc" cons25 on secure
# Virtual terminals
#ttyv1 "/usr/libexec/getty Pc" cons25 on secure
#ttyv2 "/usr/libexec/getty Pc" cons25 on secure
#ttyv3 "/usr/libexec/getty Pc" cons25 on secure
#ttyv4 "/usr/libexec/getty Pc" cons25 on secure
#ttyv5 "/usr/libexec/getty Pc" cons25 on secure
#ttyv6 "/usr/libexec/getty Pc" cons25 on secure
#ttyv7 "/usr/libexec/getty Pc" cons25 on secure
#ttyv8 "/usr/X11R6/bin/xdm -nodaemon" xterm off secure

8. Now the config file for this domain needs to be modified since the whole installaion has been done and we want to boot into this system next. Change it like this:

#kernel = "/Path/To/Kernel/freebsd-XENU_INSTALL"
kernel = "/Path/To/Kernel/freebsd-XENU"
#extra += ",vfs.root.mountfrom=ufs:/dev/md0"
extra += ",vfs.root.mountfrom=ufs:/dev/md0/xbd769s1a"

9. OK. Now you could safely reboot this domain, either using "xm reboot domainID" or sysinstall itself. Or you could shutdown this domain using "xm shutdown domainID" and then restart it. If you choose rebooting, then use "xm list" to figure out domainID for this domain after rebooting (usually it will increase 1 compared with the domainID it has before rebooting). "xm console domainID" will now bring you into the brand new system that you just installed. Enjoy it. :-)

How to use freebsd-XENU kernel to start domU directly

If you prefer to use an existing FreeBSD system rather than installing a new one, here is one way to do this. Files needed are kernel (freebsd-XENU) and config (freebsd_xen).

I still use file backed system as a example. For real hard disk situation, a few modificaitons will be needed.

1. Create the image for file backed system. Since we want to put a existing system on it rather than installing FreeBSD on it, it is not as simple as creating a blank image while doing the install-domU process. The following is the basic way to do it:

  • Create a file system in the image.

  • dd if=/dev/zero of=freesd_xen.img bs=1024k count=1000
    mdconfig -a -t vnode -f freebsd_xen.img -u 0
    bsdlabel -e md0 #edit md0 to add /(md0a) and swap(md0b), at least we need these two for a working system
    newfs md0a
  • mount /dev/md0a and copy data from an existing FreeBSD system to it. Dump & Restore are good tools for this job.

2. After the image is created, apply some tricks to get it work under Xen.

  • Edit /etc/fstab like this:

  • # Device             Mountpoint  FStype  Options  Dump  Pass#
       /dev/xbd769b  none  swap  sw  0  0
       /dev/xbd769a  /  ufs  rw  1  1

    This is because Xen doesn't know anything about ad0, ad0s1 or somthing like that, we should please it using the way that Linux use.

  • Edit /etc/ttys. Add one line and comment all the ttyv lines or turn them off.

  • xc0 "/usr/libexec/getty Pc" vt100 on secure
    #ttyv0 "/usr/libexec/getty Pc" cons25 on secure
    ...

    xc0 is the console name for FreeBSD that Xen would recognizes.

  • Edit /etc/rc.conf. Change the NIC name to xn0 like below:

  • ifconfig_xn0="inet 192.168.1.103 netmask 255.255.255.0"

    xn0 is the NIC name for FreeBSD that Xen would recognizes.




оставьте свой отзыв


Другие стать из рубрики :
Советы

Настройка сети в linux
 Сегодня многих интересует настройка сети в linux. Основн...

Виртуальные машины для linux
Сегодня разнообразные компании, в особенности те, которые зани...

какие есть игры для linux
Вы установили операционную систему linux, или может она была уже н...

как узнать какой linux
Часто, начиная работать в операционной системе linux, пользователи...

для чего нужен linux
Очень часто, когда узнаешь, что на компьютере знакомого установле...

какой Linux лучше
В интернете  на различных форумах можно все чаще встретить о...

Как установить Linux?
Установка Linux дело совсем не сложное, так что вы можете сразу же...

Какой выбрать Linux
Операционная система – основа для работы на компьютерной технике ...

Как установить Apache на Debian?
Установка Apache на Debian не представляет из себя ничего сложного...

Установка KDE на FreeBSD.
Работа с FreeBSD уже давно зарекомендовала себя с хорошей стороны....