[ath5k] Update for changes in kernel 2.6.31
[gpxe.git] / contrib / Diskless-From-NT / Diskless-From-NT.txt
blob54c2b746cda0a5f2a598990fb0e0437615f718d9
3 The Diskless Terminal running from NT server Mini-HOWTO
4 Pavel Tkatchouk, ptkatcho@portal.ca
5 v0.1, June 19th 1999
7 Table of Contents
9 1. Introduction.
11    1.1 What is it for?
12    1.2 Do we need this HOWTO?
13    1.3 A bit of History.
15 2. Project description.
17    2.1 Packaging.
18    2.2 Image.
19       2.2.1 Kernel.
20       2.2.2 MRFS.
21       2.2.3 Building MRFS.
22    2.3 Remotefs.
23    2.4 Booting sequence.
24       2.4.1 BOOTP, TFTP.
25    2.5 Bootprom.
27 3. Resources.
29 4. Copyright.
31 5. Feedback and credits.
34 1. Introduction.
37 1.1. What is it for?
39 This document describes how to build software distribution to run Java client on diskless 
40 terminal booted from Microsoft Windows 95/98/NT workstation. Package can also be easily 
41 modified to be used as Linux terminal or X Windows terminal's software. I found it also 
42 convenient for setup over the Ethernet of floppyless PS's, hard disk of which for some 
43 reason can not be accessed (sealed case under warranty, etc.).
46 1.2. Do we need this HOWTO?
48 To be honest, I'm not sure. There are few excellent HOWTO's (see 3. Recources) that up until 
49 recently I considered quite sufficient to build what I've done two years ago. But since my 
50 project uses MS Windows as a file server vs. traditional NFS there were some know-how's 
51 involved which number of people wanted to see in some formal document.
54 1.3. A bit of history.
56 My project at that time (1996) was to find OS/JVM that will allow to run Java application 
57 on hardware we manufacture. Hardware is practically generic x86 PC except it has no keyboard, 
58 hard drive, floppy drive, mouse, but touchscreen over LCD, plus some POS specific peripherals 
59 (badge reader, credit card reader, etc.). Due to cost consideration it had no any significant 
60 storage, so OS and Java client along with support binaries, libraries etc. had to be loaded 
61 remotely. Because our clients are exclusively Windows shops, Server had to be Windows as well. 
62 During evaluation of different commercial OS'es along with JVM's available it become apparent 
63 to my surprise that most promising solution was GPL one - Linux.
66 2. Project description.
68 2.1. Packaging.
70 The whole distribution consists of remote file system (RemoteFS) residing on MS Windows
71 server (NT Workstation, NT Server or Windows9x) and tagged bootable image. 
74 2.2. Image.
76 Image (~1.5MB) is generated by mknbi utility that comes with Etherboot package
77 <http://etherboot.sourceforge.net>. It can include minimal root file system (MRFS) 
78 like in my case (since I had to boot client from MS Windows server and Linux kernel doesn't 
79 support SMBFS-Root, only NFS-Root. So I had to keep rootfs in the ramdisk). To generate 
80 image the following script can be used.
82 #!/bin/sh
83 # mkrootnet: makes tagged netbootable image
84 # This image includes kernel and minimal root filesystem
85 # to do initial boot.
87 # Copyright (c) Pavel Tkatchouk 1996. All rights reserved.
88 # Permission is granted for this material to be freely
89 # used and distributed, provided the source is acknowledged.
90 # No warranty of any kind is provided. You use this material
91 # at your own risk.
93 DEVICEFILENAME="/tmp/file"              # temporary file to be used as device
94 FSBLOCKS=4096                                   # uncompressed filesystem size in K
95 BOOTDISKDIR="/usr/BOOT/ROOTFS"  # root filesystem model
96 MOUNT="/mnt2"                           # temporary mount point
97 ROOTFS="/tmp/rootfs"                    # root filesystem image
98 ROOTFSGZ="/tmp/rootfs.gz"               # compressed root filesystem image
99 KERNEL="/usr/KERNELS/vmlinuz-nt"        # kernel image
100 KERNELTMP="/tmp/vmlinuz"                # temporary copy of kernel image
101 BOOTIMAGE="/tmp/img"                    # tagged image to be booted by client
102 # if you want ramisk more than default 4096 set CMDLINE, don't forget to
103 # adjust $FSBLOCKS 
104 # CMDLINE="ramdisk_size=8192"           # parameters to pass to the kernel
106 echo "check:"
107 echo "- if tftp server's download dir mounted to /mnt"
108 echo "- loopback device is built-in or loaded"
109 echo "\n press Enter when done"
110 read tmp 
111 UPLOAD="/mnt/tmp"                               # tftp server's dir to upload bootimage
112 echo -e "\nZeroing $DEVICEFILENAME of $FSBLOCKS k"
113 echo "to be used as device for root filesystem model"
114 dd if=/dev/zero of=$DEVICEFILENAME bs=1k count=$FSBLOCKS
115 echo -e "\nMaking file system on $DEVICEFILENAME"
116 mke2fs -m 0 $DEVICEFILENAME
117 echo "Mounting $DEVICEFILENAME as a loopback device"
118 mount -o loop -t ext2 $DEVICEFILENAME $MOUNT
119 curdir=`pwd`
120 cd $BOOTDISKDIR
121 echo -e "Copying files from $BOOTDISKDIR to $DEVICEFILENAME, please wait"
122 find . -print|cpio -pmd $MOUNT
123 echo "Unmounting $MOUNT"
124 umount $MOUNT
125 cd $curdir
126 echo "Copying $DEVICEFILENAME to $ROOTFS"
127 dd if=$DEVICEFILENAME of=$ROOTFS bs=1k
128 echo "Compressing $ROOTFS, it may take a while"
129 echo "Please wait..."
130 if [ -f $ROOTFSGZ ];then
131         rm -f $ROOTFSGZ
133 gzip -c $ROOTFS>$ROOTFSGZ
134 rm -f $ROOTFS
135 echo -e "\nCreating netbootable image"
136 cp $KERNEL $KERNELTMP
137 mknbi -d ram -i rom -r $ROOTFSGZ -k $KERNELTMP -a $CMDLINE -o $BOOTIMAGE
138 echo "Uploading $BOOTIMAGE to $UPLOAD"
139 cp $BOOTIMAGE $UPLOAD
140 echo "Cleaning after ourselves"
141 rm -f $KERNELTMP $DEVICEFILENAME $BOOTIMAGE
142 echo "All done"
145 In the above script actual image is generated by the following comand
147 #mknbi -d ram -i rom -r rootfs.gz -k vmlinuz-nt -o img
149 where:
150         rootfs.gz - minimal root file system (MRFS);
151         vmlinuz-nt   - kernel;
152         img       - resulting image.
155 Note:
156 Default ramdisk size is 4096. It was enough for RedHat4.1 based minimal file system, but 
157 apparently not enough for 5.2 based. When this happens "end request:I/O error, dev 01:00 ..." 
158 error shows up. To fix that either use "mknbi -a ramdisk_size=8192" to pass parameter to the 
159 kernel (doesn't require kernel recompilation), or change /usr/src/linux/drivers/block/rd.c: 
160 int rd_size= from 4096 to 8192 or whatever and rebuild the kernel.                                                    
163 2.2.1. Kernel.
165 Kernels 2.0.30 and 2.0.36 have been used by author, although nothing is preventing you from
166 experimenting with others. Kernel should include ramdisk support. The following 
167 <link to .config> configuration has been used to build <link to binary (kernel 2.0.30)>. 
168 You may find some components unnecessary, just exclude them and rebuild. 
170 Don't forget to change root device after you built the kernel (rdev vmlinuz /dev/rd).
172 Gotcha's: apparently smbfs is broken in 2.2.x kernels. Symptoms: remote share is mounted
173 just fine but after a while fails with "smb_request: result = -32" errmsg. I've heard
174 SuSe has fix for that.
176 2.2.2. MRFS.
178 Minimal root file system is required to get Linux up and running along with networking until 
179 it can mount remote file system to run X/Java from there. After image gets loaded from the 
180 server MRFS is decompressed into ramdisk. If you can afford a lot of ram on your terminal the 
181 entire remote file system can be moved to rootfs.gz. That will make your terminal more 
182 responsive.
185 2.2.3. Building MRFS.  
187 Some folks found it easier to start from scratch, others use known "minimal" Linux distributions
188 (Linux Router, tomsrtbt, etc.), yet others prefer to start from "big" Linuces like I did. Every
189 path has it's pro and contras.
191 Pruning standard distribution (RedHat, Debian, etc.) to your needs might be very time consuming.
192 To ease that painful process I have used remotely booted diskless client with NFS-Root (see 
193 Etherboot's Readme, NFS-Root and NFS-Root-Client mini-HOWTO's, Diskless-HOWTO):
195 - setup minimal RedHat4.1 install (networked workstation, X, no development, mail, etc., ~117MB);
196 - find . -print|cpio -pmd /usr/NFS/ROOTFS - copy entire fs tree to NFS exported dir;
197 - mknod /usr/NFS/ROOTFS/dev/nfsroot b 0 255;
198 - build vmlinuz-nfs kernel according to NFS-Howto (built-in bootp,rarp,NFS,NFS root,NIC 
199   driver,RAM disk);
200 - rdev vmlinuz-nfs /dev/nfsroot - to set NFS root device; 
201 - build image for NFS-Root fs:
202   #mknbi -d rom -i rom -k vmlinuz-nfs -o nfsImage;
203 - boot client while monitoring NFS file requests (by Solaris snoop);
204 - copy files from /usr/NFS/ROOTFS to /usr/BOOT/ROOTFS (MRFS model) according to snoop's
205   filelist;
206 - generate image by mkrootnet script (don't forget to point to the right kernel vmlinuz-nt).
208 The above trick not only allows to determine the sought files set but also debug boot process 
209 analyzing NFS messages. I found it convenient to put "read tmp" statements into init scripts
210 for debugging. Tracking files up until issuing login gives you <link to rootfs.gz> MRFS (~1MB) 
211 that can be used to boot Linux from ROM (flash, eprom, DiskOnChip, SanDisk, etc.) as well. All 
212 the other files requested by client (during starting X, Java, Java client) were put into (link 
213 to remotefs.zip, ~9MB).
216 To restore MRFS model on your PC from the above rootfs.gz:
217 - #cd /tmp
218 - #gunzip rootfs.gz
219 - #mount -o loop -t ext2 /tmp/rootfs /mnt
220 - #cd /mnt
221 - #find . -print|cpio -pmd /usr/BOOT/ROOTFS
222 - #umount /mnt
224 Note: 
226 You will have to change attributes of some dirs, files (/etc/mtab, /etc/mtab~, /var/lock/subsys/*, 
227 /var/run/*, /dev/tty*, etc.) against standard. This is because with standard attribs diskless 
228 client refused to work. For example I had to change /dev/tty* ownerships to 99:99 from original 
229 0:0 or 0:5, to get rid of errmsg "INIT: Id "1" respawning too fast: disabled for 5 minutes". 
230 Being admin illiterate I just chmod them to 777 and chown to 99:99 to make life easier. 
231 THIS IS SERIOUS SECURITY VIOLATION!!! Using keyboardless terminal with no daemons running in 
232 my case reduces the risk, yet I would appreciate very much those more experienced who will help 
233 to restore the right attribs while keeping the distribution working.
235 Some "gotcha's" to watch for during MRFS building:
236 - standard attributes/ownership of some files don't work;
237 - rdev must be set (non-tagged image didn't work, so couldn't use config file to pass parrs 
238   to the kernel);
239 - diskless client writes 99:99 ownership on generated files;
240 - "password incorrect" for root, but any other OK and su OK too.
243 2.3. RemoteFS.
245 Remotefs.zip file includes everything required by the system that can be located on
246 remote file system, i.e after booting has been complete and remote file system mounted.
247 In my case it is X Windows System and Java binaries, libraries etc. To use that file on
248 MS Windows NT:
249 - unzip remotefs.zip to some directory;
250 - share this directory read-only as "usr" (or share as some other name and pass this name to
251   the client through bootptab configuration file for BOOTP server;
252 - create an account username=root, password=linux on NT (can be set in bootptab).
254 Note:
255 There's no symbolic links on NTFS, so UNIX links must be replaced by copies on NTFS. 
256 To determine potential troublmakers one could use the following:
257 - first copy required subset (according to snoop's intercept) from /usr/NFS/ROOTFS to 
258   /usr/BOOT/REMOTEFS;
259 - mount some share from NTFS to /mnt;
260 - /usr/BOOT/REMOTEFS#find . -print|cpio -pmd /mnt 2>links;
261 In the links file you will find names to work with.
264 2.4. Booting sequence.
266 Boot occurs in the following sequence:
267 - bootprom sends bootp request,
268 - bootp server responds with subnet mask, client's name, client's IP, TFTP server's IP, 
269   bootfile name and some optional parameters (like NT's username/password to use it's share,
270   you could pass some other share name here as say T104="somedir");
271 - bootprom downloads image from TFTP server;
272 - kernel starts;
273 - kernel decompresses MRFS in RAM;
274 - system starts init using ramdisk root,
275 - mounts remote file system from NT via SMBFS;
276 - automatically logins;
277 - starts xstart script located on remotefs (/usr/sbin) where you can start any of your
278   programs, change parameters, etc. without rebuilding the image.
280 Below are some config/init sample files from <rootfs.gz>, <remotefs.zip>:
282 <bootptab, change to link>
283 t1:sm=255.255.255.0:sa=192.168.33.150:bf=img:T100="pavelnt4":T101="root":T102="linux"
284 touch1:hn=touch1:tc=t1:ha=00A0F00035CD:ip=192.168.33.127
286 </etc/fstab, change to link>:
287 /dev/ram  /      ext2    defaults    1 1
288 /proc     /proc  proc    defaults    0 0
290 </etc/rc.d/rc.bootp, change to link later>:
291 #!/bin/sh
292 # Written to simply set the IP stuff up from the
293 # bootpc data.
294 # Last updated : Mon Mar 10 15:17:01 1997
296 # Variables
298 BOOTPC=/sbin/bootpc
299 IFCONFIG=/sbin/ifconfig
300 ROUTE=/sbin/route
301 BINHOST=/bin/hostname
302 DEV=eth0
303 ASKSERVER="255.255.255.255"
304 TW="--timeoutwait 320"
305 RIF="--returniffail"
306 RIFMESSAGE="Bootp failed -- disabling network."
307 RCONF=/etc/resolv.conf
308 EHOSTS=/etc/hosts
309 LHOSTS=/etc/hosts.local
310 TMPFILE=/tmp/bootp
311 # Functions
312 # Remove the networking by taking down the interface
313 netdown() {
314   ${ROUTE} del default
315   ${IFCONFIG} ${DEV} down
317 ## End of the functions
319 ## Start of the actual work
320 # Bring up minimal networking use 0.0.0.0 as our address as we don't
321 # know it yet (Means "Me but I don't know my address or network")
322 ${IFCONFIG} ${DEV} up 0.0.0.0
323 ${ROUTE} add default dev ${DEV}
325 # Perform the bootp  --  doesn't return unless it gets an answer
326 if ${BOOTPC} --dev ${DEV} --server ${ASKSERVER} ${RIF} ${TW} > ${TMPFILE}
327 then
328 # Take down networking (use the 0.0.0.0 for as short a time as possible)
329   netdown
330 # Read in the values   
331   . ${TMPFILE}
333 # To use in mountsmb script later
334 SMBSERVER=${T100}
335 # And delete the temporary file
336 #  rm ${TMPFILE}
337 else
338 # Take down networking (use the 0.0.0.0 for as short a time as possible)
339   netdown
340 # give message and quit
341   echo ${RIFMESSAGE}
342   exit 1
345 # Start the loopback interface and add a route to it
346 # It's already set by standard init?
347 ${IFCONFIG} lo 127.0.0.1
348 ${ROUTE} add -net 127.0.0.0
350 # Setup of IP stuff needs doing first
352 if [ -z "${NETMASK}" ] ; then
353 # No netmask info, all this is guessed from the IP number
354 # If this is wrong for your network FIX the bootpd to know
355 # what it should send in the RFC1497 cookie!  11/02/94 JSP
357   ${IFCONFIG} ${DEV} up ${IPADDR} broadcast ${BROADCAST} 
358   ${ROUTE} -n add -net ${NETWORK} dev ${DEV}
359 else
360 # We will have NETMASK, BROADCAST, and NETWORK defined 
361   ${IFCONFIG} ${DEV} up ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK} 
362   ${ROUTE} -n add -net ${NETWORK} dev ${DEV}
365 # Set the hostname from what we got via bootp or reverse lookup
367 echo "127.0.0.1 loopback localhost">${EHOSTS}
368 ${BINHOST} "${HOSTNAME}"
369 echo "${IPADDR} ${HOSTNAME}" >>${EHOSTS}
370 echo "${SERVER} ${SMBSERVER}" >>${EHOSTS}
373 </etc/rc.d/rc.local, change to link>:
374 #!/bin/sh
375 # This script will be executed *after* all the other init scripts.
376 # You can put your own initialization stuff in here if you don't
377 # want to do the full Sys V style init stuff.
379 # 07/02/97 Pavel Tkatchouk
381 echo "Start networking"
382 insmod /lib/8390.o
383 insmod /lib/ne.o io=0x300 irq=9
384 echo "Install serial"
385 insmod /lib/serial.o
386 echo "Install touch"
387 insmod /lib/touch.o
388 echo "Install smbfs"
389 insmod /lib/smbfs.o
390 echo "Getting TCP/IP parameters from bootp server"
391 echo "and start networking"
392 /etc/rc.d/rc.bootp
393 if [ -f /etc/squirrel-release ]; then
394         R=$(cat /etc/squirrel-release)
395 else
396         R="release 0.02"
398 echo "Mounting remote fs"
399 /sbin/mountsmb
400 echo "XYZ Inc. Diskless Linux $R"
401 echo "Starting X and Java client without login"
402 su -c /sbin/xstart root
405 </usr/sbin/xstart, change to link>:
406 #!/bin/bash
408 # Script to start X and Java client
409 # 08/07/97 Pavel Tkatchouk
411 # Read bootps response first
412 . /tmp/bootp
413 # -s 0 to disable screen-saver
414 /usr/X11R6/bin/X -s 0 &
415 export DISPLAY=:0.0
416 # /usr is share mounted from Windows workstation
417 cd /usr/program/
418 java SomeJavaApp 
421 </sbin/mountsmb, change to link>:
422 #!/bin/bash
423 # mountsmb: mounts remote filesystems from NT workstation 
424 # using Microsoft's SMB protocol 
426 # Copyright (c) Pavel Tkatchouk 1997. All rights reserved.
427 # Permission is granted for this material to be freely
428 # used and distributed, provided the source is acknowledged.
429 # No warranty of any kind is provided. You use this material
430 # at your own risk.
432 # Last edit June 29 8:30 1997
434 MOUNTDIR="usr"
435 SHRDIR="usr"
436 BOOTPRES="/tmp/bootp"
437 # Read botpc response
438 . ${BOOTPRES}
439 # Sharename from NT server, uncomment if you want to use 
440 # non-hardcoded "usr" but from bootptab
441 #SHRDIR=${T104} 
442 SMBSRV="//${T100}"
443 CLIENT="${HOSTNAME}"
444 USER="${T101}"
445 PASSWORD="${T102}"
446 echo -e "\nMounting $SMBSRV/$SHRDIR to /$MOUNTDIR"
447 smbmount $SMBSRV/$SHRDIR $MOUNTDIR -c $CLIENT -U $USER -P $PASSWORD
448 echo -e "\nDone"
450 Gotcha's:
451 Looks like smbmount client from smbfs package used to mount remote Windows shares to local 
452 Linux dirs in pre 2.2.x era isn't maintained anymore so you should use one coming with 
453 Samba package. Also binary smbmount won't work with 2.2.x, so you have to recompile with 
454 2.2.x headers following Samba's readme. Yet even that won't guarantee reliable work until
455 somebody fixes kernel's smbfs module.
457 2.4.1. BOOTP, TFTP.
459 There are number of BOOTP, TFTP servers for Windows on the market. You could find them
460 here:
462 - www.walusoft.co.uk (Walusoft's tftp);
463 - ftp.coast.net/simtel/nt/internet/tftpds12.zip (Millwood AB's tftp);
464 - ftp.cabletron.com/pub/snmp/bootftp/boottft2.zip (Cabletron's bootp/tftp combo);
465 - www.tellurian.au.com (Tellurian's bootp, tftp, dhcp servers).
466 - www.metainfo.com (Metainfo's DHCP server)
467 - www.nts.com (Network Telesystems's DHCP server in IPserver package)
469 My choice was Tellurian's products - very reliable, simple to install, attractively priced
470 (fully capable evaluation versions are available).
472 2.5. Bootprom.
474 Ken Yap's Etherboot <etherboot.sourceforge.net> will tell you everything about bootprom. 
475 Here I just want to mention that normally you would have to put bootprom's code into network
476 adapter's PROM. But if your hardware like mine has BIOS programmed in flash you could 
477 re-program it to add bootprom (some BIOS requires special programmer to do that, others don't)
478 as BIOS extension.
480 This is what I did to add ne.rom (bootprom generated by Etherboot's makerom for NE2000 clone) 
481 to AMI BIOS on my flash:
483 - read flash content by programmer into bios.bin binary file;
484 - use one of available binary editors (say www.simtel.net/Win95/editors/hxp3005.zip to add
485   ne.rom to bios.bin (and to edit ne.rom if necessary);
486 - write new bios.bin back to flash.
488 Notes:
489 - makerom generates bootprom for standard EPROM sizes (8k, 16k, 32k, etc.), so if you tight on 
490   space use -s flag to adjust size (or cut it manually to multiple of 512 bytes blocks, just
491   don't forget to adjust extension's length which is coded in Byte 2 and checksum to 8 bits 
492   of zero;
493 - valid absolute addresses for BIOS extensions are from 0xC8000 to 0xF4000 (check with 
494   motherboard's manufacturer how flash is mapped onto system memory space);
495 - Byte 0 must be 0x55, Byte 1 must be 0xAA, Byte 2 must be extension's length in 512 bytes 
496   blocks;
497 - extension BIOS has to start at a 2k boundary;
500 3. Resources.
502 FAQ's:
503 - tomsrtbt.FAQ (www.toms.net);
505 HOWTO's:
506 - Paul Moody's miniHOWTO (www.linuxembedded.com/pmhowto.html)
507 - Diskless;
508 - Diskless-HOWTO;
509 - NFS-Root;
510 - NFS-Root-Client;
511 - Bootdisk-HOWTO;
512 - BootPrompt-HOWTO;
513 - NCD-X-Terminal;
514 - Remote-Boot;
515 - Remote-X-Apps;
517 Web:
518 - etherboot.sourceforge.net/
519 - www.waste.org/~zanshin
520 - www.tellurian.com.au.
521 - www.toms.net
522 - www.trinux.org
523 - www.linux.org.uk/ELKS-Home
524 - www.embedded.com
525 - www.linuxembedded.com
526 - www.thinlinux.org
527 - www.linuxrouter.org
528 - linux-mandrake.com
529 - www.disklessworkstations.com
531 Newsgroups:
532 - comp.arch.embedded
534 Lists:
535 - netboot-owner@baghira.han.de
536 - linux-embedded@waste.org
538 Magazines:
539 - Circuit Cellar #100 - 105
542 4. Copyright.
544 Copyright (c) Pavel Tkatchouk 1999.
545 Permission is granted for this material to be freely used and distributed, provided the source 
546 is acknowledged. Copyright policy is GPL as published by the Free Software Foundation.
548 No warranty of any kind is provided. You use this material at your own risk.
552 5. Feedback and credits.
554 Since I am neither have a lot of Linux experience nor native English speaker, there would be 
555 errors in this document. I would accept any help with gratitude whether in form of proof-reading, 
556 techical corrections or otherwise. Please send your comments, suggestions and questions to Pavel 
557 Tkatchouk (ptkatcho@portal.ca)
559 I wish to thank Pierre Mondie who convinced me to start this document. I'm also very much in 
560 debt to all those who's work made this project possible:
562 Ken Yap                 <ken_yap@users.sourceforge.net> (Etherboot)
563 David Newall    <www.tellurian.com.au>  (Bootpdnt/Ftpdnt)
564 (to be continued)