future of fai

Marc SCHAEFER alphanet-linux-fai at alphanet.ch
Fri Nov 22 15:55:36 CET 2002


On Thu, 21 Nov 2002, Thomas Lange wrote:

> - write a script that creates a bootable CD. I do not know if it's
>   possible to detect the name of the CD-ROM without using a
>   initrd. What if the computer has (several) IDE and SCSI CD-ROMs? The
>   CD should be made from an existing nfsroot on a fai server. I think
>   Niall Young will work on this.

Using the initrd from Debian Educ. There is much work here to make it
independant from the local config. On
http://search.alphanet.ch/~schaefer/FAI you will find other scripts, e.g. 
for kernel generation, creating a nfsroot as appropriate, etc. 

#! /bin/sh
# NOTES
#    - Assumes fai_install.sh successfully launched.
#    - Assumes fai_mkkernel.sh done.
#    - Uses the debian-educ CD-ROM idea, but with a floppy, just
#      for configuration.
# BUGS
#    - Cleanup (trap?)
#    - Missing CD-ROM creator, ID, etc.
#    - Missing documentation/license/etc
#    - Maybe someone has installed a kernel package already in
#      /usr/lib/fai/nfsroot.
# TODO
# $Id: fai_mkcdrom.sh,v 1.9 2002/08/06 14:23:20 schaefer Exp $

function fail {
   echo "$0: ERROR: $*" >&2
   exit 2
}

KERNEL_VERSION=2.4.18
KERNEL_REVISION=fai+nf+inst.0
KERNEL_ARCH=i386
KERNEL_DEB=../kernels/kernel-image-${KERNEL_VERSION}_${KERNEL_REVISION}_${KERNEL_ARCH}.deb

if [ $# -lt 1 ]; then
   echo "$0 iso_9960_file {package_list}"
   echo "$0: bad args." >&2
   exit 2
fi

#CD_TMP_DIR=/tmp/cd_$$
CD_TMP_DIR=/scratch/cd_$$
mkdir $CD_TMP_DIR || fail "creating temp directory"

cp -a /usr/lib/fai/nfsroot $CD_TMP_DIR/live || fail "copying nfsroot"

# NOTES
#    - Unmodified.
cp -a /usr/share/fai/templates/. $CD_TMP_DIR/live/fai || fail "copying FAI config"

# NOTES
#    - We don't run depmod -a since kernel is not the same.
cp $KERNEL_DEB $CD_TMP_DIR/live || fail "copying $KERNEL_DEB"
chroot $CD_TMP_DIR/live \
   sh -c "env DEBCONF_FRONTEND=noninteractive dpkg -i `basename $KERNEL_DEB`" \
   || fail "installing $KERNEL_DEB to live fs"
rm $CD_TMP_DIR/live/`basename $KERNEL_DEB` || fail "removing kernel package"

cp -a ../boot-images/cdrom-2880.img $CD_TMP_DIR \
  || fail "copying boot image"

cp -a ../ADDITIONAL_FAI_CONFIG/. $CD_TMP_DIR/live/fai \
  || fail "copying additional FAI config"

mount $CD_TMP_DIR/cdrom-2880.img -o loop /mnt  || fail "mounting boot image"
rm -f /mnt/*.cfg /mnt/*.s16 \
   && cat > /mnt/syslinux.cfg << EOF
default linux
append initrd=initrd.gz ramdisk_size=8192 root=/dev/ram0 init=/linuxrc rw
display faiinst.txt
prompt 1
EOF
if [ $? != 0 ]; then
   umount /mnt
   fail "preparing boot image (step 1)"
fi

sed 's/$//' > /mnt/faiinst.txt <<EOF

                   FAI boot/installation CD-ROM
                      <schaefer at alphanet.ch>

WARNING: this will automatically repartition and initialize disks!
         THIS COULD CAUSE DATA LOSS.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

This uses Linux $KERNEL_VERSION ($KERNEL_ARCH; $KERNEL_REVISION)
(CD-ROM generated on `date` by $LOGNAME@`hostname --fqdn`)

Please type RETURN if you want to reinstall this system (loosing
all data).

EOF
if [ $? != 0 ]; then
   umount /mnt
   fail "preparing message"
fi

DEST=/mnt/linux
cp $CD_TMP_DIR/live/vmlinuz $DEST
if [ $? != 0 ]; then
   umount /mnt
   fail "copying kernel"
fi

RDEV=/usr/sbin/rdev

$RDEV -R $DEST 1 \
   && $RDEV -r $DEST 0 \
   && $RDEV -v $DEST -1 \
   && $RDEV $DEST /dev/ram0
if [ $? != 0 ]; then
   umount /mnt
   fail "configuring kernel with rdev"
fi

umount /mnt || fail "unmounting /mnt"

if [ $# = 2 ]; then
   ./fai_create_package_directory.sh $CD_TMP_DIR/packages $2 \
      || fail "creating package directory"
fi

mkisofs -r -o $1 -b cdrom-2880.img $CD_TMP_DIR \
   || fail "creating ISO9660/Rock Ridge/El Torito image"

rm -rf $CD_TMP_DIR




More information about the linux-fai mailing list