FreeBSD上如何跑 diskless?

/ns/wz/sys/data/20020820033225.htm


diskless 可以让 FreeBSD client PC 不需要硬碟就可以透过网路跑 FreeBSD。
以下是两个成功的范例:

======== 范例一 =========
From: client.bbs@csie.nctu.edu.tw (client)
Newsgroups: tw.bbs.comp.386bsd
Subject: Re: 如何使 diskless 的 pc 也能跑 freebsd
Date: 27 May 1995 05:44:34 GMT

(1) /etc/bootptab 建立diskless pc 的资料
(2) /etc/servives 之bootpd 及 tftpd 是否打开
(3) /etc/inetd.conf 之tftpd 是否打开
(4) bootpd 放入 /etc/rc 差不多最后面
(若由inetd 来叫 ,时常抢不过 ka9q 的 bootpd)
(5) 建立diskless pc 的 root file system. ex:/home/diskless1
(6) 建立diskless pc 的swap file system.
建目录: ex:/home/swapfs
建swap file: 若diskless pc 的 ip: 140.115.10.222
则 touch /home/swapfs/swap.140.115.10.222
(7) 把 freebsd 整个系统 拷贝至 /home/diskless1
(8) export /home/diskless1 及 home/swapfs 给 diskless pc
(9) 建立 /tftpboot/cfg.140.115.10.222 file
rootfs server:/home/diskless1
swapfs server:/home/swapfs
swapsize 32000
(10)至/usr/src/sys/i386/boot/netboot make *.com 或 *.rom
make install
至/usr/mdec 取你要的 档案,开 diskless pc

大致上,是如此! 自己再try !
========================

======== 范例二 ========
From: upleong@csie.nctu.edu.tw (Bills)
Newsgroups: tw.bbs.comp.386bsd
Subject: 设定diskless pc step by step
Date: 16 Oct 1996 03:17:58 GMT


给大家分享一下. 实在太好玩了。

假设有两台机器,
serverxy 是提供 diskless开机之server, ip: 140.113.141.191
clientab 为 diskless之机器 ip: 140.113.141.204
以下范例是在同一domain之下测试成功的(注: 好像是在不同domain也可以)

所有要修改或增加的档案:
a. /etc/inetd.conf
b. /etc/services
c. /tftpboot/cfg.xxx.yyy.zzz.www
d. /etc/bootptab
e. /swapfs/swap.xxx.yyy.zzz.www
f. /sys/i386/conf/boot/netboot/*.com
g. /rootfs/clientab ;这里是整个系统
h. /etc/exports

Server端的设定:
(一)修改 /etc/inetd.conf 加入tftpd, 修改/etc/services 增加tftpd,
bootpd的功能, 其中diskless的机器之root file system在 /rootfs/clientab。
/etc/inetd.conf:
tftp dgram udp wait nobody /usr/libexec/tftpd \
tftpd -l /tftpboot /rootfs/clientab
/etc/services:
tftp 69/tcp #Trivial File Transfer
tftp 69/udp #Trivial File Transfer
bootps 67/tcp dhcps #Bootstrap Protocol Server
bootps 67/udp dhcps #Bootstrap Protocol Server
bootpc 68/tcp dhcpc #Bootstrap Protocol Client
bootpc 68/udp dhcpc #Bootstrap Protocol Client

(三)以后启动 bootpd, 可以加入/etc/rc.local之中, 其设定档为/etc/bootptab。
/etc/rc.local:
/usr/libexec/bootpd -s /etc/bootptab

(二)修改 bootptab, 把该改的该一下就好了, 详细之参数可参考handbook或man。
/etc/bootptab:
.default:\
:td=/tftpboot:hd=/clientab:bf=kernel:\ ;bf可设定boot file name
:sm=255.255.255.0:\
:hn:\
:ds=140.113.1.1, 140.113.17.5:\ ;改为你的domain name server
:ip=140.113.141.204:\ ;diskless client之 IP
:gw=140.113.141.254:\
:dn=dorm10.nctu.edu.tw:\ ;改一下domain name
:vm=rfc1048:
clientab:ht=ether:ha=0000b46b0369:tc=.default:
;ht为client的网路种类
;ha为网路卡的hardware address

(四)设定 tftpboot的 config file, 这是开机时 client从 server得到资讯的地
方。
档案名皆为 cfg.[client ip addr]。 eg. cfg.140.113.141.191
/tftpboot/cfg.140.113.141.204: ;档案名记得要改...
rootfs 140.113.141.191:/rootfs/clientab ;rootfs放在server的
; /rootfs/clientab目录下
swapfs 140.113.141.191:/swapfs ;swap file放在/swapfs下
swapsize 20000 ;swap size in KB
hostname clientab.dorm13.nctu.edu.tw ;client的host name
ip 140.113.141.204 ;client的ip address
kernel kernel ;kernel叫什么, 因为一开机就
; 是NFS mount rootfs, kernel
;要有NFS support 才能动

(五)建一个 swap file的档案, 改名为 swap.[client IP address]
> touch /swapfs/swap.140.113.141.204

(六)把 client的file systems(/ /sbin /bin /root /etc ...)放在前面定义的地方

(/rootfs/clientab)。Client可以和 server分享一部份的file systems, 如/usr,
/usr/local等。但 rootfs等则不可以share。
这里要怎样拷过去比较好呢? 我只想到把一些最基本的程式拷到rootfs, 等开
机后再 mount freebsd.csie:/some/where/SNAP; sh upgrade.sh。

(七)修改/etc/exports, 把client的file system及swap都打开给client。
root partition记得要maproot, 否则会没效。
/etc/exports:
/rootfs/clientab /swapfs -maproot=root:wheel clientab.dorm13.nctu.edu.tw

(八)启动tftp和bootpd。
>kill -1 `cat /var/run/inetd.pid`;
>/usr/libexec/bootpd -s /etc/bootptab;

Client端的设定:
因为是diskless的关系, 设定都跑到 server去了, 所以只要准备开机片就好了。剩

就是开机时打一下参数等。
(一)建立网路开机所需的档案。
cd /usr/src/sys/i386/boot/netboot
修改Makefile中网路卡的参数, 如 NE_BASE=0x300等。
make all install
cd /usr/mdec; 把 *.com copy 至一DOS formatted的磁片上。

(二)以DOS 开机
看是那一张网路卡, 执行其中一个 .com的档案后, 它会自动去找bootpd的server.
不过并不容易找到, 解决方法是手动给它填些参数。
按ESC后会进到menu的command line, help 可以得到 help :P
>server 140.113.141.191
>ip 140.113.141.204
>netmask 255.255.255.0
>gateway 140.113.141.254
>kernel kernel ;指定kernel name (eg. kernel.GENERIC)
>flags c s ;等于boot: -c -s
>autoboot
顺利的话会看到loading kernel...等讯息, 可以开机进入single就成功了, 其他
设定都是diskless PC的事情了。