Boot Disk
Phil Schaffner
Philip.R.Schaffner at NASA.gov
Thu Feb 5 22:33:39 UTC 2004
On Thu, 2004-02-05 at 15:29, Terry Polzin wrote:
> On Thursday 05 February 2004 14:43, Michael Gargiullo wrote:
> <snip>
> > I just need to boot the OS to be able to run grub-install /dev/sda
>
> Boot from install CD into rescue
> mount the installation
>
> chroot /mnt/sysimage
> grub-install [ /dev/hdx] [/dev/sdx]
>
> That should get grub working. But as I have stated in other replies.
> A working boot medium is needed for situations like you mentioned, less messy
> and needed if you don't want a boot loader.
If you want a floppy solution for GRUB/MBR problems, or just to change
default boot OS by popping in a floppy, the following script may be
useful:
####################################################################
#!/bin/bash
# mkgrubmenu
#
# Written by Phil Schaffner <p.r.schaffner at ieee.org>
# based on mkbootdisk by Erik Troan <ewt at redhat.com>
pause=yes
format=yes
device=/dev/fd0
unset verbose
GRUBDIR=/boot/grub
MOUNTDIR=/tmp/mkgrubmenu
PATH=/sbin:$PATH
export PATH
VERSION=0.2
usage () {
cat >&2 <<EOF
usage: `basename $0` [--version] [--noprompt] [--noformat]
[--device <devicefile>] [--grubdir <dir>] [--verbose -v]
(ex: `basename $0` --device /dev/fd1)
EOF
exit $1
}
while [ $# -gt 0 ]; do
case $1 in
--device)
shift
device=$1
;;
--grubdir)
shift
GRUBDIR=$1
;;
--help)
usage 0
;;
--noprompt)
unset pause
;;
--noformat)
unset format
;;
-v)
verbose=true
;;
--verbose)
verbose=true
;;
--version)
echo "mkgrubdisk: version $VERSION"
exit 0
;;
*)
usage
;;
esac
shift
done
[ -d $GRUBDIR ] || {
echo "$GRUBDIR is not a directory!" >&2
exit 1
}
if [ -e "$device" ]; then {
[ -n "$pause" ] && {
echo -n "Insert a"
[ -n "$format" ] || echo -n " vfat formatted"
echo " disk in $device."
echo "Any information on the disk will be lost."
echo -n "Press <Enter> to continue or ^C to abort: "
read aline
}
[ -n "$format" ] && {
[ -n "$verbose" ] && echo "Formatting $device... "
fdformat $device || exit 0
mkfs.msdos $device > /dev/null 2>/dev/null || exit 0
[ -n "$verbose" ] && echo "done."
}
rm -rf $MOUNTDIR
mkdir $MOUNTDIR || {
echo "Failed to create $MOUNTDIR" >&2
exit 1
}
[ -d $MOUNTDIR ] || {
echo "$MOUNTDIR is not a directory!" >&2
exit 1
}
mount -wt vfat $device $MOUNTDIR || {
rmdir $MOUNTDIR
exit 1
}
mkdir $MOUNTDIR/grub
[ -n "$verbose" ] && echo -n "Copying $GRUBDIR files... "
cd $GRUBDIR
cp -a stage1 stage2 grub.conf device.map $MOUNTDIR/grub
[ -n "$verbose" ] && echo "done."
[ -n "$verbose" ] && echo -n "Setting up GRUB... "
grub --device-map=$GRUBDIR/device.map --batch <<EOF
root (fd0)
setup (fd0)
quit
EOF
[ -n "$verbose" ] && echo "done."
umount $MOUNTDIR
rmdir $MOUNTDIR
[ -n "$verbose" ] && echo "done setting up GRUB."
echo "edit (fd0)/grub/grub.conf to customize."
}
else
echo "$device does not exist"
fi
####################################################################
Phil
More information about the fedora-list
mailing list