Linux HOWTOs

About | Home | Search


HOWTO: grub
Description: Multiboot boot loader
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# GRUB (GRand Unified Bootloader)
# ====
# There are two versions of GRUB that I'm aware of.  The original GRUB is
# now called "GRUB Legacy" and is no longer being developed with new
# features, only bugfixes.  The other one is "GRUB 2", which is a rewrite.
# Neither has had a "stable" release, but GRUB is in widespread use.

# For another boot-loader option, check out lilo.

# If you want a Slackware-centric script that will allow you to configure
# grub, check out grubconfig

# I use the /usr prefix below for no particular reason.  Feel free to use
# /usr/local (the default), /, or whatever you like.

# If you ever need to uninstall grub, or remove an old version before
# installing a new one, skip down to the bottom for instructions.


# GRUB Legacy 0.97
# ================
# Prerequisites:
# gawk
# grep
# ncurses

cd
test -f installed/grub-0.97.tar.gz && mv installed/grub-0.97.tar.gz .
test ! -f grub-0.97.tar.gz &&
 wget ftp://alpha.gnu.org/gnu/grub/grub-0.97.tar.gz

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "cd3f3eb54446be6003156158d51f4884  grub-0.97.tar.gz" | md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg-verified tarball)
echo "2580626c4579bd99336d3af4482c346c95dac4fb  grub-0.97.tar.gz" | \
 sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys FE06BDEF > /dev/null 2>&1 || gpg --recv-keys FE06BDEF ) &&
 wget -nc ftp://alpha.gnu.org/gnu/grub/grub-0.97.tar.gz.sig &&
  gpg --verify grub-0.97.tar.gz.sig && rm grub-0.97.tar.gz.sig

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "grub-*" -exec rm -r {} \;
tar xzvf ~/grub-0.97.tar.gz
cd grub-0.97
test $UID = 0 && chown -R root:root .
./configure --prefix=/usr
make
make check

# Become root to install it
su

# Remove Slackware's grub package from 'extra'
test -x /sbin/removepkg && /sbin/removepkg extra

# Install what you compiled
make install

# Read 'info grub' for info about using it

# Back up /boot/grub
test -d /boot/grub &&
 ( mkdir -p -m 0700 ~/backup/grub
   cp -a /boot/grub/* ~/backup/grub/ )

# Install grub onto the MBR of IDE disk #1
grub-install /dev/hda

# Copy sample configuration file in /boot/grub/ (then customize it)
cp docs/menu.lst /boot/grub/

# Here is a sample one installed into the MBR of hda that hands off to the
# GRUB/Lilo that's installed into the superblock of the partition you
# select.
# http://englanders.cc/pub/linux/misc/grub-mbr-menu.lst

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/grub-*.tar.*
mv grub-0.97.tar.gz installed/


# GRUB 2 1.93
# ===========
# If you're upgrading from GRUB Legacy to GRUB 2, skip down to the bottom
# first to uninstall the older version first.

# FYI, the last time I tried this, I got as far as running grub-install,
# which had an incorrect path, then I fixed it and something else didn't
# work, and I gave up.  I am certainly in no dire need to install GRUB 2.
# When I have more time, I'll document what happens.

# Prerequisites:
# bison
# ruby (only required for development)
# grep
# lzo >= 1.02
# ncurses

cd
test -f installed/grub-1.93.tar.gz && mv installed/grub-1.93.tar.gz .
test ! -f grub-1.93.tar.gz &&
 wget ftp://alpha.gnu.org/gnu/grub/grub-1.93.tar.gz

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "c0485d0ac16b3921483bb9df1ce8baf2  grub-1.93.tar.gz" | md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg-verified tarball)
echo "2afb92d49479574f84426fb91fe6e50546d2d711  grub-1.93.tar.gz" | \
 sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys C046C039 > /dev/null 2>&1 || gpg --recv-keys C046C039 ) &&
 wget -nc ftp://alpha.gnu.org/gnu/grub/grub-1.93.tar.gz.sig &&
  gpg --verify grub-1.93.tar.gz.sig && rm grub-1.93.tar.gz.sig

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "grub-*" -exec rm -r {} \;
tar xzvf ~/grub-1.93.tar.gz
cd grub-1.93
test $UID = 0 && chown -R root:root .
./configure --prefix=/usr
make

# Become root to install it
su

# Remove Slackware's grub package from 'extra'
test -x /sbin/removepkg && /sbin/removepkg extra

# Install what you compiled
make install

# Read http://www.gnu.org/software/grub/manual/html_node/index.html for info
# about using it

# Back up /boot/grub
mkdir -p -m 0700 ~/backup/grub2
cp -a /boot/grub/* ~/backup/grub2/

# To install grub onto the MBR of IDE disk #1
# (or see the manual for other ways)
grub-install /dev/hda

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/grub-*.tar.*
mv grub-1.93.tar.gz installed/


# If you ever want to uninstall GRUB Legacy, this should do it:
cd
su
test -d src/grub-0.* && ( cd src/grub-0.* ; make uninstall )
test -d /boot/grub && rm -r /boot/grub
rm -f /usr/bin/mbchk /usr/info/grub.info /usr/man/man1/mbchk.1
test -d /usr/lib/grub && rm -r /usr/lib/grub
( cd /usr/man/man8 ; rm -f grub.8 grub-install.8 grub-md5-crypt.8 \
 grub-terminfo.8 )
( cd /usr/sbin ; rm -f grub grub-install grub-md5-crypt grub-set-default \
 grub-terminfo )
exit
find ~/src -maxdepth 1 -type d -name "grub-0.*" -exec rm -r {} \;
rm -f ~/installed/grub-0.*.tar.*


# If you ever want to uninstall GRUB 2, this should do it:
cd
su
test -d src/grub-* && ( cd src/grub-* ; make uninstall )
test -d /boot/grub && rm -r /boot/grub
rm -f /usr/bin/grub-mkimage
( cd /usr/sbin ; rm -f grub-emu grub-install grub-mkdevicemap \
 grub-probefs grub-setup )
test -d /usr/share/grub && rm -r /usr/share/grub
exit
find ~/src -maxdepth 1 -type d -name "grub-*" -exec rm -r {} \;
rm -f ~/installed/grub-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>