* Bootutil tutorial
@ 1993-10-07 21:46 David Lesher
0 siblings, 0 replies; only message in thread
From: David Lesher @ 1993-10-07 21:46 UTC (permalink / raw)
[This document will be included in the bootutil package in the future, and
perhaps part of a "Booting HOWTO" --mdw]
This tutorial is designed to help newbe's install the bootutil package.
It is NOT a substitute for RTFMing; rather it is a cleaned up history of
the School of Hard Knocks that I went through. I hope it helps others
both install this package, and also learn a little bit about how you go
about doing such things in Linux.
What:
The 'bootutils' package runs fsck (or the equal for whatever kind of
filesystem you have) upon booting. It does this only on those
filesystems that were not properly dismounted at shutdown. Most
importantly, it checks the root filesystem; generally a pain to do for
reasons you will soon understand.
Why:
Unix filesystems are somewhat brittle. They can take lots of bashing,
but one blow in the right place will break off a piece, and leave a
mess. Left in this state, the next program can come along and slip in
the mess, making a bigger one. Eventually, the filesystem can soon be
so badly damaged as to bring down the system, and leave you reaching for
the back up tapes. [You *DO* have back up tapes, right?] One (but alas,
not the only) way of causing such damage is by shutting down the system
without first dismounting all the filesystems.
Fortunately, a few simple techniques, used at the right time, protect
you from this unhappy state of affairs. [You hope.. ] In addition, fsck
(or such) will check for trouble, and fix all but the worst. But, to
keep from making a bigger mess, fsck _must be run only on a filesystem
mounted in "read-only" mode_. (Note -- this does not stop fsck from
writing to the filesystem itself while fixing things. Some are above the
law, you see.)
So the dilemma is: how do you boot up your system, for which the root
filesystem must be R/W, and still check it in read-only mode? Suffice
to say, 'bootutils' accomplishes this via wizard magic. Follow these
hints, along with the Fine Manuals and other Good Words in the
packages, and you too can share in this magic. Ignore them, and Murphy
_WILL_ get you.
Again, bootutils will: dismount everything cleanly, leaving a flag
saying it has done so, and when booting next time, fsck every
filesystem, but actually FIX those those filesystems NOT marked as
"clean".
Who:
This assumes the following:
99.10 or later kernel
ext2 boot filesystem
LILO
If you don't have all the above, the details below either will not work
correctly, or will cause you great grief. (This does not mean you can't
use bootutil, only that this text is not going to tell you how.)
With:
You will need 'bootutils-0.1' and 'utile-1.5' collections from your
favorite archive site. Note that they are likely stored as
{whatever}.tar, or {}.tgz files. Of course, be sure and set 'bin' mode
before getting them. Store each in its own {otherwise-empty}
subdirectory.
Why utile? Your shutdown program *must* unmount the root filesystem.
The standard SLS shutdown is known to have problems here. The shutdown/
reboot/halt programs from Rik Faith's utile-1.5 distribution will work
properly, as will the shutdown in the SysVinit-2.4 package (when used
with reboot/halt from utile-1.5). (This discussion is limited to the
utile approach. If you know enough to tackle the SysV package, you
likely do not need this tutorial.)
Ideally, your shutdown should not try to do the unmounting itself, but
should call the bootutils umount program by running '/etc/umount -a'.
How:
Installation has several steps:
1) Modifying LILO
2) Replacing mount, and several other utilities
3) Changing /etc/rc
1) LILO:
You will add an additional entry to the LILO menu; this one allowing you
to boot the root filesystem in read-only mode. [You will see mention of
using 'rdev' to do this, too. Ignore that -- the LILO approach is all
you'll need.] In the /etc/lilo/config file, you will have something
similar to this:
root = /dev/sda5
image = /zImage
label = linux.12-rw
although your specifics will vary. Add a new one such as:
root = /dev/sda5
image = /zImage
label = linux.12-ro
read-only
This will give you the option of booting read-only (your goal) or r/w,
as you have been. The idea is, you have a way back in if something goes
wrong {in unix? -- never! ;-} the first time. Save and exit. Run
/etc/lilo/install to invoke this new magic.
2) Mount, umount & such:
Make the programs in the bootutil directory you set aside. Before you do,
edit the start of the bootutils/mount/Makefile to say:
DEFAULT_FSTYPE=\"ext2\"
Also fix the 6 lines at the very end that say "/usr/man/cat8" as they
really ought to say "/usr/man/man8".
Do NOT 'make install' anything yet.
Find (i.e. - 'find / -name mount -print') and rename ALL existing copies
of mount & umount to mount~, umount~, etc. [You don't want to erase them
until you are sure you won't need them.] Then copy the replacements from
the bootutils package to wherever the originals were. (In my case, I
put them in /bin, and added links to the /etc directory. This assured
that other programs could find them, as some seem to assume they are in
one place, and the rest the other.) Do an "ls -l" -- do your new
versions have permissions/ownership identical to the old ones they are
replacing?
Now rename/move your existing fsck, mkfs, etc. as the README file in
fsutils instructs. Now it's safe to 'make install' the mount and fsutil
items.
As above, find "shutdown" and rename/replace it with the one from utile.
Do NOT use 'make install' in the utile directory, as that will install
everything. Again, YOU DO NOT WANT THE mount FROM UTILE - it will
overwrite the one you just installed. This does not imply the other
things from utile are not worthwhile (they are!), but adding them is a
project for another day.
3) Modifying /etc/rc:
rc is the file that the system runs while waking up. The lines you will
add are as follows:
PATH=/bin:/usr/bin:/etc
# Check the integrity of all filesystems - fix those need it
/bin/fsck -A -av
# If there was a failure, drop into single-user mode.
if [ $? -gt 1 ] ; then
echo fsck failed. Please reboot.
sh
fi
# Remount the root filesystem in read-write mode
/etc/mount -v -n -o remount /dev/{your root name hda2, sda4, etc}
Put them at the top of the etc/rc file.
Please note several things: fsck will actually run on all filesystems.
When it does, it will skip past those ext2 filesystem that were properly
dismounted. Other documentation may refer to making a /fastboot file.
Ignore that, it's a different approach.
Also observe that the exact syntax on the /bin/fsck line may be
different that that in the package; the above corrects for a bug in
fsck. Note the man pages for mount do not mention the -n option, but it
is there ON THIS VERSION OF MOUNT. (Check the Usage: line by doing a
"mount -x" to confirm this.)
Ok, now if you've done everything correctly, and not gotten any messages
of grief, you are ready to jump in. Sync three times (This invokes
powerful Unix magic; while not REALLY needed, why tempt the Unix
demons that live inside your code?) and reboot. Hit a key to stop LILO,
and tell it to use your new read-only label. It will say:
VFS: Mounted root (ext2fs filesystem) readonly.
somewhere in all those messages going by, if you did everything
correctly. You may well see messages about how it is finding unchecked
filesystems, and working on them. Then it should give many more trivia
messages, and let you log in. Celebrate.
The two most possible things to go wrong are:
1) You did NOT start in read-only mode,
or
2) You do not switch to read/write later.
If you don't get the VFS message mentioned above, You're in #1 trouble.
For some reason, LILO failed to mount the root in read-only mode. Go
through that part again.
If instead, you do get the VFS readonly message, THEN later in the
process get lots of complaints about trying to do things to a read-only
filesystem, your trouble is #2. There is something wrong with the mount
command in your rc file. Did you rename all the old copies of mount, and
check the new one{s} have -n?
But meanwhile, don't panic! Just reboot with the Red Switch, and use
your original LILO entry to get back in. Then figure out what is wrong
[Wrong version of mount? Wrong location for fsck?] and fix it. Now do
you see why you left the standard LILO label alone?
If you have problems, feel free to email me. I doubt I'll know the
answer, but I'll be happy to try. I've made lots of mistakes, and will
be happy to share them with you ;_]
It goes without saying, if Stephen Tweedie had not both created
bootutil, answered all my dumb questions, and made suggestions, you
would not be reading this. When in the area, buy him a stout for his
efforts.
======
--
A host is a host from coast to coast.....wb8foz@mthvax.cs.miami.edu
& no one will talk to a host that's close............[301] 56-LINUX
Unless the host (that isn't close).........................pob 1433
is busy, hung or dead....................................20915-1433
--
Send submissions for comp.os.linux.announce to: linux-announce@tc.cornell.edu
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1993-10-07 21:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-10-07 21:46 Bootutil tutorial David Lesher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox