Diskless NetBSD HOW-TO(无盘工作站)
这个指南试图帮助你设定通过网络启动一台netbsd工作站时的服务器配置。这个指南并不要求在你的客户端安装了任何操作系统,甚至可以没有硬盘(这种就叫无盘作站)。
(以下省略)
如果你有一个小硬盘,你仍然可以安装bootloader,一个小的根分区,何一个小的交换分区,这样运行的速度仍然比通过网络要明显快点。
netbsd1.5已经解决了好几个有关无盘工作站的问题,所以你可以使用1.5作为你的客户端。
这个指南尽可能涉及到更多的硬件和操作系统。如果你不耐烦的话,你可以直接阅读diskless这个manpage.以便确定你的硬件和boot rom版本是否能够通过lan(局域网)启动。
(译者:由于使用i386机器比较普遍,所以就只翻译了i386部分)
Diskless NetBSD HOW-TO
这个指南试图帮助你设定通过网络启动一台netbsd工作站时的服务器配置。这个指南并不要求在你的客户端安装了任何操作系统,甚至可以没有硬盘(这种就叫无盘作站)。
(以下省略)
如果你有一个小硬盘,你仍然可以安装bootloader,一个小的根分区,何一个小的交换分区,这样运行的速度仍然比通过网络要明显快点。
netbsd1.5已经解决了好几个有关无盘工作站的问题,所以你可以使用1.5作为你的客户端。
这个指南尽可能涉及到更多的硬件和操作系统。如果你不耐烦的话,你可以直接阅读diskless这个manpage.以便确定你的硬件和boot rom版本是否能够通过lan(局域网)启动。
(译者:由于使用i386机器比较普遍,所以就只翻译了i386部分)
1,介绍
...............
i386部分:
...............
2,设置启动器(bootloader)
...............
设置dhcpd 服务(i386,macppc,sparc64)
3,设置daemons(用于传输kernel)
设定rpc.bootparamd 服务
设定tftp服务
4,设置nfs服务
5,设置文件系统
6,完成安装
-------------------------------------------------------------
1,介绍
i386-部分
在无盘操作中,有几种方法可以载入netbsd kernel
1,通过netboot rom
首先你的bios支持从网络启动,并且有匹配的网卡。在pc越来越流行的今天,网卡都已经是标准配置了。设定一台网络上的服务器并改变你的bios设置(参考diskless manpage),试试能否从网络启动它。
如果你的bios不支持,但是你有一张支持netbsd'netboot' bootloader的网卡,你可以启动到dos(参考下面的dosboot.com)
然后使用netboot.com莱通过网络在入kernel.为了生成合适的netboot.com,请到 /usr/src/sys/arch/i386/stand/netboot,编辑Makefile,设置适合你的网卡的选项,然后运行make netboot.com。
2,通过pxe
如果你的硬件兼容pxe,你可以使用dhcp服务为他分配ip.dhcpd服务使用网卡硬件地址Mac来确定客户端得ip和 bootloader文件名。如果上述方法成功了,pxe将可以通过tftp下载第二阶段使用的boot程序。
他会通过tftp连接到服务器(就是先前的应答dhcp请求的服务器),并请求服务器上的文件。一切就绪,第二步取得的boot程序将通过nfs和dhcp请求到的路径取得kernel.
有两个pxe bootloader文件存在于/usr/mdec/目录.pxbeboot_ia32.bin用于大部分场合。 pxeboot_ia32_com0.bin会强制客户端使用它的第一个栓口作为console(控制台)。pxeboot_ia32_com0.bin 通常用于嵌入式系统环境,这些系统只有串行控制台。使用9600 8N1配置。
简单得说:如果你有许多pxe系统,你可以通过/etc/dhcpd.conf一起设定他们为一个组。
class "pxe-clients-ia32" {
match if substring (option vendor-class-identifier, 0, 20)
= "PXEClient:Arch:00000";
filename "pxeboot_ia32_com0.bin";
}
3,通过grub
一个启动管理器,它能通过网络启动各种类型的操作系统。他自己也可以从磁盘启动和通过使用pxe/nbi启动器从网络启动。 etherboot & grub支持许多网卡,远比netbsd的netboot多。值得一提的是:请你使用grub0.90以后的版本。
grub和etherboot需要gcc和gnu binutils 2.9.1或者更高的版本,他们可以在任何系统上编译,并不一定非要在netbsd主机上编译。
你需要设置一下以便etherboot可以载入和执行grub image,并设置grub可以载入netbsd kernel.下面是具体的步骤:
1,为你的eprom装入合适的etherboot eprom image
2,编译grub (>0.90),--enable-diskless 和 --enable-*(针对你的网卡设定参数)
3,将编译好的grub stage2/nbgrub image放到tftp服务器上。
4,为无盘机器设置dhcpd,看起来像这样:
option option-150 code 150 = text;
group {
subnet 192.168.0.0 netmask 255.255.255.0 {
option log-servers 192.168.0.1;
option domain-name-servers 192.168.0.1;
# location of GRUB configuration file
option option-150 "/tftpboot/grub.conf";
# NFS root path
option root-path "/home/dolecek/netbsd-root";
# path of image EtherBoot should load and execute
filename "/tftpboot/nbgrub";
}
host foobar { fixed-address foobar; hardware ethernet 00:c0:6c:76:17:46; }
}
5,设置grub的配置文件并将其放到tftp服务器上。下面是例子:
# uncomment following two lines to use serial terminal
# serial --unit=0 --speed=57600
# terminal --timeout=0 serial
# Boot automatically after 5 secs.
timeout 5
# By default, boot the first entry.
default 0
# Fallback to the first entry.
fallback 0
# For booting the NetBSD
title NetBSD
kernel --type=netbsd /tftpboot/netbsd
6,grub并不会将启动信息通知netbsd.因此,如果你向自动启动netbsd,需要明确的配置kernel参数,像这样:
config netbsd root on ? type nfs
接着,便以内核,然后将它放到tftp服务器上(具体的信息由grup的配置文件决定)
7,如果你使用serial console,你需要配置grub和kernel.在grub配置中(上面的grub配置),请使用serial,terminal参数。使用 netbsd console,你的加入参数像:
options "CONSDEVNAME=\"com\"",CONADDR=0x2f8,CONSPEED=57600
4,通过软盘
在内核配置文件中设定下面的选项,以便软盘上的内核可以通过网络装在root文件系统。
onfig netbsd root on ? type nfs
你得先看看怎样编译内核。
5,通过dosboot.com启动dos或者windows(不是nt)
netbsd编译了一个特殊bootloader版本.dosboot.com。在/usr/mdec中。要像是用它,将dosboot.com和kernel拷贝到fat(msdos)分区,并启动到dos.
1,windows95/98
按f8,在启动菜单里显示Loading Windows XX的时候。这个菜单选项怎么显示取决于你的安装。
不要载入HIMEM.SYS/EMM386.SYS驱动。请选择Step-by-step confirmation,并根据环境回答所有问题为n/esc
如果你不在意装入himem.sys驱动,请选择Command prompt only"
2,dos or windows3.1
按住shift,跳过config.sys和autoexec.bat
进入doc提示符时,转到你放置dosboot.com和kernel的目录,输入dosboot命令启动netbsd,或者dosboot filename(filename 是你得kernel名字,如果你没有使用默认名字的话)
dosboot工具可以使用extended内存,和himem.sys一样。不幸的是netbsd会调用apm bios。如果你不是apm bios,不会有问题,或者netbsd不会使用它。如果你有apm,请不要载入himem.sys驱动(上面启动的时候)。
如果你需要定制的dosboot.com,转道/usr/sys/arch/i386/stand/dosboot,编辑Makefile,然后make
6,通过 NT 的启动管理器
它可以直接启动netbsd.请参考Adding NetBSD to the Windows NT boot menu
---------------------------------------------------------
(译者:上面完成了准备工作)
下面的步骤是:
2,设定dhcpd 服务
dhcpd被用在一些工作站需要ip地址和bootloaer文件启动boot rom.dhcpd是一个标准的后台程序。如果你发现bootpd有问题,你可以使用dhcpd代替。bootpd和dhcpd不能同时运行。
dhcpd有两个实现。isc和cmu.netbsd使用isc版本,因为它支持更多平台,许多平台已经预安装了这个版本。
/etc/dhcpd.conf是一个跨平台的配置文件版本。他的配置很灵活。我们提供了一个使用固定地址配置的简单版本。更多信息参考dhcpd,dhcpd.conf ,dhcpd-options的manpage
netbsd dhcp how-to,isc的dhcp站点。
在下一步配置tftp和nfs服务的时候,你的小心配置。
dhcpd.conf包含有注释。建议你保存到/etc才为你的站点改变地址。并不是所有选项都适合各种场合,所以你可以根据自己需要改变。
------------------
netbsd上的设置
请确定你的kernel配置中有如下选项
pseudo-device bpfilter 4
默认kernel已经包含着个选项。
1,touch /var/db/dhcpd.leases
如果没有,dhcpd是不会工作的。
2如果你还没有/etc/dhcpd.conf,请安装默认的版本。
3,ps -aux|grep dhcpd
杀掉这个进程kill -HUP不会强迫dhcpd重读配置文件的。
4,/usr/sbin/dhcpd -d -f
这个指令dhcpd打开debug。当dhcpd发现一个请求时,他会输入下面的信息:
BOOTREQUEST from CC:CC:CC:CC:CC:CC via le0 (non-rfc1048)
BOOTREPLY for 192.168.1.10 to client.test.net
(CC:CC:CC:CC:CC:CC) via le0
DHCPDISCOVER from CC:CC:CC:CC:CC:CC via le0
DHCPOFFER on 192.168.1.10 to CC:CC:CC:CC:CC:CC via le0
DHCPREQUEST for 192.168.1.10 from CC:CC:CC:CC:CC:CC via le0
DHCPACK on 192.168.1.10 to CC:CC:CC:CC:CC:CC via le0
bootloader不会打印任何消息,但当kernel查找root文件系统的时候,会有下面的输出信息:
boot device: <unknown>
nfs_boot: trying DHCP/BOOTP
nfs_boot: DHCP server: 0xC0A80105
nfs_boot: my_name=client
nfs_boot: my_domain=test.net
nfs_boot: my_addr=0xC0A8010A
nfs_boot: my_mask=0xffffff00
nfs_boot: gateway=0xC0A80101
root on :/export/client/root
下面就是配置tftpd和nfs服务
3,设定tftpd服务
它用来在通过boot rom启动时,下载boot loaser和kernel.它运行在tcp/ip协议上,所以客户机必须首先取得ip,通常是通过rarp,bootp,dhcp(上面介绍的)
首先,请确定你没有通过TCP WRAPPER拒绝任何IP访问.请看/etc/hosts.deny /etc/hosts.allow中有没有tftp....
下一步,根据客户机的情况拷贝需要的文件到/tftpboot中.比如sparc 192.168.1.10:
# mkdir -p /tftpboot
# cp /export/client/root/usr/mdec/boot /tftpboot/C0A8010A.SUN4C
注意:一些tftpd不支持chroot,你需要指出具体路径(在bootparams,bootpd,dhcpd),请先测试一下。
如果成功
# cd /tftpboot
# ln -s . tftpboot
下面是netbsd/openbsd具体设置:
1,编辑/etc/inetd.conf.移除下面行前的#
tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /tftpboot
2,确定最后的路径为/tftpboot
3,# ps -aux | grep inetd
kill -HUP that process to force it to reread /etc/inetd.conf.
测试如下:
# tftp tftpserver.test.net
tftp> get C0A8010A.SUN4C
Received 683 bytes in 0.3 seconds
tftp> quit
这里我们获取C0A8010A.SUN4C,sparc kernel
下面是nfs的设置
4,设定nfs服务
nfs是unix中标准的网络文件系统.bootloader会通过它找到kernel,装载到内存,然后把控制权交个kernel.客户机需要nfs server的读/写权限,如果对于你觉得有安全疑虑,那么请小心设定可以访问的客户机.
下面的目录必须有root读/写权限
/
/var
/etc
/dev
因此,预先做的事情是将/home和/usr同/export/client/root分开,并不允许他们的root r/w权限.
路径看起来是这样的:
Server (exported directory) Client
/export/client/root /
/export/client/swap (file) /swap (file)
/export/client/usr /usr
/export/client/home /home
注意/swap做为一个文件来装载
当然,注意到如果服务器是相同的平台,并运行着netbsd,那么客户能够使用服务器/usr目录,这样,你需要输出/usr代替上面的/export/client/usr
nfsd,mountd,rpcbind,portmap服务不能在tcp wapper中的hosts.allow/hosts.deny中被禁止访问.
下面是真对netbsd./openbsd上的nfs
确定你的内核选项有:options NFSSERVER
默认内核已经包含这个选项.
1. # mkdir -p /export/client/root/dev
2. # mkdir /export/client/usr
3. # mkdir /export/client/home
4. # touch /export/client/swap
5. # cd /export/client/root
6. # tar -xvpzf /export/client/NetBSD-release/binary/sets/kern.tgz
7. # mknod /export/client/root/dev/console c 0 0
8. Add the following lines to /etc/exports:
#/etc/exports
/export/client/root -maproot=root:wheel client.test.net
/export/client/swap -maproot=root:wheel client.test.net
/export/client/usr -maproot=nobody:nobody client.test.net
/export/client/home -maproot=nobody:nobody client.test.net
9. # ps -aux | grep mountd
If mountd is running, then kill -HUP that process to force it to reread /etc/exports. Otherwise, you'll need to start it:
# /usr/sbin/mountd
10. # ps -aux | grep nfsd
If the nfsdaemons are not running, then you need to start them:
# /usr/sbin/nfsd -tun 4
如果服务器没有运行nfs,客户机将打印下面信息:
le(0,0,0,0): Unknown error: code -1
boot: Unknown error: code -1
如果服务器运行了nfs,但没有输出root目录,客户将打印信息:
boot: no such file or directory
如果一切正常,你会看到客机上显示一些数字和闪烁的光标.oh,成功了.注意,你的客户机并不是可启动的.如果继续init的话,系统将当机.正确的步骤是下面的设定文件系统.
5,设定文件系统.
下面的步骤是独立于服务器操作系统的.有些文件是tftp的
1,# cd /export/client/root
2,如果tftpserver上没运行tftpd,你的检查一下时候有gnu tar程序(>1.12)
# tar --version
tar (GNU tar) 1.12
如果不是,请先获得tar
3,解开基本的文件包
# tar [--numeric-owner] -xvpzf /export/client/NetBSD-release/binary/sets/base.tgz
# tar [--numeric-owner] -xvpzf /export/client/NetBSD-release/binary/sets/etc.tgz
4,同样的解开其他文件包
5,# mkdir /export/client/root/kern
6,设定swap
# mkdir /export/client/root/swap
# dd if=/dev/zero of=/export/client/swap bs=4k count=4k
他将创建一个16mB的swap文件.
7,设定/etc/ifconfig.le0,le0是你的网卡名:
inet client netmask 255.255.255.0 broadcast 192.168.1.255
根据你的情况修改子网掩码
8,设定/etc/fstab
/export/client/root/etc/fstab, which has the following lines:
#/etc/fstab
nfsserver:/export/client/swap none swap sw,nfsmntpt=/swap
nfsserver:/export/client/root / nfs rw 0 0
nfsserver:/export/client/usr /usr nfs rw 0 0
nfsserver:/export/client/home /home nfs rw 0 0
9,编辑/etc/rc.conf
/export/client/root/etc/rc.conf. Some important things to set up are (replace 192.168.1.1 with the router your network administrator specifies):
hostname="client"
defaultroute="192.168.1.1"
nfs_client=YES
auto_ifconfig=NO
net_interfaces=""
注意这里不能设定网卡
10,加入机器到/etc/hosts
/export/client/root/etc/hosts:
#/etc/hosts
192.168.1.10 client.test.net client
192.168.1.5 nfsserver.test.net nfsserver
现在可以启动你的无盘工作站了
It's time to boot up your diskless machine!
1. Here is an example of what the diskless boot messages on a NetBSD/hp300 machine look like.
If your screen goes black or appears to hang, make sure that NetBSD supports a local console on your particular machine, you may need to hook up a serial terminal.
If your serial terminal doesn't show anything (or your machine doesn't even have serial ports), then you need to read additional directions on setting up remote access without any console
2. Your client will boot into single-user mode, giving you this prompt:
Enter pathname of shell or RETURN for sh:
Hit return.
3. It'll ask you your terminal type.
On a NetBSD/hp300 machine, the local console, is hp300h, and for serial console, you should probably use vt100
4. # mount /usr
5. Create the /dev files.
# cd /dev
# /bin/sh MAKEDEV all
This takes a while (at least two minutes), be patient.
Note, this won't work using the HP-UX 9 or earlier NFS server, since it doesn't allow client creation of device files. You'll have to download this tarball of device files (5 KB) for NetBSD/hp300 and run, on the nfs server:
# cd /export/client/root
# tar [--numeric-owner] -xpvzf dev.tar.gz
6. Check to make sure swap will work:
# swapctl -A
swapctl: adding nfsserver:/export/client/swap as swap device at priority 0
# swapctl -l
Device 512-blocks Used Avail Capacity Priority
/dev/?? 32768 0 32768 0% 0
7. Continue to multi-user mode. Edit /etc/rc.conf either on the nfs server (in /export/client/root/etc/rc.conf) or on the client, and change the line to read:
rc_configured=YES
8. Exit out of the single-user shell, by typing exit.
9. Log in as root and have fun using your new NetBSD diskless workstation!
Now, you should continue on and finish up the diskless procedure by making sure your server(s) start all of the necessary daemons the next time they reboot.