xref: /netbsd/distrib/notes/common/netboot (revision bf9ec67e)
$NetBSD: netboot,v 1.4 2002/05/20 23:07:15 mbw Exp $

Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the NetBSD
Foundation, Inc. and its contributors.
4. Neither the name of The NetBSD Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

. .(enum Introduction

p To netboot a \*M, you must configure one or more servers to provide information and files to your \*M (the .Sq client ). If you are using .Nx (any architecture) on your netboot server(s), the information provided here should be sufficient to configure everything. Additionally, you may wish to look at the .Xr diskless 8 manual page and the manual pages for each daemon you'll be configuring. If the server(s) are another operating system, you should consult the NetBSD Diskless HOW-TO, which will walk you through the steps necessary to configure the netboot services on a variety of platforms. .Lk http://www.netbsd.org/Documentation/network/netboot/

p You may either netboot the installer so you can install onto a locally attached disk, or you may run your system entirely over the network. .\}

p Briefly, the netboot process involves discovery, bootstrap, kernel and filesystem stages. In the first stage, the client discovers information about where to find the bootstrap program. Next, it downloads and executes the bootstrap program. The bootstrap program goes through another discovery phase to determine where the kernel is located. The bootstrap program tries to mount the NFS share containing the kernel. Once the kernel is loaded, it starts executing. For RAM disk kernels, it mounts the RAM disk filesystem and begins executing the installer from the RAM disk. For normal (non-RAM disk) kernels, the .\} kernel tries to mount the NFS share that had the kernel and starts executing .Xr init 8 . All supported \*M systems use HP's proprietary RMP (the .Xr rbootd 8 daemon) for the first discovery stage and bootstrap download stages. The bootstrap program uses DHCP for its discovery stage. .\} All \*M systems use BOOTP for the discovery stage. .\} All \*M systems use a combination of RARP and BOOTP for the discovery stage. In the past, these systems used RARP and BOOTPARAMS. .\} TFTP is used in the bootstrap phase to download the bootstrap program,

a ofwboot.xcf . .\}

a boot . .\}

a boot.net , which has been linked to a file name appropriate to the client's architecture and IP address as described in the TFTP section below. .\} .\} \" ! !\n[hp300] NFS is used in both the kernel and filesystem stages to download the kernel, and to access files on the file server.

p We will use .Sq Li "CC:CC:CC:CC:CC:CC" as the MAC address (ethernet hardware address) of your netboot client machine. You should have determined this address in an earlier stage. In this example, we will use .Sq Li 192.168.1.10 as the IP address of your client and .Sq Li client.test.net as its name. We will assume you're providing all of your netboot services on one machine called .Sq Li server.test.net with the client's files exported from the directory

a /export/client/root . You should, of course, replace all of these with the names, addresses, and paths appropriate to your environment.

p You should set up each netboot stage in order (i.e. discovery, bootstrap, kernel, and then filesystem) so that you can test them as you proceed.

p t .Xr rbootd 8

p Get

a SYS_UBOOT from the

a installation/misc directory of the distribution.

p .(disp .No # Ic "mkdir -p /usr/mdec/rbootd" .No # Ic "cp SYS_UBOOT /usr/mdec/rbootd" .No # Ic "chmod -R a+rX /usr/mdec/rbootd" .disp)

p Create

a /etc/rbootd.conf with the following line: .(disp CC:CC:CC:CC:CC:CC SYS_UBOOT .disp)

p You will need to start the c rbootd . If it's already running, you will need to restart it to force it to re-read its configuration file. If the server is running .Nx 1.5 or later, you can achieve this with:

p .(disp .No # Ic "/etc/rc.d/rbootd restart" .disp)

p t .\} \" ! \n[hp300] .Xr dhcpd 8 in .Xr bootpd 8 compatible mode

p .\} .Xr dhcpd 8

p The bootstrap program uses DHCP to discover the location of the kernel. .\} Put the following lines in your

a /etc/dhcpd.conf (see .Xr dhcpd.conf 5 and .Xr dhcp-options 5 for more information): .(disp ddns-update-style none; # Do not use any dynamic DNS features # allow bootp; # Allow bootp requests, thus the dhcp server # will act as a bootp server. # authoritative; # This is the authoritative DHCP server for this subnet # subnet 192.168.1.0 netmask 255.255.255.0 { # Which network interface the server will # listen on. The zeros indicate which # range of addresses are allowed to connect. } group { # Set of parameters common to all clients # in this "group". # option broadcast-address 192.168.1.255; option domain-name "test.net"; option domain-name-servers dns.test.net; option routers router.test.net; option subnet-mask 255.255.255.0; # # An individual client. # host client.test.net { hardware ethernet CC:CC:CC:CC:CC:CC; fixed-address 192.168.1.10; # # Name of the host (if the fixed address # doesn't resolve to a simple name). # option host-name "client"; # # Name of the bootloader or kernel # to download via tftp. # filename "ofwboot.xcf"; .\} filename "boot"; .\} .\} # # The path on the NFS server. # option root-path "/export/client/root"; # #next68k machines require non-RFC1048 BOOTP # always-reply-rfc1048 false; .\} } #you may paste another "host" entry here for additional clients on this network } .disp)

p You will need to make sure that the

a dhcpd.leases file exists.

p .(disp .No # Ic "touch /var/db/dhcpd.leases" .disp)

p You will need to start the c dhcpd . If it's already running, you will need to restart it to force it to re-read its configuration file. If the server is running .Nx 1.5 or later, you can achieve this with:

p .(disp .No # Ic "/etc/rc.d/dhcpd restart" .disp)

p .\} \" ! \n[hp300]:\n[macppc]:\n[next68k]:\n[sparc]

p t .Xr rarpd 8

p Create an

a /etc/ethers file with the following line:

p .(disp CC:CC:CC:CC:CC:CC client .disp)

p Add your client to the server's

a /etc/hosts file:

p .(disp 192.168.1.10 client .disp)

p You will need to start the c rarpd . If it's already running, you will need to restart it to force it to re-read its configuration file. If the server is running .Nx 1.5 or later, you can achieve this with:

p .(disp .No # Ic "/etc/rc.d/rarpd restart" .disp)

p .\} \" ! \n[sparc]

p t .Xr tftpd 8

p The deafult configuration of the TFTP server is to run in a .Xr chroot 8 environment in the

a /tftpboot directory. Thus, the first order of business is to create this directory: .(disp .No # Ic "mkdir -p /tftpboot" .disp) Next, edit

a /etc/inetd.conf and uncomment the line with the TFTP daemon: .(disp tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot .disp) Now, restart .Xr inetd 8 . If the server is running .Nx 1.5 or later, you can achieve this with:

p .(disp .No # Ic "/etc/rc.d/inetd restart" .disp)

p Now, you need to copy the bootloader for your \*M machine to

a /tftpboot . Get .Xr ofwboot.xcf 8 from the

a installation directory of the distribution. .(disp .No # Ic "cp ofwboot.xcf /tftpboot" .disp) .\} Extract

a boot from

a binary/sets/base.tgz in the distribution .(disp .No # Ic "tar -xpvzf base.tgz ./usr/mdec/boot" .No # Ic "cp ./usr/mdec/boot /tftpboot" .disp) .\} Get

a boot.net from the

a installation/netboot directory of the distribution. .(disp .No # Ic "cp boot.net /tftpboot" .disp)

p Now, you need to link

a boot.net to the filename that your \*M will look for. It will look for a filename composed of the machine's IP address (in hexadecimal) followed by the machine's architecture, separated by a period. For example, a sun4c machine which has been assigned IP address 192.168.1.10, will make a TFTP request for

a C0A8010A.SUN4C .

p You can use .Xr bc 1 to help calculate the filename: .(disp .No # Ic bc c obase=16 c 192 C0 c 168 A8 c 1 1 c 10 A c quit .No # Ic "cd /tftpboot" .No # Ic "ln -s boot.net C0A8010A.SUN4C" .disp)

p .\} \" ! \n[sparc] Just to be sure, let's make everything readable. .(disp .No # Ic "chmod -R a+rX /tftpboot" .disp)

p Sometimes, the .Xr arp 8 table gets messed up, and the TFTP server can't communicate with the client. In this case, it will write a log message (via .Xr syslogd 8 ) to

a /var/log/messages saying: .Sq Li "tftpd: write: Host is down" . If this is the case, you may need to force the server to map your client's ethernet address to its IP address: .(disp .No # Ic "arp -s client CC:CC:CC:CC:CC:CC" .disp) .\} \" ! !\n[hp300]

p t .Xr nfsd 8 , .Xr mountd 8 , and .Xr rpcbind 8

p Now your system should be able to load the bootstrap program and start looking for the kernel. Let's set up the NFS server. Create the directory you are exporting for the netboot client:

p .(disp .No # Ic "mkdir -p /export/client/root" .disp)

p Put the following line in

a /etc/exports to enable NFS sharing:

p .(disp .No "/export/client/root -maproot=root client.test.net" .disp)

p If your server is currently running an NFS server, you only need to restart .Xr mountd 8 . Otherwise, you need to start .Xr rpcbind 8 and .Xr nfsd 8 . If the server is running .Nx 1.5 or later, you can achieve this with:

p .(disp .No # Ic "/etc/rc.d/rpcbind start" .No # Ic "/etc/rc.d/nfsd start" .No # Ic "/etc/rc.d/mountd restart" .disp)

p t .Nx kernel

p Now, if you place a kernel named

a netbsd in

a /export/client/root your client should boot the kernel. If you are netbooting the installer, you can use either the traditional miniroot-based installer

a installation/miniroot/miniroot.fs.gz or the experimental RAM disk-based installer

a binary/kernel/netbsd.RAMDISK.gz .

p To use the miniroot-based installer, mount the miniroot filesystem on your netboot server. This procedure does .Em not work on any operating system other than .Nx . You'll also need to either set up a new NFS share point or an FTP sever for the distribution files, as they won't fit inside the miniroot filesystem.

p .(disp .No # Ic "gunzip miniroot.fs.gz" .No # Ic "vnconfig -c /dev/vnd0c /path/to/miniroot.fs" .No # Ic "mount -o ro /dev/vnd0c /export/client/root" .No # Ic "ls /export/client/root" .profile dist/ install.md mnt/ sbin/ usr/ bin/ etc/ install.sub mnt2/ tmp/ var/ dev/ install* kern/ netbsd* upgrade* .disp)

p If there are no files present in your exported directory, then something is wrong.

p To use the RAM disk-based installer, uncompress and rename the kernel. Also, copy the distribution files to the client's root directory.

p .(disp .No # Ic "cp *tgz /export/client/root" .No # Ic "gunzip netbsd.RAMDISK.gz" .No # Ic "mv netbsd.RAMDISK /export/client/root/netbsd" .disp)

p If you are running your \*M diskless, simply use

a binary/kernel/netbsd-GENERIC.gz . .\} If you are netbooting the installer, use

a binary/kernel/netbsd.GENERIC_MD.gz (this has the installation tools in a RAM disk). Also, copy the distribution files to the client's root directory.

p .(disp .No # Ic "cp *tgz /export/client/root" .No # Ic "gunzip netbsd.GENERIC_MD.gz" .No # Ic "mv netbsd.GENERIC_MD /export/client/root/netbsd" .disp)

p If you are running your \*M diskless, simply use

a binary/kernel/netbsd-GENERIC.gz . .\} Use

a binary/kernel/netbsd.GENERIC.gz .

p .(disp .No # Ic "gunzip netbsd.GENERIC.gz" .No # Ic "mv netbsd.GENERIC /export/client/root/netbsd" .disp) .\} Use

a binary/kernel/netbsd-GENERIC.gz ) .

p .(disp .No # Ic "gunzip netbsd-GENERIC.gz" .No # Ic "mv netbsd-GENERIC /export/client/root/netbsd" .disp)

p If you are netbooting the installer, copy the distribution files to the client's root directory and extract the tools from

a installation/netboot/rootfs.tgz .

p .(disp .No # Ic "cp *tgz /export/client/root" .No # Ic "cd /export/client/root" .No # Ic "tar -xpzf rootfs.tgz" .disp) .\} \" ! \n[sparc]

p t Client filesystem

p You can skip this step if you do not plan to run your client diskless after installation. Otherwise, you .\} need to extract and set up the client's installation of .Nx . The Diskless HOW-TO describes how to provide better security and save space on the NFS server over the procedure listed here. .Lk http://www.netbsd.org/Documentation/network/netboot/nfs.html .(bullet -compact Extracting distribution sets

p .(disp .No # Ic "cd /export/client/root" .No # Ic "tar -xpzf /path/to/files/base.tgz" .No # Ic "tar -xpzf /path/to/files/etc.tgz" .disp)

p Continue with the other non-essential distribution sets if desired.

p t Set up swap

p .(disp .No # Ic "mkdir /export/client/root/swap" .No # Ic "dd if=/dev/zero of=/export/client/swap bs=4k count=4k" .No # Ic "echo '/export/client/swap -maproot=root:wheel client.test.net' | cat \*>\*> /etc/exports" .No # Ic "/etc/rc.d/mountd restart" .disp) This creates a 16 MB swap file and exports it to the client.

p t Create device nodes

p .(disp .No # Ic "cd /export/client/root/dev" .No # Ic "./MAKEDEV all" .disp)

p This procedure only works on .Nx hosts.

p t Set up the client's .Xr fstab 5

p Create a file in

a /export/client/root/etc/fstab with the following lines:

p .(disp server:/export/client/swap none swap sw,nfsmntpt=/swap server:/export/client/root / nfs rw 0 0 .disp)

p t Set up the client's .Xr rc.conf 5

p Edit

a /export/client/root/etc/rc.conf .(disp rc_configured=YES hostname="client" defaultroute="192.168.1.1" nfs_client=YES auto_ifconfig=NO net_interfaces="" .disp)

p Make sure rc does not reconfigure the network device since it will lose its connection to the NFS server with your root filesystem.

p t Set up the client's .Xr hosts 5 file.

p Edit

a /export/client/root/etc/hosts

p .(disp ::1 localhost 127.0.0.1 localhost 192.168.1.10 client.test.net client 192.168.1.5 server.test.net server .disp) .bullet)

p t Setting up the server daemons

p these services to start up every time you boot your server, make sure the following lines are present in your

a /etc/rc.conf : .(disp rbootd=YES rbootd_flags="" .\} dhcpd=YES dhcpd_flags="-q" .\} rarpd=YES rarpd_flags="-a" .\} nfs_server=YES # enable server daemons mountd=YES rpcbind=YES rpcbind_flags="-l" # -l logs libwrap .disp)

p Also, you'll need to make sure the

a tftpd line in

a /etc/inetd.conf remains uncommented. .\} .enum)