FreeBSD如何跑diskless?
2024-07-26 00:29:23
供稿:網友
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的事情了。