IMHO, it also doesn't make sense to use a Minix file system for booting.
You do save a few bytes on the boot floppy, but the ext2 overhead seems
compressible and the Minix file system code then lies around in memory
doing nothing.
This is the script I'm using to build a complete boot floppy. Actually, a
bunch of boot floppies. Adapt to taste.
#!/bin/sh
PATH=/usr/src/BUILD/bin:/usr/sbin:/sbin:$PATH
usage() {
cat >&2 <<END
Usage: $0
[ -f | -F /dev/fd0 | -I(mage) ]
[ -s ramdisksize ] [ -S imagesize ]
[ -l(ilo) ] [ -v Kernelversion ]
[ -n(et) -d(ebug) -w X (serial wire X, usually 1) ]
[ -r(un without stop in linuxrc) ]
kernel (smurf, test, ...)
END
exit 1
}
cd /usr/src || die "No sources"
if test $# -eq 0 ; then usage ; fi
size=4500
imgsize=1440
fifo=/tmp/pipe.$$
fd=
run=
net=
ver=
debug=
serial=
if test -f BUILD/done/kernel:lilo ; then
wherelilo=done
else
wherelilo=legacy
fi
set -- $(getopt dfF:Ilns:S:rv: $*)
if test $? != 0
then
usage
fi
for i
do
case "$i"
in
-w)
serial=$2; shift; shift;;
-d)
debug=y; shift;;
-I)
fd=IMAGE; shift;;
-F)
fd=$2; shift; shift;;
-v)
ver=$2; shift; shift;;
-f)
fd=/dev/fd0; shift;;
-r)
run=y; shift;;
-S)
imgsize=$2; shift; shift;;
-s)
size=$2; shift; shift;;
-n)
net="net-"; shift;;
-l)
lilo=y; shift;;
--)
shift; break;;
esac
done
if test -z "$1"; then usage; fi
sys=$1
disk=/tmp/disk-$sys
diskfile=/tmp/diskfile-$sys
set -e
if test -z "$ver" ; then
rm -f $fifo; mkfifo $fifo
( cd /lib/modules-$sys; /bin/ls -r1 | while read a ; do if test -d $a; then echo $a; fi; done > $fifo ) &
read ver <$fifo ; rm $fifo
fi
if test "$fd" = "IMAGE" ; then
fd=/boot-$sys/floppy-$net$ver
fi
echo 'Unmounting..?'
umount $disk || true
rm -rf $disk $diskfile
dd bs=1024 count=$size if=/dev/zero of=$diskfile
yes y | /sbin/mkfs -t ext2 $diskfile $size
mkdir $disk
echo Mounting disk file
mount -t ext2 -o loop $diskfile $disk
while read a ; do echo /$a; mkdir $disk/$a; done <<END
bin
dev
etc
etc/terminfo
lib
mnt
mnt1
mnt2
mnt3
proc
sbin
usr
usr/lib
usr/sbin
cd
var
var/run
END
if test -n "$net" ; then ## Netz
cpio -pvd $disk <<END
/sbin/route
/sbin/ifconfig
/usr/sbin/portmap
/usr/sbin/rpc.mountd
/usr/sbin/rpc.nfsd
/lib/libnss_files-1.97.so
/lib/libnss_files.so.1
END
echo 'hosts: files' >$disk/etc/nsswitch.conf
else
cpio -pvd $disk <<END
/sbin/fdisk
/sbin/fs/mkfs.ext2
/sbin/fs/fsck.ext2
/sbin/swapon
/sbin/mkswap
/sbin/update
END
fi
cpio -pvd $disk <<END
/bin/ls
/bin/ln
/bin/cat
/bin/cp
/bin/rm
/bin/mv
/bin/mount
/bin/umount
/sbin/insmod
/sbin/ldconfig
END
find $disk/bin $disk/sbin -type f -print|xargs strip
cpio -pvd $disk <<END
/dev/zero
/dev/null
/dev/tty
/dev/tty1
/dev/ttyS0
/dev/ttyS1
/dev/sda
/dev/sda1
/dev/sda2
/dev/sda3
/dev/sda4
/dev/sda5
/dev/sda6
/dev/sda7
/dev/sda8
/dev/sdb
/dev/sdb1
/dev/sdb2
/dev/sdb3
/dev/sdb4
/dev/sdb5
/dev/sdb6
/dev/sdb7
/dev/sdb8
/dev/sdc
/dev/sdc1
/dev/sdc2
/dev/sdc3
/dev/sdc4
/dev/sdc5
/dev/sdc6
/dev/sdc7
/dev/sdc8
/dev/sdd
/dev/sdd1
/dev/sdd2
/dev/sdd3
/dev/sdd4
/dev/sdd5
/dev/sdd6
/dev/sdd7
/dev/sdd8
/dev/fd0
/dev/fd1
/dev/scd0
/etc/fstab
END
mkdir -p $disk/etc/terminfo/l
cp -v /usr/lib/terminfo/l/linux $disk/etc/terminfo/l
(
(
if test -f BUILD/out/gnu:libc ; then
cat BUILD/out/gnu:libc
else
cat <<END
/lib/ld.so.1
/lib/libc-1.97.so
/lib/libc.so.6
END
fi
cat BUILD/out/gnu:readline
cat BUILD/out/lib:ncurses
cat BUILD/out/lib:shadow
) | grep ^/lib/ |
while read a ; do
if test -L $a ; then
echo $a
elif test -f $a ; then
b=/tmp/$$.$(basename $a)
cp -a $a $b
ls -l $b >&2
strip --strip-debug $b || true
ls -l $b >&2
cp -a $b $disk/$a
rm $b
else
echo $a
fi
done
grep ^/bin/ < BUILD/out/gnu:bash
) | cpio -pvd $disk
cat <<END > $disk/etc/ld.so.conf
/lib
/usr/lib
/cd/lib
/cd/usr/lib
/cd/usr/X11R6/lib
/mnt/lib
/mnt/usr/lib
END
sync
echo ldconfig ...
LD_PRELOAD="" chroot $disk /sbin/ldconfig -v
mkdir $disk/modules
if test -n "$net" ; then ## Netz
while read a ; do
if test -f /lib/modules-$sys/$ver/$a ; then
b=/tmp/$$.$(basename $a)
cp -a /lib/modules-$sys/$ver/$a $b
ls -l $b >&2
strip --strip-debug $b || true
ls -l $b >&2
cp -a $b $disk/modules/$(basename $a)
rm $b
fi
done <<END
net/3c503.o
net/3c507.o
net/3c509.o
net/3c59x.o
net/8390.o
net/eepro.o
net/eexpress.o
net/ewrk3.o
net/ne.o
net/wd.o
net/de4x5.o
net/depca.o
net/smc-ultra.o
net/smc9194.o
net/tulip.o
fs/nfs.o
block/floppy.o
END
else ## kein Netz
while read a ; do cp -v /lib/modules-$sys/$ver/$a $disk/modules || true; done <<END
scsi/scsi_mod.o
scsi/aha1542.o
scsi/53c7,8xx.o
scsi/aha152x.o
scsi/aic7xxx.o
scsi/sd_mod.o
scsi/sr_mod.o
fs/isofs.o
block/floppy.o
fs/binfmt_aout.o
END
fi
ln -s /proc/mounts $disk/var/run/mtab
echo ">> $disk/linuxrc"
cat <<END >$disk/linuxrc
#!/bin/sh
set -xv
PATH=/bin:/sbin
END
if test -z "$serial" ; then
echo "exec </dev/tty1 >/dev/tty1 2>&1" >>$disk/linuxrc
else
echo "exec </dev/ttyS$serial >/dev/ttyS$serial 2>&1" >>$disk/linuxrc
fi
cat <<END >>$disk/linuxrc
echo "Dies ist die Bootdiskette für $sys..."
> /etc/mtab
END
if test -n "$net" ; then
cp /usr/src/BUILD/bin/doinstall.1 $disk/bin/install
cat <<END >>$disk/linuxrc
insmod /modules/8390.o
insmod /modules/ne.o io=0x300
insmod /modules/wd.o io=0x240
insmod /modules/nfs.o
END
else ## kein Netz
cat <<END >>$disk/linuxrc
insmod /modules/scsi_mod.o
insmod /modules/53c7,8xx.o
insmod /modules/aha1542.o
insmod /modules/aic7xxx.o
insmod /modules/aha152x.o
insmod /modules/sd_mod.o
insmod /modules/floppy.o
insmod /modules/binfmt_aout.o
END
fi
cat <<END >>$disk/linuxrc
mount -n /proc
echo 0x801 >/proc/sys/kernel/real-root-dev
END
if test -z "$run" ; then
cat <<END >>$disk/linuxrc
/bin/sh -i
END
fi
cat <<END >>$disk/linuxrc
umount -n /proc
END
chmod +x $disk/linuxrc
du -s $disk/.
if test -n "$debug" ; then
echo "disk ready for compressing."
( cd $disk; /bin/sh -i )
fi
echo Unmounting disk file
umount $disk
sync
if test -n "$fd" ; then
dest=/tmp/cdisk.$$
else
dest=/boot-$sys/disk-$net$ver
fi
echo "Compressing $diskfile ($disk) to $dest"
gzip < $diskfile > $dest &
if test -n "$fd" ; then
sleep 1
if test -b "$fd" ; then
echo /sbin/fs/mkfs.ext2 -i 50000 $fd $imgsize
/sbin/fs/mkfs.ext2 -i 50000 $fd $imgsize
mount -t ext2 $fd $disk
else
dd bs=1024 count=$imgsize if=/dev/zero of=$fd
echo /sbin/fs/mkfs.ext2 -i 50000 $diskfile $imgsize
yes y | /sbin/fs/mkfs.ext2 -i 50000 $diskfile $imgsize
mount -t ext2 -o loop $fd $disk
fi
while read a ; do echo /$a; mkdir $disk/$a; done <<END
boot
dev
etc
END
(
grep ^/boot/ < BUILD/out/kernel:lilo | fgrep -v .old
cat <<END
/dev/null
/dev/fd0
END
) | cpio -pvd $disk
echo $disk/boot/message
cat <<END >$disk/boot/message
Dies ist die Bootfloppy fuer $sys, Kernel $ver.
Erstellt via Buildsystem: $(date)
END
if test -n "$net" ; then
echo "Konfiguration: NETZ."
else
echo "Konfiguration: STANDARD."
fi >>$disk/boot/message
echo $disk/etc/lilo.conf
cat <<END >$disk/etc/lilo.conf
boot = /dev/fd0
install = /boot/boot.b
compact
delay = 10
read-only
END
if test -n "$serial" ; then
cat <<END >>$disk/etc/lilo.conf
append="ramdisk=$size console=$serial,9600 reboot=hard,bios"
serial = 1,9600n8
END
else
cat <<END >>$disk/etc/lilo.conf
append="ramdisk=$size reboot=hard,bios"
END
fi
cat <<END >>$disk/etc/lilo.conf
root = /dev/fd0
message = /boot/message
### IMAGES ###
image = /boot/linux-$ver
initrd = /boot/disk-$net$ver
label = $ver
END
ls -l /boot-$sys/linux-$ver
cp /boot-$sys/linux-$ver $disk/boot/linux-$ver
wait ## RAM-Disk wird evtl. noch gepackt...
ls -l $dest
cp $dest $disk/boot/disk-$net$ver
echo Running LILO...
lilo -r $disk
echo Unmount real disk
umount $disk
else # keine Bootfloppy
echo Compressing the boot disk...
wait
fi
if test -n "$lilo" ; then
if test ! -f /boot/message ; then
cat <<END
Dies ist die Bootplatte für $sys, Kernel $ver.
Erstellt via Buildsystem: $(date)
Die nd-*-Kernels booten ohne initrd.
END
fi
if test -z "$net" -a /boot/disk-$ver -ef /boot-$sys/disk-$ver ; then
echo " *** LILO kann ich hier nicht für $sys starten -- lebensmüde??? *** "
else
/sbin/mklilo
fi
fi
if test -n "$fd" ; then
rm $dest
fi
rm $diskfile
rmdir $disk
-- Matthias Urlichs \ noris network GmbH / Xlink-POP Nürnberg Schleiermacherstraße 12 \ Linux+Internet / EMail: urlichs@noris.de 90491 Nürnberg (Germany) \ Consulting+Programming+Networking+etc'ing PGP: 1024/4F578875 1B 89 E2 1C 43 EA 80 44 15 D2 29 CF C6 C7 E0 DE Click <A HREF="http://info.noris.de/~smurf/finger">here</A>. 42