DESCHALL Linux Bootdisk mini-HOWTO

Stuart Stock (stuart@gundaker.com)
Thu, 1 May 1997 17:05:01 -0500 (CDT)


DECHALL Linux bootdisk mini-HOWTO
v0.01 ALPHA! - May 1 1997
Stuart Stock
This document is distributed under the GPL

0.0 COPYRIGHT AND LEGAL CLUTTER
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------------------------------
DISCLAIMER: Your mileage may vary. This works for me but if it
blows your machine up it's not my fault. I have tried to assemble
accurate instructions on how to do this, but bear in mind this is a
rushed job and intended as a guideline only. This information is
provided free of charge and comes with no warranty! All
responsibility lies with the user of this document. The author
disclaims any and all responsibility for damages arising from the
use or misuse of the provided information.
------------------------------------------------------

This document is Copyright (c) 1997 Stuart Stock. It is distributed
under the GNU Public License. Everyone is permitted to make verbatim
copies of this document. Changing it is not allowed.

New versions will be posted to the deschall mailing lists as they become
available. If you find an error, or have a suggested improvement, please
mail stuart@gundaker.com.

IF YOU HAVE PROBLEMS: I'm sorry, but I will not be able to help you
with problems you might have. There is a wealth of information in the
Linux Documentation Project HOWTO's and FAQ's as well as the Cramdisk
docs. Please consult those, this is something I'm doing in my (very
limited) spare time.

0.1 PURPOSE
~~~~~~~~~~~
There have been a number of requests for a Linux boot disk to use at
night on spare machines. This document will provide instructions on
how to create a customized boot disk for your site. These instructions
are NOT for the newbie. You must be comfortable with manipulating disk
partitions, modifying system startup files, and configuring network
devices. Once you are done, you will have a bootdisk that supports any
network (Ethernet and PPP), SCSI, or other devices needed to boot the
system correctly.

Right now, there are no pre-made generic bootdisks. I haven't taken
a look at Cramdisk's license to see if that would be permitted (it's
GPL'ed so I imagine it would be okay). If there is a demand, I will
make some generic bootdisks available if someone will provide a FTP
site.

1.0 INTRO
~~~~~~~~~
The disk you are going to create is made possible by the really
excellent Cramdisk RAM disk loader. Please take a look at the READMEs
in the cramdisk distribution for information on the authors and MUCH
more detailed instructions than I can provide here. If you get
confused by my instructions, take a look at the cramdisk documentation.

You'll need the following:

- A Linux 2.X.X box that you have root permission on
- A 3.5" floppy drive
- Kernel source and gcc
- A spare disk partition (see the info below)
- cramdisk-2.0.8MB.net.tgz from Sunsite or a mirror
ftp://sunsite.unc.edu/pub/Linux/system/recovery/images/

Note - The cramdisk image that we will be modifying assumes that the
client machine has at least 8MB of memory. I have yet to meet a
Pentium with 4 megs, but you can try the 4MB cramdisk image file if you
want. I haven't used it and don't know if it will work.

2.0 LET'S DO IT
~~~~~~~~~~~~~~~

------------------------------------------------------------------
2.0.1 - Find an extra partition
------------------------------------------------------------------

This is the trickiest step of the whole process. The cramdisk image,
cramdisk.8MB, is a complete compressed filesystem. To modify it, it
needs to be decompressed to a drive partition and mounted as a normal
filesystem. The partition only needs to be 4 megs or so. I suggest
the following:

- If you have multiple swap partitions, unmount one and use it
temporarily.
- If you don't mind the hassle, boot to DOS and use FIPS
- If you have plenty of real memory, unmount your current swap
partition temporarily.
- Donate that old FAT partition running Windoze ;-)
- If you can suffer with a little less memory for a few minutes,
create a 4MB ramdisk.

*** WARNING: The partition you choose will be ERASED COMPLETELY ***
*** ANY DATA ON THE PARTITION IS LOST FOREVER!!! ***

Using a swap partition works great. You won't even have to change the
partition type in fdisk. Just remember to run mkswap and swapon after
you're all done to re-enable your swap space. Note: You'll have to
specify the blocksize of the partition to mkswap when you recreate it.
Get that info from fdisk.

You do not need to create a file system on the spare partition. Just
allocate it for now.

------------------------------------------------------------------
2.0.2 - Extract the files
------------------------------------------------------------------

After you have downloaded cramdisk-2.0.8MB.net.tgz make a temporary
directory and extract the files. Change to the cramdisk directory and
it should look like this:
# ls -l
total 1507
-rw-r--r-- 1 root root 9324 Oct 19 1996 README.howto
-rw-r--r-- 1 root root 7043 Oct 19 1996 README.what2mod
-rw-r--r-- 1 root root 42587 Oct 19 1996 cramdisk-2.0.tgz
-rw-r--r-- 1 root root 1474560 Oct 19 1996 cramdisk.8MB

extract the cramdisk-2.0.tgz file also:
# ls -l
total 1606
-rw-r--r-- 1 root root 17976 Oct 17 1996 COPYING
-rw-r--r-- 1 root root 9324 Oct 19 1996 README.howto
-rw-r--r-- 1 root root 15524 Oct 17 1996 README.orig
-rw-r--r-- 1 root root 7043 Oct 19 1996 README.what2mod
-rw-r--r-- 1 root root 3497 Oct 17 1996 config.cram.net
-rw-r--r-- 1 root root 3335 Oct 17 1996 config.cram.ppa
-rw-r--r-- 1 root root 42587 Oct 19 1996 cramdisk-2.0.tgz
-rw-r--r-- 1 root root 1474560 Oct 19 1996 cramdisk.8MB
-rwxr-xr-x 1 root root 623 Oct 7 1996 cramon
-rw-r--r-- 1 root root 4855 Oct 19 1996 filelist.8MB
-rw-r--r-- 1 root root 4748 Oct 19 1996 filelist.lynx
-rw-r--r-- 1 root root 4581 Oct 19 1996 filelist.net
-rw-r--r-- 1 root root 4428 Oct 18 1996 filelist.ppa
-rwxr-xr-x 1 root root 1618 Oct 19 1996 make2fsz
-rwxr-xr-x 1 root root 560 Oct 19 1996 makedist.8MB
-rwxr-xr-x 1 root root 555 Oct 19 1996 makedist.lynx
-rwxr-xr-x 1 root root 560 Oct 19 1996 makedist.net
-rwxr-xr-x 1 root root 565 Oct 19 1996 makedist.ppa
-rwxr-xr-x 1 root root 1589 Oct 7 1996 makefsz
-rw-r--r-- 1 root root 8232 Oct 7 1996 ramdisk.txt
-rwxr-xr-x 1 root root 872 Oct 7 1996 readfsz
-rw-r--r-- 1 root root 13248 Oct 17 1996 tzx100.tgz
-rwxr-xr-x 1 root root 1085 Oct 7 1996 writefsz

------------------------------------------------------------------
2.0.3 - Build a custom kernel (if needed)
------------------------------------------------------------------

The stock cramdisk image comes with support for ppp, 3c509, and
NE2000 network cards. If your client uses PPP or a 3Com or NE2000
compatible network card, skip to the next section (2.0.4).

Otherwise, before you get busy with the next few steps, start the
compile of your custom kernel. If you don't know how to compile a
kernel, consult the Kernel-HOWTO.

** Make sure to add RAM Disk support **

Initial RAM disk support (initrd) is not needed, just the regular
stuff. Include all drivers you need for the proper operation of your
clients, but don't over do it! Keep the kernel as small as possible
(sorry, soundcard support is out ;-).

------------------------------------------------------------------
2.0.4 - Write the stock image to a floppy
------------------------------------------------------------------

Find yourself a FORMATTED, ERROR-FREE diskette and do a

# cat cramdisk.8MB > /dev/fd0

------------------------------------------------------------------
2.0.5 - Extract the kernel image from the floppy
------------------------------------------------------------------

Keep the floppy in the drive and do a

# dd if=/dev/fd0 of=zImage bs=1 count=386393

You now have the stock kernel laying in the current directory as
zImage.

------------------------------------------------------------------
2.0.6 - Extract the compressed filesystem to the partition
------------------------------------------------------------------

Got that partition ready? Good, keep the floppy in the drive and do

# readfsz - | gzip -d > /dev/hda?

Where /dev/hda? is the name of your unmounted spare partition. Could
be /dev/sda3, could be /dev/hdc5, I dunno. If you don't understand
this part, you probably want to STOP NOW because you could overwrite
your entire Linux box if you don't know what you're doing.

------------------------------------------------------------------
2.0.7 - Mount the filesystem and start editing
------------------------------------------------------------------

Now the cool stuff. Mount your new partition:

# mount /dev/hda? /mnt

Again /dev/hda? is your partition's name and /mnt is the mount-point
you've picked. Change directory to /mnt and take a look:
# ls -l
total 28
drwxr-xr-x 2 root bin 1024 Oct 19 1996 bin
drwxr-xr-x 2 root root 3072 Mar 24 1996 dev
drwxrwxrwx 2 root root 1024 Mar 21 1995 dos
drwxr-xr-x 5 root root 1024 Oct 19 1996 etc
drwxrwxrwx 2 root root 1024 Mar 21 1995 hd
drwxr-xr-x 5 root root 1024 Oct 15 1996 home
drwxr-xr-x 2 root root 1024 Oct 19 1996 lib
drwxr-xr-x 2 root root 12288 Apr 12 12:09 lost+found
drwxr-xr-x 2 root root 1024 Apr 18 1994 mnt
dr-xr-xr-x 2 root root 1024 Apr 18 1994 proc
drwxr-xr-x 2 root root 1024 Oct 19 1996 root
drwxr-xr-x 2 root bin 1024 Oct 17 1996 sbin
drwxrwxrwt 2 root root 1024 Oct 15 1996 tmp
drwxr-xr-x 6 root root 1024 Mar 23 1996 usr
drwxr-xr-x 6 root root 1024 Feb 18 1995 var

Your own new filesystem! Edit away. I've changed the following things
on our site's disks:

- Network interfaces (eth0) are NOT configured in
/etc/rd.d/rc.inet1
- Added domain and nameserver IPs to /etc/resolv.conf
- Because we don't use PPP, removed all the PPP related
files from /usr/bin to save space
- Added DESCHALL clients to /usr/bin

You get the idea. If you need to add additional files, you have
about 200Kb slack space to work with.

------------------------------------------------------------------
2.0.8 - Create a configuration strategy
------------------------------------------------------------------

So now that you have this filesystem, how are you going to configure
the network and get the DESCHALL client going once it's booted? As
shown above, I don't start the network interfaces at boot-time.
Instead, I have a modified Slackware rc.inet1 script I run from the
command line do it for me:

----------------------------- BEGIN SCRIPT ---------------------------
#!/bin/sh
#

echo "configuring client with IP of $1"
echo "setting hostname to $2"

/sbin/ifconfig lo 127.0.0.1
/sbin/route add -net 127.0.0.0

NETMASK="255.255.255.0" # REPLACE with YOUR netmask!
NETWORK="192.168.1.0" # REPLACE with YOUR network address!
BROADCAST="192.168.1.255" # REPLACE with YOUR broadcast address!
GATEWAY="192.168.1.254" # REPLACE with YOUR gateway address!

/sbin/ifconfig eth0 $1 broadcast ${BROADCAST} netmask ${NETMASK}

/sbin/route add -net ${NETWORK} netmask ${NETMASK}
/sbin/route add default gw ${GATEWAY} metric 1

/bin/hostname $2

/usr/bin/deschall-linux-P5 keymaster.verser.frii.com &

# end of script
----------------------------- END SCRIPT ------------------------------

As you can see there is no error checking, so you might want to
consider a more robust script than mine.

Edit the filesystem to suit your connection needs. Maybe that means
configuring PPP dial scripts, maybe that means configuring the client
to use DHCP. It's up to you. Almost all of the standard Linux system
utilities are present, and you can always copy some over.

You may also statically configure a disk with the rc.inet1 script
provided with cramdisk if you only have one host you need to boot.

Another good idea would be to compile FAT/FAT32 filesystem support
into your custom kernel and run your config script from a DOS/Win95
hard drive mounted at startup. You would have to edit the file once on
each machine, but after that, bootup on the floppy is hands-free.

------------------------------------------------------------------
2.0.9 - Finally, create the disk
------------------------------------------------------------------

Place the kernel you intend to use in the cramdisk directory and name
it zImage (suprise suprise). Place an ERROR-FREE FORMATTED floppy in the
drive and:

# dd if=zImage of=/dev/fd0 bs=20b
# umount /mnt <-- or whatever mount-point you chose
for your partition
# make2fsz /dev/hda? - 2200 | writefsz -

Bingo. You now have your custom boot disk.

3.0 NOW WHAT?
~~~~~~~~~~~~~
------------------------------------------------------------------
3.0.1 - Usurping cycles overnight
------------------------------------------------------------------

The cramdisk image comes configured with 2 virtual consoles
(adjustable of course). I like to start DESCHALL on one, flip over to
the other console and set a delayed reboot:

# sleep 25200; shutdown -r -t3 now

That will reboot the machine in 7 hours. Pop out the bootdisk, and
walk away. In the morning the user will be greeted with the normal
login or desktop screen they are used to.

------------------------------------------------------------------
3.0.2 - Duplicate your disk
------------------------------------------------------------------

Easy. Follow the procedure in section 2.0.9 or pop in the newly
created bootdiskette and:

# cat /dev/fd0 > ./bootdisk.image

Now pop in a new ERROR-FREE FORMATTED diskette and

# cat ./bootdisk.image > /dev/fd0

------------------------------------------------------------------
3.0.3 - PCMCIA Support
------------------------------------------------------------------

I see no reason why you couldn't enable PCMCIA support. You'll have
to strip as many unnecessary files from the cramdisk filesystem as
possible to accommodate the modules and module utilities but it
certainly could be done.
If anyone does this, please mail me so I can include the instructions
in the next version of this mini-HOWTO. Plentiful

4.0 THAT'S ALL
~~~~~~~~~~~~~~
Good luck and may your cycles be optimal.

--
Stuart Stock				       stuart@gundaker.com
Systems/Security Administrator		       http://www.gundaker.com
Gundaker Realtors			       "If Windows is the answer,
                                                it was a stupid question."
 
 Got a computer?  Help crack DES!  http://www.frii.com/~rcv/deschall.htm