[linux] Oh My Bitchy LILO (buntut ketinggalan - makebootdisk)

Chairil K. Kartakusuma (chairil@jiffy.printis.org)
Tue, 30 Jan 1996 08:54:49 +0700 (JVT)

#!/bin/sh
# Copyright 1995, Patrick Volkerding, Moorhead, Minnesota USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
ROOT_DEVICE="`mount | fgrep ' on / ' | cut -f 1 -d ' '`"
K1=/vmlinuz
K2=/usr/src/linux/arch/i386/boot/zImage
if [ $K1 -nt $K2 ]; then
KERNEL=$K1
else
KERNEL=$K2
fi
if [ ! -r $K2 ]; then
KERNEL=$K1
fi
if mount | fgrep ' on / ' | fgrep umsdos 1> /dev/null 2> /dev/null ; then
MOUNT="read-write"
else
MOUNT="read-only"
fi
while [ 0 ]; do # the bootdisk menu loop
dialog --title "MAKE BOOTDISK" --menu "This menu allows you to make a \
bootdisk from a newly compiled kernel. It looks at /vmlinuz and \
/usr/src/linux/arch/i386/boot/zImage and uses whichever one is newer. \
There are two types of \
bootdisks that you can make: a simple bootdisk (which is just a kernel image \
written directly to disk) or a LILO bootdisk (which is more flexible, but \
takes a little longer to load). Which option would you like?" 18 60 4 \
"format" "format floppy disk in /dev/fd0" \
"simple" "make simple vmlinuz > /dev/fd0 bootdisk" \
"lilo" "make lilo bootdisk" \
"exit" "exit this program" 2> /tmp/return
if [ ! $? = 0 ]; then
break;
fi
REPLY=`cat /tmp/return`
rm -f /tmp/return
if [ "$REPLY" = "format" ]; then
dialog --title "SPECIFY FLOPPY SIZE" --menu "What size is your /dev/fd0 (a:)\
drive?" 9 60 2 \
"1.44" "1.44 megabytes" \
"1.2" "1.2 megabytes" 2> /tmp/return
if [ "`cat /tmp/return`" = "1.44" ]; then
dialog --title "Formatting /dev/fd0H1440" --infobox "Formatting /dev/fd0, \
1.44 megabytes." 3 50
fdformat -n /dev/fd0H1440 1> /dev/null 2> /dev/null
elif [ "`cat /tmp/return`" = "1.2" ]; then
dialog --title "Formatting /dev/fd0h1200" --infobox "Formatting /dev/fd0, \
1.2 megabytes." 3 50
fdformat -n /dev/fd0h1200 1> /dev/null 2> /dev/null
fi
rm -f /tmp/return
elif [ "$REPLY" = "simple" ]; then # make simple bootdisk
dialog --title "BOOT DISK CREATION" --yesno \
"\n\
Now put a formatted floppy in your boot drive. \n\
This will be made into your Linux boot disk. Use this to\n\
boot Linux until LILO has been configured to boot from\n\
the hard drive.\n\n\
Any data on the target disk will be destroyed.\n\n\
YES creates the disk, NO aborts.\n" 14 62
if [ $? = 0 ]; then
dialog --title "CREATING DISK" --infobox "Creating boot disk from $KERNEL..." 5 72
dd if=$KERNEL of=/dev/fd0 2> /dev/null
rdev /dev/fd0 $ROOT_DEVICE
rdev -v /dev/fd0 -1
if [ "$MOUNT" = "read-only" ]; then
rdev -R /dev/fd0 1
else
rdev -R /dev/fd0 0
fi
fi
elif [ "$REPLY" = "lilo" ]; then # make lilo bootdisk
dialog --title "CREATING LILO BOOTDISK IN /dev/fd0" --yesno "Now put a \
formatted floppy in your boot drive. This will be made into a LILO \
bootdisk that you can use to start your Linux system. Any data on the \
target disk will be destroyed. YES creates the disk, NO aborts." 8 62
if [ $? = 0 ]; then # make the disk
# dialog --title "SPECIFY FLOPPY SIZE" --menu "What size is your /dev/fd0 (a:)\
# drive?" 9 60 2 \
#"1.44" "1.44 megabytes" \
#"1.2" "1.2 megabytes" 2> /tmp/return
# if [ "`cat /tmp/return`" = "1.44" ]; then
# DEV=/dev/fd0H1440
# else
# DEV=/dev/fd0h1200
# fi
DEV=/dev/fd0
dialog --infobox "Creating LILO bootdisk from $KERNEL for $ROOT_DEVICE..." 4 60
mke2fs -i 1024 $DEV 1> /dev/null 2> /dev/null
if [ ! -d /tmp/lilo ]; then
mkdir /tmp/lilo
fi
mount -t ext2 /dev/fd0 /tmp/lilo 1> /dev/null 2> /dev/null
cp $KERNEL /tmp/lilo/vmlinuz
cp -a /dev /tmp/lilo
mkdir /tmp/lilo/etc
cat << EOF > /tmp/lilo/etc/lilo.conf
boot = /dev/fd0
message=/boot/message
prompt
image = /vmlinuz
label = mount
ramdisk = 0
root = $ROOT_DEVICE
vga = normal
$MOUNT
EOF
cp -a /boot /tmp/lilo
cat << EOF > /tmp/lilo/boot/message

Welcome to the Slackware Linux custom LILO bootdisk!

By default, this disk boots a root Linux partition on $ROOT_DEVICE when
you hit ENTER. If you'd like to boot some other partition, use a command
like this on the LILO prompt below:

mount root=/dev/sda1 ro

Where "/dev/sda1" is the partition you want to boot, and "ro" specifies that
the partition should be initially mounted as read-only. If you which to mount
the partition read-write, use "rw" instead. You may also add any other kernel
parameters you might need depending on your hardware, and which drivers are
included in your kernel.

EOF
lilo -r /tmp/lilo 1> /dev/null 2> /dev/null
umount /tmp/lilo
rm -rf /tmp/lilo
fi
elif [ "$REPLY" = "exit" ]; then
break;
fi
done
==================== cut here =====================================

-- 
========================================================================
Chairil K. Kartakusuma, M.Sc.                  | SunOS / Solaris,      |
PRINTIS Information Systems Consultant         | AT&T/UnixWare SVR4    |
UNIX & Multi-Platform Client/Server Integrator | Linux, FreeBSD, OS/2  |
Jakarta, INDONESIA                             |=======================|
e-mail: chairilk@indo.net.id                   |   Abolish Software    |
        chairil@ibm.net                        |       Monopoly        |
        chairil@sns.com                        | Support Free Software |
========================================================================
-
START LANGGANAN:  kirimkan isi pesan "subscribe" ke linux-request@sdn.or.id
STOP LANGGANAN:	kirimkan isi pesan "unsubscribe" ke linux-request@sdn.or.id