Messages in this thread | | | From | (Matthias Urlichs) | Subject | Re: Linux-2.1.92 - Feature Freeze | Date | 12 Apr 1998 14:23:46 +0200 |
| |
hpa@transmeta.com (H. Peter Anvin) writes: > > I guess I never really read the docs (I learned it from a > boot-loader-writer's perspective), but basically, this is the idea: > [ idea deleted ]
Here's my script to build an initrd boot disk (or whatever).
It's ugly. It tries to do everything including the kitchen sink. BUT I'm using it for all our install floppies, rescue floppies, and general system bootup of everything, mainly because I don't like to build a kernel for every box, and neither do I like a kernel with two dead SCSI drivers.
The script accesses /boot-KERNEL/linux-VERSION and /lib/modules-KERNEL/ /VERSION/*/* for the actual files. It depends on loopback mounts (unless you have ROMfs).
Bug: I should probably run it through the new sh2p program. ;-) Bug: The thing keeps growing. I should probably try to trim at least the C library down to what's actually necessary for booting, but I'm too lazy... ...as it is, the option to use 82-track floppies is a necessity, and if somebody has a good recipe how to tell LILO+BIOS to use 21-sector floppies I'd be grateful too.
#!/bin/sh
PATH=/usr/src/STATUS/bin:/usr/sbin:/sbin:$PATH LIBC=2.0.92
usage() { cat >&2 <<END Usage: $0 [ -f | -F /dev/fd0 | -I(mage) ] [ -m MEMSIZE ] [ -s ramdisksize ] [ -S imagesize ] [ -g(enerate ROMFS) ] [ -l(ilo) ] [ -v Kernelversion ] [ -p(rerun the disk's shell) ] [ -n(et) -d(ebug) -w X (serial wire X, usually 1) ] [ -r(un without stop in linuxrc) ] [ -R RootDevNum(hex-ohne-0x) ] # [ -N(ew floppy, superformat, sect=21 cyl=83 ] [ -k fqname-of-box ] [ -P (include pcmcia) ] KERNEL (pci, adaptec, 2.1, ...) END exit 1 }
cd /usr/src || die "No sources"
if test $# -eq 0 ; then usage ; fi
size=3500 imgsize= fifo=/tmp/pipe.$$ fd= format= run= net= ver= debug= serial= prerun= rootdev= romfs= kiste= MEM=
set -- $(getopt dfF:P:Ilnps:S:rR:v:w:m:Ngk: $*) if test $? != 0 then usage fi for i do case "$i" in -g) romfs=y; shift;; -p) prerun=y; shift;; -w) serial=$2; shift; shift;; -P) pcmcia=y; shift ;; -d) debug=y; shift;; -k) kiste=$2; shift; shift;; -I) fd=IMAGE; shift;; -F) fd=$2; shift; shift;; -v) ver=$2; shift; shift;; -f) fd=/dev/fd0; shift;; -N) fd=/dev/fd0; format=y; shift;; -r) run=y; shift;; -S) imgsize=$2; shift; shift;; -s) size=$2; shift; shift;; -n) net="net-"; shift;; -R) rootdev=$2; shift; shift;; -m) MEM="mem=${2}M"; shift; 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 | grep '^[0-9]' | 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
if test -n "$romfs" ; then rm -rf $disk mkdir $disk
else rm -rf $disk $diskfile
dd bs=1024 count=$size if=/dev/zero of=$diskfile set +e yes y | /sbin/mkfs -t ext2 $diskfile $size set -e mkdir $disk echo Mounting disk file mount -t ext2 -o loop $diskfile $disk fi
while read a ; do echo /$a; mkdir $disk/$a; done <<END cd mnt END while read a ; do echo /$a "=>" /cd/$a; mkdir $disk/cd/$a; ln -s cd/$a $disk/$a; done <<END var usr sbin lib END while read a ; do echo /$a; mkdir $disk/$a; done <<END bin dev etc etc/terminfo mnt1 mnt2 mnt3 proc usr/lib usr/sbin fd var/run var/tmp END ln -s cd/var/tmp $disk/tmp
if test -n "$net" ; then ## Netz cpio -pvd $disk <<END /sbin/route /sbin/ifconfig /sbin/ipwhat /usr/sbin/portmap /usr/sbin/rpc.mountd /usr/sbin/rpc.nfsd /lib/libnss_files-$LIBC.so /lib/libnss_files.so.1 END sed -e 's/files.*/files/' </etc/nsswitch.conf >$disk/etc/nsswitch.conf else cpio -pvd $disk <<END /sbin/fdisk /sbin/fs/mkfs.ext2 /sbin/fs/fsck.ext2 /sbin/swapon /sbin/mkswap 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/update END
find $disk/bin/ $disk/sbin/ -type f -print|xargs strip
cpio -pvd $disk <<END /dev/zero /dev/null /dev/tty /dev/tty1 /dev/console /dev/ttyS0 /dev/ttyS1 /dev/hda /dev/hda1 /dev/hda2 /dev/hda3 /dev/hda4 /dev/hda5 /dev/hda6 /dev/hda7 /dev/hda8 /dev/hdb /dev/hdb1 /dev/hdb2 /dev/hdb3 /dev/hdb4 /dev/hdb5 /dev/hdb6 /dev/hdb7 /dev/hda /dev/hdc1 /dev/hdc2 /dev/hdc3 /dev/hdc4 /dev/hdc5 /dev/hdc6 /dev/hdc7 /dev/hdd /dev/hdd1 /dev/hdd2 /dev/hdd3 /dev/hdd4 /dev/hdd5 /dev/hdd6 /dev/hdd7 /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 $disk/lib ( cd $disk/lib; ln -s . temp ) cp -v /usr/lib/terminfo/l/linux $disk/etc/terminfo/l
( ( ( # if test -f STATUS/out/gnu:libc ; then # cat STATUS/out/gnu:libc # else cat <<END /lib/libc-$LIBC.so /lib/ld-$LIBC.so /lib/libc.so.6 /lib/ld-linux.so.2 /lib/libshadow.so.3 /lib/libshadow.so.3.3.1 /lib/libdl-$LIBC.so /lib/libdl.so.2 END #/lib/libreadline.so.2 #/lib/libncurses.so.1.9.9e #/lib/libncurses.so.3.0 # fi # cat STATUS/out/gnu:readline # cat STATUS/out/lib:ncurses # cat STATUS/out/lib:shadow ) | grep ^/lib/ ; cat <<END /bin/sh END ) | 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/ < STATUS/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
# echo ldconfig ... # LD_PRELOAD="" chroot $disk /sbin/ldconfig -v
mkdir $disk/modules
if test -n "$pcmcia" ; then ## pcmcia echo "*.* /dev/tty1" >$disk/etc/syslog.conf mkdir -p $disk/var/log $disk/var/run ln -s modules-pcmcia $disk/lib/modules ( echo /usr/sbin/syslogd fgrep -v usr/man /usr/src/STATUS/out/kernel:pcmcia ) | while read a ; do if test -L $a ; then mkdir -p $(dirname $disk/$a) cp -a $a $disk/$a elif test -f $a ; then b=/tmp/$$.$(basename $a) cp -a $a $b ls -l $b strip --strip-debug $b || true ls -l $b mkdir -p $(dirname $disk/$a) cp -a $b $disk/$a rm $b elif test -d $a ; then mkdir -p $disk/$a else mkdir -p $(dirname $disk/$a) cp -a $b $disk/$a fi done fi
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/wd.o net/smc-ultra.o net/smc9194.o net/tulip.o net/tlan.o misc/sunrpc.o fs/lockd.o fs/nfs.o fs/ext2.o block/floppy.o END #net/de4x5.o #net/depca.o #net/eexpress.o #net/ewrk3.o #net/ne.o
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/ncr53c8xx.o scsi/aha152x.o scsi/aic7xxx.o scsi/sd_mod.o scsi/sr_mod.o fs/ext2.o fs/isofs.o block/floppy.o block/ide-disk.o block/ide-mod.o block/ide-probe.o block/ide-proc.o END fi #scsi/53c7,8xx.o
touch $disk/proc/mounts ln -s /proc/mounts $disk/var/run/mtab
echo ">> $disk/linuxrc" cat <<END >$disk/linuxrc #!/bin/sh
set -xv PATH=/bin:/sbin END
echo 'echo "linuxrc startet"' >>$disk/linuxrc
if test -n "$serial" ; then echo "exec </dev/ttyS$serial >/dev/ttyS$serial 2>&1" >>$disk/linuxrc #else # echo "exec </dev/tty1 >/dev/tty1 2>&1" >>$disk/linuxrc fi
cat <<END >>$disk/linuxrc echo "Dies ist die Bootdiskette für $sys..."
END
if test -n "$net" ; then cp /usr/src/STATUS/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/sunrpc.o insmod /modules/lockd.o insmod /modules/nfs.o insmod /modules/ext2.o END
else ## kein Netz
cat <<END >>$disk/linuxrc insmod /modules/ext2.o insmod /modules/scsi_mod.o insmod /modules/aha1542.o insmod /modules/aha152x.o insmod /modules/aic7xxx.o insmod /modules/ncr53c8xx.o insmod /modules/53c7,8xx.o insmod /modules/sd_mod.o insmod /modules/floppy.o insmod /modules/ide-mod.o insmod /modules/ide-disk.o insmod /modules/ide-probe.o END fi
cat <<END >>$disk/linuxrc
mount -n /proc END
if test -n "$rootdev" ; then echo "echo 0x$rootdev >/proc/sys/kernel/real-root-dev" >>$disk/linuxrc else echo '# echo 0x801 >/proc/sys/kernel/real-root-dev' >>$disk/linuxrc fi
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 ls -l $disk/linuxrc
du $disk/. if test -n "$debug" ; then echo "disk ready for compressing." ( cd $disk; /bin/sh -i ) fi
if test -n "$prerun" ; then echo Starting test shell LD_PRELOAD="" chroot $disk /bin/sh echo ...continuing. else LD_PRELOAD="" chroot $disk /bin/sh -c "echo Running a small test..." fi
if test -n "$fd" ; then dest=/tmp/cdisk.$$ else dest=/boot-$sys/disk-$net$ver fi
if test -n "$romfs" ; then echo Generating ROM FS /sbin/genromfs -d $disk -f $diskfile -V "Test 1" else echo Unmounting disk file umount $disk sync fi
echo "Compressing $diskfile ($disk) to $dest" gzip < $diskfile > $dest &
if test -n "$fd" ; then
sleep 1 if test -b "$fd" ; then if test -n "$format" ; then # superformat $fd sect=21 cyl=83 superformat $fd sect=18 cyl=82 # superformat $fd sect=18 cyl=80 else # mformat -k -t 83 -s 21 a: # /dev/fd0 mformat -k -t 82 -s 18 a: # /dev/fd0 # mformat -k -t 80 -s 18 a: # /dev/fd0 fi echo /sbin/fs/mkfs.ext2 -i 50000 $fd $imgsize set +e /sbin/fs/mkfs.ext2 -i 50000 $fd $imgsize set -e mount -t ext2 $fd $disk else dd bs=1024 count=$imgsize if=/dev/zero of=$fd echo /sbin/fs/mkfs.ext2 -i 50000 $fd $imgsize set +e yes y | /sbin/fs/mkfs.ext2 -i 50000 $fd $imgsize set -e mount -t ext2 -o loop $fd $disk fi if test -n "$kiste" ; then if test ! -f STATUS/status/$kiste ; then
echo "Keine Statusdatei für $kiste gefunden." echo -n "System (pci): "; read who; if test -z "$who"; then who="pci"; fi echo -n "Ziel (193.141.54.134): "; read slave; if test -z "$slave"; then slave="193.141.54.134"; fi echo -n "Netzbits (26): "; read netbits; if test -z "$netbits"; then netbits=26; fi set -- $(/sbin/ipwhat $slave $netbits) mask=$1 netz=$2 broad=$3 defdef=$4
echo -n "Defaultrouter ($defdef): "; read def; if test -z "$def"; then def="$defdef"; fi echo -n "Quelle ($defdef): "; read master; if test -z "$master"; then master="$defdef"; fi echo -n "Hostname (install.noris.de): "; read name; if test -z "$name"; then name="install.noris.de"; fi
( echo "### KONFIGDATEN '$kiste'" echo "export who=$who" echo "export master=$master" echo "export slave=$slave" echo "export mask=$mask" echo "export imask=$netbits" echo "export broad=$broad" echo "export netz=$netz" echo "export def=$def" echo "export name=$name" ) > STATUS/status/$kiste
fi cp STATUS/status/$kiste $disk/STATUS fi
while read a ; do echo /$a; mkdir $disk/$a; done <<END boot dev etc END
( grep ^/boot/ < STATUS/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 disk=/dev/fd0 bios=0x00 sectors=18 heads=2 cylinders=82 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 $MEM console=$serial,9600 reboot=hard,bios" serial = 1,9600n8 END else cat <<END >>$disk/etc/lilo.conf append="ramdisk=$size $MEM 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... if lilo -r $disk ; then : ; else umount $disk exit 1 fi
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 rm -r $disk
-- Matthias Urlichs noris network GmbH
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |