Remote boot in Linux 一、版權說明 本文版權屬於全體作者所有,且以 GNU FDL 授權合約發佈。在遵守 GNU FDL 授權合約的情況下,您可以複製、散佈,以及修改本文件。唯請保持 作者列表的完整,若您修改過此份文件,也請在作者列表中加入您的大名。 同時請注意本文件沒有任何擔保,若因本文件而產生任何直接或間接的損 失,本文作者群均不負任何法律及道義上的責任。 二、作者列表 Steven Shiau (jhshiau@nchc.gov.tw) K. L. Huang (c00hkl00@nchc.gov.tw) H. T. Wang (c00wht00@nchc.gov.tw) 三、作法 Things to do: - make kernel - buildin NIC, IP:kernel level autoconfiguraton, root over NFS - mknbi package - Tagged kernel (prepared with mknbi-linux) - get or make .lzpxe image (from http://www.rom-o-matic.net or made with Etherboot) - DHCP Server - TFTP Server - NFS Server - NIS Server - NIS client - create filesystem for client machine - make kernel - buildin NIC, kernel ip autoconfiguraton, root over NFS 1. make the custom kernel a. get the latest kernel in http://www.kernel.org b. compile the kernel, and the following should be buildin, not modules, (1). in block devices, check <*> RAM disk support (4096) Default RAM disk size [*] Initial RAM disk (initrd) support (2). in Networking options: check [*] IP: kernel level autoconfiguration [*] IP: DHCP support [*] IP: BOOTP support [ ] IP: RARP support <--- not needed (3). in file system, -> Network File Systems --->, check <*> NFS file system support [*] Provide NFSv3 client support [*] Root file system on NFS (4). the driver for NIC should also be checked, - mknbi package - Tagged kernel (prepared with mknbi-linux) 1. download mknbi package in: http://prdownloads.sourceforge.net/etherboot/mknbi-1.2-8.noarch.rpm 2. use mknbi-linux to create the NBI: mknbi-linux --output=/tftpboot/vmlinuz-etherboot arch/i386/boot/bzImage --ip=rom - get or make .lzpxe image (from http://www.rom-o-matic.net or made with Etherboot) a. get .lzpxe for you PXE NIC in http://www.rom-o-matic.net/5.0.6/ Ex. If you have 3Com 3c905c NIC, then download this one: eb-5[1].0.6-3c905c-tpo.lzpxe - DHCP Server 1. setup DHCP server as: using DHCP version 3.0 or above a. get it in http://www.isc.org/products/DHCP/ or get something like "dhcp-3.0b2pl23-1mdk.i586.rpm" in http://www.rpmfind.net b. the dhcpd.conf should like: ----------------------------------------------- default-lease-time 21600; max-lease-time 21600; use-host-decl-names on; option subnet-mask 255.255.255.0; subnet 192.168.0.0 netmask 255.255.255.0 { option broadcast-address 192.168.0.255; option routers 192.168.0.254; option domain-name-servers 192.168.0.254; host node001 { hardware ethernet 00:50:56:01:01:01; fixed-address 192.168.0.1; filename "vmlinuz-etherboot"; if substring (option vendor-class-identifier, 0, 9) = "PXEClient" { filename "eb-5[1].0.6-3c905c-tpo.lzpxe"; } else if substring (option vendor-class-identifier, 0, 9) = "Etherboot " { filename "vmlinuz-etherboot"; } host node002 { hardware ethernet 00:50:56:01:01:11; fixed-address 192.168.0.2; if substring (option vendor-class-identifier, 0, 9) = "PXEClient" { filename "eb-5[1].0.6-3c905c-tpo.lzpxe"; } else if substring (option vendor-class-identifier, 0, 9) = "Etherboot " { filename "vmlinuz-etherboot"; } host node003 { hardware ethernet 00:50:56:01:01:21; fixed-address 192.168.0.3; if substring (option vendor-class-identifier, 0, 9) = "PXEClient" { filename "eb-5[1].0.6-3c905c-tpo.lzpxe"; } else if substring (option vendor-class-identifier, 0, 9) = "Etherboot " { filename "vmlinuz-etherboot"; } } ----------------------------------------------- 2. service dhcp start - TFTP Server 1. setup tftp server a. install tftp server, the file is in the Redhat cdrom. rpm -Uvh tftp-server-0.28-2.i386.rpm b. the config file in /etc/xinted.d/tftp (for xinte.d), , it should be: ---------------------------------------------------- service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot disable = no } ---------------------------------------------------- ps. "disable = no" should be in the last, not in the begining. c. service xinted restart - NFS Server a. 請先確定 nfs-utils 套件有裝, 然後用ntsysv將nfs, nfslock開啟 b. edit /etc/exports, so that client machine can mount directory via NFS: -------------------------------------------- /tftpboot/node001 192.168.0.1(rw,no_root_squash) /usr 192.168.0.1(ro,no_root_squash) /opt 192.168.0.1(ro,no_root_squash) /home 192.168.0.1(rw,no_root_squash) ... -------------------------------------------- ps. "no_root_squash"是允許讓使用者具備 root 的權限 c. you must have hostname in /etc/hosts so that server can let client to access /etc/hosts should like this: -------------------------------------------- 127.0.0.1 localhost.localdomain localhost 192.168.0.254 server.EBP.org server 192.168.0.1 node001.EBP.org node001 192.168.0.2 node002.EBP.org node002 192.168.0.3 node003.EBP.org node003 ... -------------------------------------------- d. service nfs restart - NIS Server a. 確定 ypserv 套件有安裝 b. 執行 ntsysv 將 ypserv 和 yppasswdd開啟 c. 修改 /var/yp/securenets, like this: -------------------------------------------- # Always allow access for localhost 255.0.0.0 127.0.0.0 # This line gives access to everybody. PLEASE ADJUST! #0.0.0.0 0.0.0.0 255.255.255.0 192.168.0.0 -------------------------------------------- d. service ypserv start e. service yppasswdd start f. nisdomainname EBP g. cd /var/yp; make - NIS client a. 確定 ypbind 和 yp-tools 套件有安裝 b. 執行 ntsysv﹐確定 ypbind 開啟 c. 修改 /etc/yp.conf, like this: -------------------------------------------- domain EBP server 192.168.0.254 -------------------------------------------- d. 修改 /etc/sysconfig/network, like this: -------------------------------------------- NISDOMAIN=EBP -------------------------------------------- e. service ypbind restart - create filesystem for client machine a. script to create filesystem: -------------------------------------------- #!/bin/sh if [ $# != 1 ] then echo Usage: $0 client-IP-addr-or-name exit 1 fi cd / umask 022 in /tftpboot/node001 for d in home mnt proc tmp usr opt do mkdir /tftpboot/$1/$d done chmod 1777 /tftpboot/$1/tmp touch /tftpboot/$1/fastboot chattr +i /tftpboot/$1/fastboot # copy these ones cp -a bin sbin lib dev etc root var /tftpboot/$1 # cat <