Merge branch 'vendor/OPENBSD_LIBM'
[dragonfly.git] / share / examples / diskless / README.BOOTP
1 # $FreeBSD: src/share/examples/diskless/README.BOOTP,v 1.2.4.1 2002/02/12 17:43:11 luigi Exp $
2 # Notes on diskless boot.
3
4 IMPORTANT NOTE:
5
6 For quite some time
7 the /etc/rc.d/{initdiskless,diskless} scripts support a slightly different
8 diskless boot process than the one documented in the rest of this file.
9
10 I am not deleting the information below because it contains some
11 useful background information on diskless operation, but for the
12 actual details you should look at diskless(8), /etc/rc.d/initdiskless,
13 /etc/rc.d/diskless,
14 and the /usr/share/examples/diskless/clone_root script which can
15 be useful to set up clients and server for diskless boot.
16
17 -----------------------------------------------------------------------
18
19                         BOOTP configuration mechanism
20
21                             Matthew Dillon
22                             dillon@backplane.com
23
24     BOOTP kernels automatically configure the machine's IP address, netmask,
25     optional NFS based swap, and NFS based root mount.  The NFS server will
26     typically export a shared read-only /, /usr, and /var to any number of
27     workstations.  The shared read-only root is typically either the server's
28     own root or, if you are more security concious, a contrived root.
29
30     The key issue with starting up a BOOTP kernel is that you typically want
31     to export read-only NFS partitions from the server, yet still be able to
32     customize each workstation ( or not ).
33
34     /etc/rc.diskless1 is responsible for doing core mounts and for retargeting
35     /conf/ME ( part of the read-only root NFS mount ) to /conf/$IP_OF_CLIENT.
36     /etc/rc.conf.local and /etc/rc.local, along with other machine-specific
37     configuration files, are typically softlinks to /conf/ME/<filename>.
38
39     In the BOOTP workstation /conf/$IP/rc.conf.local, you must typically
40     turn *OFF* most of the system option defaults in /etc/rc.conf as well
41     as do additional custom configuration of your environment
42
43     The /usr/src/share/examples/diskless directory contains a typical
44     X session / sshd based workstation configuration.  The directories
45     involved are HT.DISKLESS/ and 192.157.86.12/. 
46
47     Essentially, the $IP/ directory ( which rc.diskless looks for in
48     /conf/$IP/ ) contains all the junk.  The HT.DISKLESS directory exists
49     to hold common elements of your custom configuration so you do not have
50     to repeat those elements for each workstation.  The example /conf 
51     structure included here shows how to create a working sshd setup ( so
52     you can sshd into the diskless workstation ), retarget xdm's pid and error
53     files to R+W directories if /usr is mounted read-only, and retarget
54     syslogd and other programs.  This example is not designed to run out of
55     the box and some modifications are required.
56
57     >> NOTE <<  HT.DISKLESS/ttys contains the typical configuration required
58     to bring X up at boot time.  Essentially, it runs xdm in the foreground
59     with the appropriate arguments rather then a getty on ttyv0.  You must
60     run xdm on ttyv0 in order to prevent xdm racing with getty on a virtual
61     terminal.  Such a race can cause your keyboard to be directed away from
62     the X session, essentially making the session unusable.
63
64     Typically you should start with a clean slate by tar-copying this example
65     directory to /conf and then hack on it in /conf rather then in 
66     /usr/share/examples/diskless.
67
68                                 BOOTP CLIENT SETUP
69
70     Here is a typical kernel configuration.  If you have only one ethernet
71     interface you do not need to wire BOOTP to a specific interface name.
72     BOOTP requires NFS and NFS_ROOT, and our boot scripts require MFS.  If
73     your /tmp is *not* a softlink to /var/tmp, the scripts also require NULLFS
74
75 # BootP
76 #
77 options         BOOTP           # Use BOOTP to obtain IP address/hostname
78 options         BOOTP_NFSROOT   # NFS mount root filesystem using BOOTP info
79 options         "BOOTP_NFSV3"   # Use NFS v3 to NFS mount rootoptions
80 options         BOOTP_COMPAT    # Workaround for broken bootp daemons.
81 #options         "BOOTP_WIRED_TO=de0"
82
83 options         MFS                     # Memory File System
84 options         NFS                     # Network Filesystem
85 options         NFS_ROOT                # Nfs can be root
86 options         NULLFS                  # nullfs to map /var/tmp to /tmp
87
88                                 BOOTP SERVER SETUP
89
90     The BOOTP server must be running on the same logical LAN as the
91     BOOTP client(s).  You need to setup two things:
92
93     (1) You need to NFS-export /, /usr, and /var.
94
95     (2) You need to run a BOOTP server.  DHCPD can do this.
96
97
98     NFS Export:
99
100         Here is an example "/etc/exports" file.
101
102 / -ro -maproot=root: -network 192.157.86.0 -mask 255.255.255.192
103 /usr -ro -maproot=root: -network 192.157.86.0 -mask 255.255.255.192
104 /var -ro -maproot=root: -network 192.157.86.0 -mask 255.255.255.192
105
106     In order to be an NFS server, the server must run portmap, mountd,
107     nfsd, and rpc.statd.  The standard NFS server options in /etc/rc.conf
108     will work ( you should put your overrides in /etc/rc.conf.local on the
109     server and not edit the distribution /etc/rc.conf, though ).
110
111     BOOTP Server:
112
113         This configuration file "/etc/dhcpd.conf" example is for 
114         the '/usr/ports/net/isc-dhcp' dhcpd port.
115
116             subnet 192.157.86.0 netmask 255.255.255.192 {
117                 # range if you want to run the core dhcpd service of
118                 # dynamic IP assignment, but it is not used with BOOTP 
119                 # workstations
120                 range 192.157.86.32 192.157.86.62;
121
122                 # misc configuration.
123                 #
124                 option routers 192.157.86.2;
125                 option domain-name-servers 192.157.86.2;
126
127                 server-name "apollo.fubar.com";
128                 option subnet-mask 255.255.255.192;
129                 option domain-name-servers 192.157.86.2;
130                 option domain-name "fubar.com";
131                 option broadcast-address 192.157.86.63;
132                 option routers 192.157.86.2;
133             }
134
135             host test1 {
136                 hardware ethernet 00:a0:c9:d3:38:25;
137                 fixed-address 192.157.86.11;
138                 option root-path "192.157.86.2:/";
139                 option option-128 "192.157.86.2:/images/swap";
140             }
141
142             host test2 {
143             #    hardware ethernet 00:e0:29:1d:16:09;
144                 hardware ethernet 00:10:5a:a8:94:0e;
145                 fixed-address 192.157.86.12;
146                 option root-path "192.157.86.2:/";
147                 option option-128 "192.157.86.2:/images/swap";
148             }
149
150     SWAP.  This example includes options to automatically BOOTP configure
151     NFS swap on each workstation.  In order to use this capabilities you
152     need to NFS-export a swap directory READ+WRITE to the workstations.
153
154     You must then create a swap directory for each workstation you wish to
155     assign swap to.  In this example I created a dummy user 'lander' and
156     did an NFS export of /images/swap enforcing a UID of 'lander' for
157     all accesses.
158
159         apollo:/usr/ports/net# ls -la /images/swap
160         total 491786
161         drwxr-xr-x  2 root    wheel        512 Dec 28 07:00 .
162         drwxr-xr-x  8 root    wheel        512 Jan 20 10:54 ..
163         -rw-r--r--  1 lander  wheel   33554432 Dec 23 14:35 swap.192.157.86.11
164         -rw-r--r--  1 lander  wheel  335544320 Jan 24 16:55 swap.192.157.86.12
165         -rw-r--r--  1 lander  wheel  134217728 Jan 21 17:19 swap.192.157.86.6
166
167     A swap file is best created with dd:
168
169         # create a 32MB swap file for a BOOTP workstation
170         dd if=/dev/zero of=swap.IPADDRESS bs=1m count=32
171
172     It is generally a good idea to give your workstations some swap space,
173     but not a requirement if they have a lot of memory.
174