Trinity Rescue Kit v 0.4 Development HOWTO (14-01-2002)

Ok, this is "the making of". It 's not really structured yet, sorry for that, it will change.

I 'm making this document because apparently several people who tried it have had some problems but want to help developing it.

Where to start.

Let 's talk about the tools I  used. I actually did everything from a Win2K station with VMWare 3.0 workstation. This was very handy to switch from devolepment platform to the actual bootcd. Also, I didn't have to create a new CD-rom: I just let VMWare boot from an iso-file. To create the ISOs, I used Nero Burning Rom. Although Nero doesn 't offer ISO to save to (only .nrg),  you can just enter .iso as extension and it 's workable.

What I did in Linux

There are a few tools that I used a lot, that is loopback filesystems, mount, lilo...

First thing I did was bake a new kernel with all that is disk controller compiled in.

Here's the .config file for the 2.4.17 kernel I created

After making a kernel, one has to have an initrd filesystem. This is your root filesystem from RAM, because one has to have a read-write filesystem and you can't have that from CD.

All this has to fit on a 2.88mb floppy, so this can be emulated on CD. This means not all files from TRK can fit on that and only stuff that is needed to boot and access the CD goes in there. All other things go on CD and are unpacked in the bootscripts.

Making the Kit

First, make a file that is exactly the size of a 2.88mb floppy

# dd if=/dev/zero of=/tmp/288dsk-2.4.17 bs=1k count=2880

Connect this file to a loopback device

# losetup /dev/loop0 /tmp/288dsk-2.4.17

Create a filesystem on it.

# mke2fs /dev/loop0

Mount it. I used /brol as mount point ("brol" means garbage in Flemish, when I first started with the kit, I was just experimenting and since then it has stayed on that mount point)

# mount /dev/loop0 /brol

Here 's a list of what this filesystem is made of eventually

It needs to consist of your kernel, the initrd image and a few lilo boot files

See that when you make a kernel, you make it with "make bzImage" to get maximum compression. Also compress the initrd image with "gzip --best"

After you 've created the 2.88mb boot floppy, you need a filesystem that will be your root filesystem after booting. Here 's how

# dd if=/dev/zero of=/tmp/initrd-2.4.17.img bs=1k count=18432

Connect the file to /dev/loop1

 # losetup /dev/loop1 /tmp/initrd-2.4.17.img

Make an ext2 filesystem on it. You need about 3500 inodes, so I created 4096

# mke2fs -N 4096 /dev/loop1

Mount it at /brol2 (or whatever you like)

files-on-initrd lists what files that have to be on it

Third, I made a file structure (linux/morebin.tgz) that is unpacked over the root after booting of the kernel in the rc.sysinit script.

This is how this structure looks like: files-on-morebin

The script that triggers the file untarring is "mountcd.sh":

#!/bin/bash
#set -x

# Check cd-rom drives in /proc/sys/dev/cdrom/info

cddrive=`cat /proc/sys/dev/cdrom/info | grep name | sed -e s'/drive name://'`
echo "CDdrives: $cddrive"
cdcount=`echo $cddrive | wc -w`
echo "$cdcount drive(s) found, looking for drive with Rescue CD"

for i in $cddrive;
do
if [ "TRK                             " == "`dd if=/dev/$i bs=1 skip=32808 count
=32 2>/dev/null`" ];
then mount -r -t iso9660 /dev/$i /cdrom
echo "Trinity Rescue Kit found in $cddrive, unpacking additional files";

else echo "Trinity Rescue Kit not found in $cddrive" >&2;
fi
done

cd /
tar xzf /cdrom/linux/morebin.tgz

The nifty part of the script is that it reads out /proc/sys/dev/cdrom/info where it then checks every cdrom with dd to see if the volume label matches. So should you want to change the volume label, be sure to also change it in this script.

morebin.tgz is created with the command

# tar czf morebin.tgz *

...from within the dir where I planted all my other files to populate the root with.

Before you run this script from /etc/rc.d/rc.sysinit (which is the first script init calls), be sure to mount /proc

...rc.sysinit
/bin/mount /proc
/etc/mountcd.sh 

At the end of rc.sysinit, I insert loading of the belgian keyboard

/bin/loadkeys azerty

One can always load another keyboard, I  made some short scripts to to that

be : loadkeys for Belgian keyboard
de : loadkeys for German keyboard
fr : loadkeys for French keyboard
uk : loadkeys for English keyboard
us : loadkeys for US keyboard

All other keyboards are included but have to be loaded with "loadkeys" command

Last thing that 's important is how to wrap it all up.

Once all the files are in place, umount /brol2

# umount /brol2

Then you must  unlink the file /tmp/initrd-2.4.17.img from it 's loopback device

# losetup -d /dev/loop1

After that, compress /tmp/initrd-2.4.17.img the best you can

# gzip --best initrd-2.4.17.img

Copy initrd.2.4.17.img.gz to /brol.
Copy also your kernel, vmlinuz-2.4.17 to /brol
See that /brol contains a boot.b file

Run lilo with this config file: lilo2.conf

# lilo -C /etc/lilo2.conf

Oh yeah. I created a custom boot message called trini.
It 's actually an 8bit paletted PCX file, 320x200 pixels.

 

That 's about the most you need to know about building/customizing TRK

Other scripts that are custom: /bin/findnic.sh, /bin/mountallfs.sh and /bin/virusscan.sh. You can check them out after you booted, they speak for themselves.

To create the ISO, I copy the files 288dsk-2.4.17 and morebin.tgz to a samba share on my Win2k workstation. I make sure morebin.tgz resides in the subdir linux/

In Nero, I create a bootable CD-Rom, with volume label TRK, boot floppy image 288dsk-2.4.17, emulating a 2.88mb floppy (no other parameters required) and I populate the disk with linux/morebin.tgz and linux/f-prot (f-prot is a big binary I linked to the CD so it doesn 't have to take up precious root space.)

Save the file as "all files" and give it extension .iso.

That 's about it

For further questions, mailto trk-at-telenet-dot-be.

You know how to fill in the email address, those !#X@{$µ harvester bots are already infesting me with spam. Should install a Webpoison, I know...