免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4781 | 回复: 14
打印 上一主题 下一主题

[NetBSD] [原创]体验NetBSD 3.0/Xen 2.0 [复制链接]

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-03-01 20:25 |只看该作者 |倒序浏览
日期:2006.3.1
作者:congli@chinaunix.net
博客:http://congli.cublog.cn

BSD License版权发布

参考文章:NetBSD/Xen Howto.详细http://www.netbsd.org/Ports/xen/howto.html.

一.磁盘分区介绍(以FreeBSD命令):
ad0s1        128MB        FAT32        # Grub
ad0s2        20GB                UFS2                # FreeBSD
ad0s3        18GB                FFSv2        # NetBSD


二.构建Xen-Based系统(Domain0)

假设NetBSD 3.0已安装,并同步了pkgsrc及src.

1.安装Grub
# cd /usr/pkgsrc/sysutils/grub
# make install clean clean-depends


2.把Grub安装到第一个分区,使用Grub引导NetBSD及NetBSD/Xen.

3.安装xentools20
# cd /usr/pkgsrc/sysutils/xentools20
# make install clean clean-depends

4.安装Xen 2.0内核
# cd /usr/pkgsrc/sysutils/xenkernel20
# make install clean clean-depends

复制Xen 2.0内核到/目录下:
# cp /usr/pkg/xen-kernel/xen.gz /


5.编译NetBSD/Xen内核,并复制成为/netbsd-XEN0
# cd /usr/src/sys/arch/i386/conf
# config XEN0
# cd ../compile/XEN0
# make depend
# make
# cp netbsd /netbsd-XEN0

6.挂上MSDOS分区,修改Grub启动列表.最后menu.lst如下:
default 0
timeout 10
       
title FreeBSD 6.0
        rootnoverify (hd0,1,a)
        chainloader +1

title NetBSD 3.0
        rootnoverify (hd0,2,a)
        chainloader +1

title NetBSD/Xen
        root (hd0,2)
        kernel (hd0,2,a)/xen.gz dom0_mem=262144
        module (hd0,2,a)/netbsd-XEN0 root=/dev/hda1 ro console=tty0

dom0_mem=262144代表了domain0的系统内存为256MB,module (hd0,2,a)/netbsd-XEN0就是NetBSD/Xen内核.

7.重启系统,并选择"NetBSD/Xen"进入系统.
# uname -a
NetBSD NetBSD.congli 3.0.0_STABLE NetBSD 3.0.0_STABLE (XEN0) #0: Tue Feb 21 03:33:30 UTC 2006  builds@works.netbsd.org:/home/builds/ab/netbsd-3-0/i386/\
200602200000Z-obj/home/builds/ab/netbsd-3-0/src/sys/arch/i386/compile/XEN0 i386


8.启动Xen工具守护进程(/usr/pkg/share/examples/rc.d/xend)
# echo 'xend=YES' >> /etc/rc.conf
# cd /dev && sh MAKEDEV xen
# /usr/pkg/share/examples/rc.d/xend start


检查是否成功
# xm list
Name              Id  Mem(MB)  CPU  State  Time(s)  Console
Domain-0           0       256    0  r----     58.1        

到此,已经成功构建并运行在Xen-Based系统(Domain0)中.


三.安装DomainU
1.编译及安装XENU内核(/netbsd-XENU)
# cd /usr/src/sys/arch/i386/conf
# config XENU
# cd ../compile/XENU
# make depend
# make
# cp netbsd /netbsd-XENU


2.编译及安装INSTALL_XENU内核(/netbsd-INSTALL_XENU)
# cd /usr/src/sys/arch/i386/conf
# config INSTALL_XENU
# cd ../compile/INSTALL_XENU
# make depend
# make
# cp netbsd /netbsd-INSTALL_XENU

注:不知道是什么原因,自己编译的netbsd-INSTALL_XENU在安装时出下面错误而不能安装,但从NetBSD网站上下载的netbsd-INSTALL_XENU却能够安装.下载地址:ftp://ftp.netbsd.org/pub/NetBSD- ... i386/binary/kernel.
其实在这里可以下载上文所提到的三个内核文件,包括netbsd-XEN0,netbsd-INSTALL_XENU及netbsd-XENU.

错误信息,提示不能挂载/设备:
xbd: using event channel 5
xbd0 at hypervisor0: Xen Virtual Block Device 2048 MB
boot device: xbd0
root on md0a dumps on md0b
no file system for md0 (dev 0x1100)
cannot mount root, error = 79
root device (default md0a):


3.建立磁盘映象文件,如果直接安装到硬盘的一个分区上则可以跳过这一步.
# mkdir /home/xen
# cd /home/xen
# dd if=/dev/zero of=nbsd.img bs=1024k count=2048

建立一个2GB大小的文件.并把NetBSD 3.0的安装ISO(i386cd.iso)文件复制到/home/xen下面.

4.使用xm工具创建DomainU,xm可以直接指定参数,或从配置文件读取,详细看帮助
# xm help CMD (如: xm help create)

下面是一个简单的配置文件(/home/xen/nbsd):
#  -*- mode: python; -*-
#===========================================
# Python defaults setup for 'xm create'.
# Edit this file to reflect the configuration of your system.
#===========================================

#----------------------------------------------------------------------------
# Kernel image file. This kernel will be loaded in the new domain.

# DomainU运行时所需要的内核文件
kernel = "/netbsd-XENU"

# DomainU安装时所需的内核文件
#kernel = "/netbsd-INSTALL_XENU"

# Memory allocation (in megabytes) for the new domain.
memory = 512

# A handy name for your new domain. This will appear in 'xm list',
# and you can use this as parameters for xm in place of the domain
# number. All domains must have different names.
#
name = "nbsd"

# Which CPU to start domain on (only relevant for SMP hardware).  CPUs
# numbered starting from ``0''.
#
cpu = -1   # leave to Xen to pick

#----------------------------------------------------------------------------
# Define network interfaces for the new domain.

# Number of network interfaces (must be at least 1). Default is 1.
nics = 1

# Define MAC and/or bridge for the network interfaces.
#
# The MAC address specified in ``mac'' is the one used for the interface
# in the new domain. The interface in domain0 will use this address XOR'd
# with 00:00:00:01:00:00 (i.e. aa:00:00:51:02:f0 in our example). Random
# MACs are assigned if not given.
#
# ``bridge'' is a required parameter, which will be passed to the
# vif-script called by xend(8) when a new domain is created to configure
# the new xvif interface in domain0.
#
# In this example, the xvif is added to bridge0, which should have been
# set up prior to the new domain being created -- either in the
# ``network'' script or using a /etc/ifconfig.bridge0 file.
#
vif = [ 'mac=aa:00:00:50:02:f0, bridge=bridge0' ]

#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
#
# Each disk entry is of the form:
#
#        phy:DEV,VDEV,MODE
#
# where DEV is the device, VDEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.  You can also create
# file-backed domains using disk entries of the form:
#
#        file:PATH,VDEV,MODE
#
# where PATH is the path to the file used as the virtual disk, and VDEV
# and MODE have the same meaning as for ``phy'' devices.
#
# VDEV doesn't really matter for a NetBSD guest OS, but it does for Linux.
# Worse, the device has to exists in /dev/ of domain0, because xm will
# try to stat() it. This means that in order to load a Linux guest OS
# from a NetBSD domain0, you'll have to create /dev/hda1, /dev/hda2, ...
# on domain0, with the major/minor from Linux :(

#disk = [ 'phy:/dev/wd0e,wd0d,w' ]
disk = [ 'file:/home/xen/i386cd.iso,cd0a,r', 'file:/home/xen/nbsd.img,wd0d,w' ]

#----------------------------------------------------------------------------
# Set the kernel command line for the new domain.

# Set root device. This one does matter for NetBSD
root = "/dev/wd0d"
# extra parameters passed to the kernel
#extra = ""

#----------------------------------------------------------------------------
# Set according to whether you want the domain  restarted when it exits.
# The default is False.
#autorestart = True

# end of nbsd config file ===========================================


因为现在是安装DomainU阶段,所以需要把配置文件改一下:
#kernel = "/netbsd-XENU"
kernel = "/netbsd-INSTALL_XENU"


安装DomainU:
# xm create /home/xen/nbsd -c


接下来就跟正常安装NetBSD 3.0没有多大区别.安装完之后,需要halt,再改一下配置文件(/home/xen/nbsd),使用netbsd-XENU来启动domainU:
kernel = "/netbsd-XENU"
#kernel = "/netbsd-INSTALL_XENU"


最后运行 xm list,
Name              Id  Mem(MB)  CPU  State  Time(s)  Console
Domain-0           0      256    0  r----   1569.6
nbsd               4      511    0  -b---      0.2    9604


四.DomainU的网络设置.
    当domU启动时,会在dom0系统中创建一个虚拟网络接口(vxif?.?),该虚拟接口跟domU系统的网络接口(xennet?)桥接,只需要把 vxif?.?及xennet?设置同一网段,domU的网关指向vxif?.?,然后在dom0系统中对vxif?.?做NAT.这样domU就可以访问外网.


欢迎大家指正!

[ 本帖最后由 congli 于 2006-5-25 07:58 编辑 ]

snapshot2.png (100.67 KB, 下载次数: 73)

snapshot2.png

论坛徽章:
2
亥猪
日期:2014-03-19 16:36:35午马
日期:2014-11-23 23:48:46
2 [报告]
发表于 2006-03-01 20:58 |只看该作者
期待老大继续完善

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
3 [报告]
发表于 2006-03-01 21:09 |只看该作者
原帖由 gvim 于 2006-3-1 20:58 发表
期待老大继续完善

今晚太累了。

论坛徽章:
0
4 [报告]
发表于 2006-03-01 22:10 |只看该作者
装了个 NetBSD 3.0 ,又在下面装了个虚拟机 Xen 2.0 ,又在 Xen 下安装了个 NetBSD 3.0, 是吗?

和 qemu 比速度如何?

那个 gnome 是你自己编译的?

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
5 [报告]
发表于 2006-03-01 22:30 |只看该作者
原帖由 jnmt 于 2006-3-1 22:10 发表
装了个 NetBSD 3.0 ,又在下面装了个虚拟机 Xen 2.0 ,又在 Xen 下安装了个 NetBSD 3.0, 是吗?

和 qemu 比速度如何?

那个 gnome 是你自己编译的?

应该是,装了NetBSD3.0及Xen2.0之后,使用NetBSD/Xen内核开机,再装NetBSD3。
因为刚刚弄出来,还没有"极速"体验过XEN,所以不好说.
那个gnome是自己编译的,你看看日期还是"-m-d"的说.呵~还没有时间弄啊.

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
6 [报告]
发表于 2006-03-01 22:45 |只看该作者
初步试验,已经可以访问外网。先卖个关子,明天再写。呵~

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
7 [报告]
发表于 2006-03-02 09:16 |只看该作者
Xen 是虾米啊?

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
8 [报告]
发表于 2006-03-02 09:35 |只看该作者
原帖由 FinalBSD 于 2006-3-2 09:16 发表
Xen 是虾米啊?

在网上找来的
Xen:
Xen 是在剑桥大学作为一个研究项目被开发出来的,目前在GPL许可下开源。Xen 被定义为一款 半虚拟化(paravirtualizing) VMM(虚拟机监视器,Virtual Machine Monitor),这表示,为了调用系统管理程序,要有选择地修改操作系统,然而却不需要修改操作系统上运行的应用程序。虽然 VMWare 等其他虚拟化系统实现了完全的虚拟化(它们不必修改使用中的操作系统),但它们仍需要进行实时的机器代码翻译,这会影响性能。现在的Xen要为内核打补丁,但是,将来的处理器能支持虚拟化,内核也就不需要打补丁了。比如说,Intel的VT和AMD的Pacifica处理器都将包括这种支持。 XenSource公司2005年8月在Intel开发者论坛(IDF)上发表声明说,它已经利用Intel的VT-Enabled平台和Xen技术虚拟化了Linux和Windows XP SP 2。

论坛徽章:
0
9 [报告]
发表于 2006-03-02 17:08 |只看该作者
原帖由 FinalBSD 于 2006-3-2 09:16 发表
Xen 是虾米啊?


你也有不知道的,呵呵!


netbsd下的第一篇xen文章终于出炉了!lili真有精力啊,估计是熬夜出来的吧!xen内核我是直接下的。

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
10 [报告]
发表于 2006-03-02 17:19 |只看该作者
原帖由 mafa 于 2006-3-2 17:08 发表


你也有不知道的,呵呵!


netbsd下的第一篇xen文章终于出炉了!lili真有精力啊,估计是熬夜出来的吧!xen内核我是直接下的。

呵~~还好还好!
兄弟多给点意见.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP