home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Enter 1999 June / enter_06_1999.iso / doc / HOWTO / Root-RAID-HOWTO < prev    next >
Text File  |  1998-10-14  |  84KB  |  2,905 lines

  1.   Root RAID HOWTO cookbook
  2.   Michael A. Robinton, michael@bzs.org
  3.   <mailto:michael@bzs.org>
  4.   v1.07, 25 March 1998
  5.  
  6.   This document provides a cookbook for creating a root mounted raid
  7.   filesystem and companion fallback rescue system using linux initrd.
  8.   There are complete step-by-step instruction for both raid1 and raid5
  9.   md0 devices. Each step is accompanied by an explanation of it's pur¡
  10.   pose.  Included with this revision is a generic linuxrc initrd file
  11.   which may be configured with a single three line ``/etc/raid¡
  12.   boot.conf'' file for raid1 and raid5 configurations.
  13.   ______________________________________________________________________
  14.  
  15.   Table of Contents
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   1. Introduction
  68.  
  69.      1.1 Where to get Up-to-date copies of this document.
  70.      1.2 Bugs
  71.      1.3 Acknowledgements
  72.      1.4 Copyright Notice
  73.  
  74.   2. What you need BEFORE YOU START
  75.  
  76.      2.1 Required Packages
  77.      2.2 Other similar implementations.
  78.      2.3 Documentation -- Recommended Reading
  79.      2.4 RAID resources
  80.  
  81.   3. Quick Start for ROOT RAID
  82.  
  83.   4. initrd- Cookbook for root mounted RAID
  84.  
  85.      4.1 Security Reminder
  86.      4.2 Build the Kernel and Raid Tools
  87.      4.3 Build the
  88.      4.4 Start the STEP by STEP instructions
  89.      4.5 Install the distribution - Slackware Specific
  90.      4.6 Install linux
  91.      4.7 Install Raid Tools
  92.      4.8 Remove un-needed directories and files from new filesystem.
  93.      4.9 Create /dev/md
  94.      4.10 Create a bare filesystem suitable for
  95.         4.10.1 Create the BOOT/RESCUE
  96.      4.11 Making 'initrd' boot the RAID device - linuxrc
  97.      4.12 Modifying the rc-scripts for SHUTDOWN
  98.      4.13 Configuring RAIDBOOT - raidboot.conf
  99.      4.14 Kernel 'loadlin and lilo' variables for RESCUE and RAID
  100.  
  101.   5. Configuring the Production RAID system.
  102.  
  103.      5.1 System specs. Two systems with identical motherboards were configured.
  104.      5.2 Partitioning the hard drives.
  105.  
  106.   6. Building the RAID file system.
  107.  
  108.      6.1 /etc/raid5.conf
  109.      6.2 /etc/raid1.conf
  110.      6.3 Step by Step procedures for building production RAID file system.
  111.  
  112.   7. One last thought.
  113.  
  114.   8. Appendix A. - Bohumil Chalupa's md0 shutdown
  115.  
  116.   9. Appendix B. - Sample SHUTDOWN scripts
  117.  
  118.      9.1 Slackware - /etc/rc.d/rc.6
  119.      9.2 Debian bo - /etc/init.d/halt and /etc/init.d/reboot
  120.         9.2.1 /etc/init.d/halt
  121.         9.2.2 /etc/init.d/reboot
  122.  
  123.   10. Appendix C. - other setup files
  124.  
  125.      10.1 linuxrc
  126.      10.2 loadlin -- linux.bat file - boot.par
  127.      10.3 linuxthreads Makefile.diff
  128.      10.4 raid1.conf
  129.      10.5 raid5.conf
  130.      10.6 raidboot.conf
  131.      10.7 rc.raidown
  132.  
  133.   11. Appendix D. - obsolete linuxrc and shutdown scripts
  134.  
  135.      11.1 Obsolete working - linuxrc
  136.      11.2 Obsolete working - shutdown scripts
  137.  
  138.   12. Appendix E. - Gadi's raid stop patch for the linux kernel
  139.  
  140.   13. Appendix F. - rc.raidown
  141.  
  142.   14. Appendix G. - linuxrc theory of operation
  143.  
  144.  
  145.  
  146.   ______________________________________________________________________
  147.  
  148.   1.  Introduction
  149.  
  150.   The reader is assumed to be familiar with the various types of raid
  151.   implementations, their advantages and drawbacks. This is not a
  152.   tutorial, just a set of instructions on how to implement root mounted
  153.   raid on a linux system. All of the information necessary to become
  154.   familiar with linux raid is listed here directly or by reference,
  155.   please read it before send e-mail questions.
  156.  
  157.  
  158.   1.1.  Where to get Up-to-date copies of this document.
  159.  
  160.   Root-RAID-HOWTO
  161.  
  162.   Available in LaTeX (for DVI and PostScript), plain text, and HTML.
  163.  
  164.        sunsite.unc.edu/mdw/HOWTO/ <http://sun¡
  165.        site.unc.edu/mdw/HOWTO/>
  166.  
  167.  
  168.   Available in SGML and HTML.
  169.  
  170.        ftp.bizsystems.com/pub/raid/ <ftp://ftp.bizsys¡
  171.        tems.com/pub/raid/>
  172.  
  173.  
  174.  
  175.   1.2.  Bugs
  176.  
  177.   As of this writing, the problem of stopping a root mounted RAID device
  178.   has not yet been solved in a satisfactory way.  A work-around proposed
  179.   by Ed Welbon and implemented by Bohumil Chalupa is incorporated into
  180.   this document which eliminates the need for a long ckraid at each boot
  181.   for raid1 and raid5 devices. Without the workaround, it is necessary
  182.   to ckraid the md device each time the system is re-booted. On a large
  183.   array this can cause a severe availability performance degradation.
  184.   On my 6 gig RAID1 device running on a Pentium 166 with 128 megs of
  185.   ram, it takes well over half an hour to ckraid :-( after each re-boot.
  186.   It takes over an hour on my 13 gig RAID5 array with a 20mb/sec scsi
  187.   adaptor.
  188.  
  189.   The workaround stores the status of the array at shutdown on the real
  190.   boot device and compares it to a reference status placed there when
  191.   the system is first built. If the status's match at reboot, the
  192.   superblock on the array is rebuilt on the next boot, otherwise the
  193.   operator is notified of the status error and the rescue system is left
  194.   running with all the raid tools available.
  195.  
  196.   Rebuilding the superblock causes the system to ignore that the array
  197.   was powered down without mdstop by marking all the drives as OK, as if
  198.   nothing happened. This only works if all the drives are OK at
  199.   shutdown. If the array was operating with a bad drive, the operator
  200.   must remove the bad drive prior to restarting the md device or the
  201.   data can be corrupted.
  202.  
  203.   None of this applies to raid0 which does not have to be mdstopped
  204.   before shutdown.
  205.  
  206.   Final proposed solutions to this problem include a finalrd similar to
  207.   initrd, and mdrootstop which writes the clean flags to the array
  208.   during  shutdown when it is mounted read only. I am sure there are
  209.   others.
  210.  
  211.   In the mean time, the problem has been by-passed for now Please let me
  212.   know when this problem is solved more cleanly!!!
  213.  
  214.  
  215.   1.3.  Acknowledgements
  216.  
  217.   The writings and e-mail from the following individuals helped to make
  218.   this document possible.  Many of the ideas were stolen from the
  219.   helpful work of others, I have just tried to put it all in COOKBOOK
  220.   form so that it is straightforward to use. My thanks to:
  221.  
  222.   ╖  Linas Vepstas <mailto:linas@linas.org>
  223.       for the RAID howto that explained most of this to me.
  224.  
  225.   ╖  Gadi Oxman <mailto:gadio@netvision.net.il>
  226.       for answering my dumb 'newbie' questions.
  227.  
  228.   ╖  Ed Welbon <mailto:welbon@bga.com>
  229.       for the execellent initrd.md package that inspired me to write
  230.      this.
  231.  
  232.   ╖  Bohumil Chalupa <mailto:bochal@apollo.karlov.mff.cuni.cz>  for
  233.      implementing the re-boot 'workaround' that allows root-mounted-raid
  234.      to work in a production environment.
  235.  
  236.  
  237.   ╖  and many others who contributed to this work in one way or another.
  238.  
  239.  
  240.   1.4.  Copyright Notice
  241.  
  242.   This document is GNU copyleft by Michael Robinton michael@bzs.org
  243.   <mailto:michael@bzs.org>.
  244.  
  245.   Permission to use, copy, distribute this document for any purpose is
  246.   hereby granted, provided that the author's / editor's name and this
  247.   notice appear in all copies and/or supporting documents; and that an
  248.   unmodified version of this document is made freely available.  This
  249.   document is distributed in the hope that it will be useful, but
  250.   WITHOUT ANY WARRANTY, either expressed or implied.  While every effort
  251.   has been taken to ensure the accuracy of the information documented
  252.   herein, the author / editor / maintainer assumes NO RESPONSIBILITY for
  253.   any errors, or for any damages, direct or consequential, as a result
  254.   of the use of the information documented herein.
  255.  
  256.  
  257.   2.  What you need BEFORE YOU START
  258.  
  259.   The packages you need and the documentation that answers the most
  260.   common questions about setting up and running raid are listed below.
  261.   Please review them throughly.
  262.  
  263.  
  264.  
  265.   2.1.  Required Packages
  266.  
  267.   You need to obtain the most recent versions of these packages.
  268.  
  269.   ╖  a linux kernel that supports raid, initrd and /dev/loopx
  270.  
  271.        I used linux-2.0.33 <ftp://sunsite.unc.edu/pub/Linux/ker¡
  272.        nel/> from sunsite
  273.  
  274.  
  275.   ╖  raid145-971022-2.0.31
  276.      <ftp://ftp.kernel.org/pub/linux/daemons/raid/> patch adds support
  277.      for raid1/4/5
  278.  
  279.   ╖  raidtools-pre3-0.42 <ftp://ftp.kernel.org/pub/linux/daemons/raid/>
  280.      tools to create and maintain raid devices (documentation too).
  281.  
  282.   ╖  ``Gadi's raid stop patch'' in Appendix E.
  283.  
  284.   ╖  linuxthreads-0.71
  285.      <ftp://ftp.inria.fr/INRIA/Projects/cristal/Xavier.Leroy> required
  286.      threads package. Use ftp, browser doesn't work
  287.      ftp.inria.fr/INRIA/Projects/cristal/Xavier.Leroy
  288.  
  289.   ╖  A Linux distribution, ready to install.
  290.  
  291.        I used Slackware-3.4 <ftp://ftp.cdrom.com/pub/linux>
  292.  
  293.  
  294.   Helpful but not required
  295.  
  296.   ╖  raidboot-0.01.tar.gz <ftp://ftp.bizsystems.com/pub/raid/> pre-built
  297.      raid rescue/boot system.
  298.  
  299.   The detailed instructions in this document are based on the above
  300.   packages.  If the packages have been updated or you use a different
  301.   linux distribution, you may have to modify the procedures you find
  302.   here.
  303.  
  304.   The patches, tool assortment, etc... may vary with 2.1 kernels.
  305.   Please check the most recent documentation at:
  306.  
  307.  
  308.        ftp.kernel.org/pub/linux/daemons/raid/ <ftp://ftp.ker¡
  309.        nel.org/pub/linux/daemons/raid/>
  310.  
  311.  
  312.  
  313.   2.2.  Other similar implementations.
  314.  
  315.   I chose to include in the kernel all of the pieces necessary to run
  316.   from boot without loading any modules.  My kernel image is a little
  317.   over 300k compressed.
  318.  
  319.   Take a look at Ed Welbon's <mailto:welbon@bga.com> initrd.md.tar.gz
  320.   for another way to make a bootable raid device.  He uses loadable
  321.   modules.  A look at his concise scripts will show you how it is done
  322.   if you need a very small kernel with modules.
  323.  
  324.  
  325.        http://www.realtime.net/~welbon/initrd.md.tar.gz
  326.        <http://www.realtime.net/~welbon/initrd.md.tar.gz>
  327.  
  328.  
  329.  
  330.  
  331.   2.3.  Documentation -- Recommended Reading
  332.  
  333.   Please read:
  334.  
  335.        /usr/src/linux/Documentation/initrd.txt
  336.  
  337.  
  338.  
  339.   as well as the documentation and man pages that accompany the
  340.   raidtools set. In particular, read man mdadd as well as the
  341.   QuickStart.RAID document included in the raidtools package.
  342.  
  343.  
  344.   You may also wish to review:
  345.  
  346.   ╖  BootPrompt-HOWTO <http://sunsite.unc.edu/mdw/HOWTO/BootPrompt-
  347.      HOWTO.html>
  348.  
  349.   ╖  man lilo
  350.  
  351.   ╖  man lilo.conf
  352.  
  353.  
  354.   2.4.  RAID resources
  355.  
  356.  
  357.   ╖  sunsite.unc.edu/mdw/HOWTO/mini/Software-RAID
  358.      <http://sunsite.unc.edu/mdw/HOWTO/mini/Software-RAID>
  359.  
  360.   ╖  www.ssc.com/lg/issue17/raid.html
  361.      <http://www.ssc.com/lg/issue17/raid.html>
  362.  
  363.   ╖  linas.org/linux/raid.html <http://linas.org/linux/raid.html>
  364.  
  365.   ╖  ftp.kernel.org/pub/linux/daemons/raid/
  366.      <ftp://ftp.kernel.org/pub/linux/daemons/raid/>
  367.  
  368.   ╖  www.realtime.net/~welbon/initrd.md.tar.gz
  369.      <http://www.realtime.net/~welbon/initrd.md.tar.gz>
  370.  
  371.   ╖  luthien.nuclecu.unam.mx/~miguel/raid/
  372.      <http://luthien.nuclecu.unam.mx/~miguel/raid/>
  373.  
  374.      Mailing lists can be joined at:
  375.  
  376.   ╖  majordomo@nuclecu.unam.mx <mailto:majordomo@nuclecu.unam.mx> send a
  377.      message to subscribe raiddev
  378.  
  379.      send mail to: raiddev@nuclecu.unam.mx
  380.      <mailto:raiddev@nuclecu.unam.mx>
  381.  
  382.   ╖  majordomo@vger.rutgers.edu <mailto:majordomo@vger.rutgers.edu> send
  383.      a message to subscribe linux-raid
  384.  
  385.      send mail to: linux-raid@vger.rutgers.edu <mailto:linux-
  386.      raid@vger.rutgers.edu> (this seems to be the most active list)
  387.  
  388.  
  389.   3.  Quick Start for ROOT RAID
  390.  
  391.   If you don't want to try and build and debug the rescue system, you
  392.   can get a generic one created from Slackware-3.4 from:
  393.  
  394.        ftp.bizsystems.com/pub/raid/raidboot-0.01.tar.gz
  395.        <ftp://ftp.bizsystems.com/pub/raid/>
  396.  
  397.   Perform the following steps:
  398.  
  399.   ╖  Compile the raid enabled kernel with built in support for your disk
  400.      subsystem
  401.  
  402.   ╖  Test that the raid array will configure and mount correctly
  403.  
  404.   ╖  Build your OS on the raid system
  405.  
  406.   ╖  Correct the entries in fstab to show /dev/md0 as the root device.
  407.      Make sure that the partition(s) you use for booting are included in
  408.      fstab.
  409.  
  410.   ╖  Modify your shutdown halt and reboot script(s) (mine is
  411.      /etc/rc.d/rc.6) as shown in ``Modifying the rc-scripts for
  412.      SHUTDOWN''
  413.  
  414.   ╖  Copy the following from you development filesystem to the rescue
  415.      system AND the new raid system
  416.  
  417.  
  418.              cd /root/raidboot
  419.              mkdir mnt
  420.              gzip -d rescue.clean
  421.              losetup /dev/loop0  rescue.clean
  422.              mount /dev/loop0    mnt
  423.  
  424.      copy these files
  425.  
  426.              cp -p /etc/*         mnt/etc
  427.              cp -p /etc/rc.d/*    mnt/etc/rc.d
  428.                      {or as appropriate for your system}
  429.              cp -a /lib/modules/* mnt/lib/modules
  430.  
  431.  
  432.  
  433.   Correct the entries in fstab to show /dev/md0 as the root device. Make
  434.   sure that the partition(s) you use for booting is included in fstab.
  435.  
  436.  
  437.   Create /etc/raidboot.conf which describes the raid boot configuration.
  438.   This file may NOT contain comments in the first three lines, after
  439.   that it doesn't matter.
  440.  
  441.   raidboot.conf
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.           /dev/sda1 /dev/sda2
  464.           raidboot
  465.           raid5.conf
  466.   # comments may only be placed 'after' the three
  467.   # configuration lines.
  468.   #
  469.   # This is 'raidboot.conf'
  470.   #
  471.   # line one, the partition(s) containing the 'initrd' raid-rescue system
  472.   #       It is not necessary to boot from these partitions, however,
  473.   #       since the rescue system will not fit on floppy, it is necessary
  474.   #       to know which partitions are to be used to load the rescue system
  475.   #
  476.   # line two, the path to the raidboot config information
  477.   #       Where the shutdown status, etc... is located at boot time
  478.   #       It does NOT include the mount point information, only 'path'
  479.   #       /mntpoint/'path'
  480.   #
  481.   # line -3-, name of the raid configuration file
  482.   #       Current raid configuration file i.e. raid1.conf, raid5.conf
  483.  
  484.  
  485.   A few more things to do and the raid systems is ready to boot.
  486.  
  487.   Create ``rc.raidown'', as described in Appendix F, and copy it to
  488.   /etc/rc.d on the rescue, development, and raid system.  Unmount the
  489.   rescue system and zip it.
  490.  
  491.           umount mnt
  492.           losetup -d /dev/loop0
  493.           mv rescue.clean rescue
  494.           gzip rescue
  495.  
  496.  
  497.   Copy the rescue file to the raidboot partitions.
  498.  
  499.           cp rescue.gz /mnt_point(1)/raidboot
  500.           cp rescue.gz /mnt_point(2)/raidboot
  501.  
  502.  
  503.   Activate the raid array.
  504.  
  505.           mdadd -ar
  506.  
  507.  
  508.   Save the good reference status to the raidboot partition
  509.  
  510.           cat /proc/mdstat | grep md0 > /mnt_point(1)/raidboot/raidgood.ref
  511.           cat /proc/mdstat | grep md0 > /mnt_point(1)/raidboot/raidgood.ref
  512.  
  513.  
  514.   Lastly, configure the boot program as outlined in ``Boot Time Configu¡
  515.   ration Parameters'' and reboot your system onto the raid array.
  516.  
  517.  
  518.  
  519.  
  520.   4.  initrd- Cookbook for root mounted RAID
  521.  
  522.   This is the procedure to make an 'initrd' ramdisk with rescue tools
  523.   for raid.
  524.  
  525.   Specifically, this document referrs to RAID1 and RAID5
  526.   implementations.
  527.  
  528.  
  529.   4.1.  Security Reminder
  530.  
  531.   The rescue file system may be used stand alone. Should your raid array
  532.   fail to mount, you are left with the rescue system mounted and
  533.   running.  TAKE THE APPROPRIATE SECURITY PRECAUTIONS!!!
  534.  
  535.  
  536.   4.2.  Build the Kernel and Raid Tools
  537.  
  538.   The first thing that must be done is to patch and build your kernel
  539.   and become familiar with the raid tools. Make sure and include
  540.   ``Gadi's raid stop patch'' in Appendix E.  Configure, mount and test
  541.   your raid device(s). The details of how to do this are included in the
  542.   raidtools package and briefly reviewed later in this document.
  543.  
  544.  
  545.   4.3.  Build the initrd  Rescue and Boot filesystem
  546.  
  547.   I used the Slackware-3.4 distribution to build both the Rescue/Boot
  548.   filesystem and the filesystem for the production machine. Any linux
  549.   distribution should work fine. If you use a different distribution,
  550.   review the Slackware specific portion of this procedure and modify it
  551.   to suit your needs.
  552.  
  553.  
  554.   I use loadlin to boot the kernel image and ramdisk from a dos
  555.   partition simply because there are oddball devices in my system that
  556.   have dos configuration software. Lilo will work just as well and a
  557.   small linux partition can be used instead containing only the
  558.   raid/boot files and the lilo record.
  559.  
  560.   For the raid boot/rescue system, I chose to create a minimum ramdisk
  561.   system using the Slackware 'setup' script followed by installing the
  562.   'linuxthreads' package and 'raidtools' over the clean Slackware
  563.   installation on my ramdisk. I used the identical procedure to build
  564.   the production system. So the rescue and production systems are very
  565.   similar.
  566.  
  567.   This installation process gives me a 'bare' system (save a copy of the
  568.   file) to which I overlay
  569.  
  570.  
  571.           /lib/modules/2.x.x......
  572.           /etc .... with a modified fstab, mdtab, raidX.conf, raidboot.conf
  573.           /etc/rc.d
  574.           /dev/md*
  575.  
  576.  
  577.  
  578.   from my current system to customize it for the particular kernel and
  579.   machine that it is/will-be running on.
  580.  
  581.   This makes the boot/rescue system the same system that is running on
  582.   the root mounted raid device, just skinnyed down a bit, while allowing
  583.   the library, etc... revisions to always be current.
  584.  
  585.  
  586.   4.4.  Start the STEP by STEP instructions
  587.  
  588.   From the root home directory (/root):
  589.  
  590.  
  591.           cd /root
  592.           mkdir raidboot
  593.           cd raidboot
  594.  
  595.   Create a mountpoints to work on
  596.  
  597.  
  598.           mkdir mnt
  599.           mkdir mnt2
  600.  
  601.  
  602.  
  603.  
  604.   Make a file large enough to do the file system install. This will be a
  605.   lot larger than the final rescue file system.  I chose 24 megs since
  606.   16 megs is not large enough
  607.  
  608.           dd if=/dev/zero of=build bs=1024k count=24
  609.  
  610.  
  611.   associate the file with a loop device and generate an ext2 file system
  612.   on the file
  613.  
  614.  
  615.           losetup /dev/loop0 build
  616.           mke2fs -v -m0 -L initrd /dev/loop0
  617.           mount /dev/loop0 mnt
  618.  
  619.  
  620.  
  621.   4.5.  Install the distribution - Slackware Specific
  622.  
  623.   ``...skip Slackware Specific stuff'' and go to next section.
  624.  
  625.   Now that an empty filesystem is created and mounted, run "setup".
  626.  
  627.  
  628.   Specify         /root/raidboot/mnt
  629.  
  630.  
  631.  
  632.   as the 'target'.  The source is whatever you normally install from.
  633.   Select the packages you wish to install and proceed but DO NOT
  634.   configure.
  635.  
  636.   Choose 'EXPERT' prompting mode.
  637.  
  638.   I chose 'A', 'AP, and 'N' installing only the minimum to run the
  639.   system plus an editor I am familiar with (vi, jed, joe) that is
  640.   reasonably compact.
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.   lqqqqqqqq SELECTING PACKAGES FROM SERIES A (BASE LINUX SYSTEM) qqqqqqqqk
  662.   x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
  663.   x x   [X] aaa_base  Basic filesystem, shell, and utils - REQUIRED    x x
  664.   x x   [X] bash      GNU bash-1.14.7 shell - REQUIRED                 x x
  665.   x x   [X] devs      Device files found in /dev - REQUIRED            x x
  666.   x x   [X] etc       System config files & utilities - REQUIRED       x x
  667.   x x   [X] shadow    Shadow password suite - REQUIRED                 x x
  668.   x x   [ ] ide       Linux 2.0.30 no SCSI (YOU NEED 1 KERNEL)         x x
  669.   x x   [ ] scsi      Linux 2.0.30 with SCSI (YOU NEED 1 KERNEL)       x x
  670.   x x   [ ] modules   Modular Linux device drivers                     x x
  671.   x x   [ ] scsimods  Loadable SCSI device drivers                     x x
  672.   x x   [X] hdsetup   Slackware setup scripts - REQUIRED               x x
  673.   x x   [ ] lilo      Boots Linux (not UMSDOS), DOS, OS/2, etc.        x x
  674.   x x   [ ] bsdlpr    BSD lpr - printer spooling system                x x
  675.   x x   [ ] loadlin   Boots Linux (UMSDOS too!) from MS-DOS            x x
  676.   x x   [ ] pnp       Plug'n'Play configuration tool                   x x
  677.   x x   [ ] umsprogs  Utilities needed to use the UMSDOS filesystem    x x
  678.   x x   [X] sysvinit  System V-like INIT programs - REQUIRED           x x
  679.   x x   [X] bin       GNU fileutils 3.12, elvis, etc. - REQUIRED       x x
  680.   x x   [X] ldso      Dynamic linker/loader - REQUIRED                 x x
  681.   x x   [ ] ibcs2     Runs SCO/SysVr4 binaries                         x x
  682.   x x   [X] less      A text pager utility - REQUIRED                  x x
  683.   x x   [ ] pcmcia    PCMCIA card services support                     x x
  684.   x x   [ ] getty     Getty_ps 2.0.7e - OPTIONAL                       x x
  685.   x x   [X] gzip      The GNU zip compression - REQUIRED               x x
  686.   x x   [X] ps        Displays process info - REQUIRED                 x x
  687.   x x   [X] aoutlibs  a.out shared libs - RECOMMENDED                  x x
  688.   x x   [X] elflibs   The ELF shared C libraries - REQUIRED            x x
  689.   x x   [X] util      Util-linux utilities - REQUIRED                  x x
  690.   x x   [ ] minicom   Serial transfer and modem comm package           x x
  691.   x x   [ ] cpio      The GNU cpio backup/archiving utility            x x
  692.   x x   [X] e2fsbn    Utilities for the ext2 file system               x x
  693.   x x   [X] find      GNU findutils 4.1                                x x
  694.   x x   [X] grep      GNU grep 2.0                                     x x
  695.   x x   [ ] kbd       Change keyboard mappings                         x x
  696.   x x   [X] gpm       Cut and paste text with your mouse               x x
  697.   x x   [X] sh_utils  GNU sh-utils 1.16 - REQUIRED                     x x
  698.   x x   [X] sysklogd  Logs system and kernel messages                  x x
  699.   x x   [X] tar       GNU tar 1.12 - REQUIRED                          x x
  700.   x x   [ ] tcsh      Extended C shell version 6.07                    x x
  701.   x x   [X] txtutils  GNU textutils-1.22 - REQUIRED                    x x
  702.   x x   [ ] zoneinfo  Configures your time zone                        x x
  703.   x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
  704.  
  705.  
  706.   From the 'AP series, I use only 'JOE', and editor I like, and 'MC' a
  707.   small and useful file management tool. You choose the utilities you
  708.   will need on your system.
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.   lqqqqqqqqq SELECTING PACKAGES FROM SERIES AP (APPLICATIONS) qqqqqqqqqk
  728.   x x     [ ] ispell    The International version of ispell          x x
  729.   x x     [ ] jove      Jonathan's Own Version of Emacs text editor  x x
  730.   x x     [ ] manpgs    More man pages (online documentation)        x x
  731.   x x     [ ] diff      GNU diffutils                                x x
  732.   x x     [ ] sudo      Allow special users limited root access      x x
  733.   x x     [ ] ghostscr  GNU Ghostscript version 3.33                 x x
  734.   x x     [ ] gsfonts1  Ghostscript fonts (part one)                 x x
  735.   x x     [ ] gsfonts2  Ghostscript fonts (part two)                 x x
  736.   x x     [ ] gsfonts3  Ghostscript fonts (part three)               x x
  737.   x x     [ ] jed       JED programmer's editor                      x x
  738.   x x     [X] joe       joe text editor, version 2.8                 x x
  739.   x x     [ ] jpeg      JPEG image compression utilities             x x
  740.   x x     [ ] bc        GNU bc - arbitrary precision math language   x x
  741.   x x     [ ] workbone  a text-based audio CD player                 x x
  742.   x x     [X] mc        The Midnight Commander file manager          x x
  743.   x x     [ ] mt_st     mt ported from BSD - controls tape drive     x x
  744.   x x     [ ] groff     GNU troff document formatting system         x x
  745.   x x     [ ] quota     User disk quota utilities                    x x
  746.   x x     [ ] sc        The 'sc' spreadsheet                         x x
  747.   x x     [ ] texinfo   GNU texinfo documentation system             x x
  748.   x x     [ ] vim       Improved vi clone                            x x
  749.   x x     [ ] ash       A small /bin/sh type shell - 62K             x x
  750.   x x     [ ] zsh       Zsh - a custom *nix shell                    x x
  751.   x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
  752.  
  753.  
  754.   From the 'N' package I only loaded TCPIP.  This isn't really neces¡
  755.   sary, but is very handy and allows access to the network while working
  756.   on a repair or update with the root raid array dismounted. TCPIP also
  757.   contains 'biff' which is used by some of the applications in 'A'. If
  758.   you don't install 'N' you might want to install the biff package any¡
  759.   way.
  760.  
  761.   lqqqq SELECTING PACKAGES FROM SERIES N (NETWORK/NEWS/MAIL/UUCP) qqqqqk
  762.   x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
  763.   x x    [ ] apache    Apache WWW (HTTP) server                      x x
  764.   x x    [ ] procmail  Mail delivery/filtering utility               x x
  765.   x x    [ ] dip       Handles SLIP/CSLIP connections                x x
  766.   x x    [ ] ppp       Point-to-point protocol                       x x
  767.   x x    [ ] mailx     The mailx mailer                              x x
  768.   x x    [X] tcpip     TCP/IP networking programs                    x x
  769.   x x    [ ] bind      Berkeley Internet Name Domain server          x x
  770.   x x    [ ] rdist     Remote file distribution utility              x x
  771.   x x    [ ] lynx      Text-based World Wide Web browser             x x
  772.   x x    [ ] uucp      Taylor UUCP 1.06.1 with HDB && Taylor configs x x
  773.   x x    [ ] elm       Menu-driven user mail program                 x x
  774.   x x    [ ] pine      Pine menu-driven mail program                 x x
  775.   x x    [ ] sendmail  The sendmail mail transport agent             x x
  776.   x x    [ ] metamail  Metamail multimedia mail extensions           x x
  777.   x x    [ ] smailcfg  Extra configuration files for sendmail        x x
  778.   x x    [ ] cnews     Spools and transmits Usenet news              x x
  779.   x x    [ ] inn       InterNetNews news transport system            x x
  780.   x x    [ ] tin       The 'tin' news reader (local or NNTP)         x x
  781.   x x    [ ] trn       'trn' for /var/spool/news                     x x
  782.   x x    [ ] trn-nntp  'trn' for NNTP (install 1 'trn' maximum)      x x
  783.   x x    [ ] nn-spool  'nn' for /var/spool/news                      x x
  784.   x x    [ ] nn-nntp   'nn' for NNTP (install 1 'nn' maximum)        x x
  785.   x x    [ ] netpipes  Network pipe utilities                        x x
  786.   x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
  787.  
  788.  
  789.   With the installation complete, say no to everything else (no to all
  790.   configuration requests) and exit the script.
  791.  
  792.  
  793.   4.6.  Install linux pthreads
  794.  
  795.   Now you must install the 'linuxthreads-0.71' library.  I have included
  796.   this diff for the linuxthreads Makefile rather than explain the
  797.   details of the installation by hand.  Save the original Makefile,
  798.   apply the diff and then:
  799.  
  800.  
  801.           cd /usr/src/linuxthreads-0.71
  802.     patch
  803.           make
  804.           make install
  805.  
  806.  
  807.  
  808.   -------------------diff Makefile.old  Makefile.raid-----------------
  809.   2a3,13
  810.   > # If you are building "linuxthreads" for installation on a mount
  811.   > # point which is not the "root" partition, redefine 'BUILDIR' to
  812.   > # the mount point to use as the "root" directory
  813.   > # You may wish to do this if you are building an 'initial ram disk'
  814.   > # such as used with bootable root raid devices.
  815.   > # REQUIRES ldconfig version 1.9.5 or better
  816.   > # do ldconfig -v to check
  817.   > #
  818.   > BUILDIR=/root/raidboot/mnt
  819.   > #BUILDIR=
  820.   >
  821.   81,82c92,93
  822.   <       install pthread.h $(INCLUDEDIR)/pthread.h
  823.   <       install semaphore.h $(INCLUDEDIR)/semaphore.h
  824.   ---
  825.   >       install pthread.h $(BUILDIR)$(INCLUDEDIR)/pthread.h
  826.   >       install semaphore.h $(BUILDIR)$(INCLUDEDIR)/semaphore.h
  827.   84c95
  828.   <       test -f /usr/include/sched.h || install sched.h $(INCLUDEDIR)/sched.h
  829.   ---
  830.   >       test -f $(BUILDIR)/usr/include/sched.h || install sched.h $(BUILDIR)$(INCLUDEDIR)/sched.h
  831.   86,89c97,103
  832.   <       install $(LIB) $(LIBDIR)/$(LIB)
  833.   <       install $(SHLIB) $(SHAREDLIBDIR)/$(SHLIB)
  834.   <       rm -f $(LIBDIR)/$(SHLIB0)
  835.   <       ln -s $(SHAREDLIBDIR)/$(SHLIB) $(LIBDIR)/$(SHLIB0)
  836.   ---
  837.   >       install $(LIB) $(BUILDIR)$(LIBDIR)/$(LIB)
  838.   >       install $(SHLIB) $(BUILDIR)$(SHAREDLIBDIR)/$(SHLIB)
  839.   >       rm -f $(BUILDIR)$(LIBDIR)/$(SHLIB0)
  840.   >       ln -s $(SHAREDLIBDIR)/$(SHLIB) $(BUILDIR)$(LIBDIR)/$(SHLIB0)
  841.   > ifneq ($(BUILDIR),)
  842.   >       ldconfig -r ${BUILDIR} -n $(SHAREDLIBDIR)
  843.   > else
  844.   91c105,106
  845.   <       cd man; $(MAKE) MANDIR=$(MANDIR) install
  846.   ---
  847.   > endif
  848.   >       cd man; $(MAKE) MANDIR=$(BUILDIR)$(MANDIR) install
  849.  
  850.  
  851.  
  852.  
  853.   4.7.  Install Raid Tools
  854.  
  855.   The next step is the installation of the raid tools.  raidtools-0.42
  856.  
  857.   You must run the "configure" script to point the Makefile at the build
  858.   directory for the ramdisk files
  859.     cd /usr/src/raidtools-0.42
  860.     configure --sbindir=/root/raidboot/mnt/sbin --prefix=/root/raidboot/mnt/usr
  861.     make
  862.     make install
  863.  
  864.  
  865.   Now!! the Makefile for install is not quite right so do the following
  866.   to clean up. This will be fixed in future releases so that the re-
  867.   linking will not be necessary.
  868.  
  869.  
  870.        Fix the make install error
  871.  
  872.  
  873.   The file links specified in the Makefile at 'LINKS' must be removed
  874.   and re-linked to operate properly.
  875.  
  876.           cd /root/raidboot/mnt/sbin
  877.           ln -fs mdadd mdrun
  878.           ln -fs mdadd mdstop
  879.  
  880.  
  881.  
  882.  
  883.   4.8.  Remove un-needed directories and files from new filesystem.
  884.  
  885.   Delete the following directories from filesystem (CAUTION DON'T DELETE
  886.   FROM YOUR RUNNING SYSTEM) it's easy to do, guess how I found out!!!
  887.  
  888.           cd /root/raidboot/mnt
  889.           rm -r home/ftp/*
  890.           rm -r lost+found
  891.           rm -r usr/doc
  892.           rm -r usr/info
  893.           rm -r usr/local/man
  894.           rm -r usr/man
  895.           rm -r usr/openwin
  896.           rm -r usr/share/locale
  897.           rm -r usr/X*
  898.           rm -r var/man
  899.           rm -r var/log/packages
  900.           rm -r var/log/setup
  901.           rm -r var/log/disk_contents
  902.  
  903.  
  904.  
  905.  
  906.   4.9.  Create /dev/md x
  907.  
  908.   The last step simply copies the /dev/md* devices from the current file
  909.   system onto the rescue file system.  You could create these with
  910.   mknode.
  911.  
  912.           cp -a /dev/md* /root/raidboot/mnt/dev
  913.  
  914.  
  915.  
  916.   4.10.  Create a bare filesystem suitable for initrd
  917.  
  918.   Now you have a clean re-useable filesystem ready for customization.
  919.   Once customized, this file system can be used for rescue should the
  920.   raid device(s) become corrupted and the raid tools needed to fix them.
  921.   It will also be used to boot and root-mount the raid device by adding
  922.   the linuxrc file which will be discussed next.
  923.  
  924.  
  925.   Copy the file system to a smaller device for the initrd file, 16 megs
  926.   should be large enough.
  927.  
  928.   Create the smaller file system and mount it
  929.  
  930.           cd /root/raidboot
  931.           dd if=/dev/zero of=bare.fs bs=1024k count=16
  932.  
  933.  
  934.   associate the file with a loop device and generate a ext2 file system
  935.   on the file
  936.  
  937.           losetup /dev/loop1 bare.fs
  938.           mke2fs -v -m0 -L initrd /dev/loop1
  939.           mount /dev/loop1 mnt2
  940.  
  941.  
  942.   Copy the 'build' file system to 'bare.fs'
  943.  
  944.           cp -a mnt/* mnt2
  945.  
  946.  
  947.   Save the 'bare.fs' system before customization so later update is
  948.   easy.  The 'build' file system is no longer needed and may be deleted.
  949.  
  950.           cd /root/raidboot
  951.           umount mnt
  952.           umount mnt2
  953.           losetup -d /dev/loop0
  954.           losetup -d /dev/loop1
  955.           rm build
  956.           cp bare.fs rescue
  957.           gzip -9 bare.fs
  958.  
  959.  
  960.  
  961.   4.10.1.  Create the BOOT/RESCUE initrd  filesystem
  962.  
  963.   Now copy the system dependent items that match the kernel from the
  964.   development platform, or you can manually modify the files in the
  965.   rescue file system to match your target system.
  966.  
  967.           losetup /dev/loop0 rescue
  968.           mount /dev/loop0 mnt
  969.  
  970.  
  971.   Make sure your etc directory is clean of *~, core and log files.  The
  972.   next 2 commands creates some warning messages, ignore them.
  973.  
  974.           cp -dp /etc/* mnt/etc
  975.           cp -dp /etc/rc.d/* mnt/etc/rc.d
  976.  
  977.           mkdir  mnt/lib/modules
  978.           cp -a  /lib/modules/2.x.x mnt/lib/modules <--- your current 2.x.x
  979.  
  980.  
  981.   Edit the following files to correct them for your rescue system.
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.           cd mnt
  992.  
  993.   Non-network
  994.           etc/fstab
  995.           etc/mdtab       should work OK
  996.   Network
  997.           etc/hosts
  998.           etc/resolv.conf
  999.           etc/hosts.equiv         and related files
  1000.           etc/rc.d/rc.inet1       correct ip#, mask, gateway, etc...
  1001.           etc/rc.d/rc.S           remove entire section on file system status
  1002.                   from:
  1003.                           # Test to see if the root partition isread-only
  1004.                   to but not including:
  1005.                           # remove /etc/mtab* so that mount will .....
  1006.                                   This avoids the annoying warning that
  1007.                                   the ramdisk is mounted rw.
  1008.           etc/rc.d/rc.xxxxx       others as required, see later on in this doc
  1009.           root/.rhosts            if present
  1010.           home/xxxx/xxxx          others as required
  1011.  
  1012.       WARNING:    The above procedure moves your password and shadow
  1013.                   files onto the rescue disk!!!!!
  1014.  
  1015.       WARNING:    You may not wish to do this for security reasons.
  1016.  
  1017.  
  1018.   Create any directories for mounting /dev/disk... as may be required
  1019.   that are unique to your system.  These are the mountpoints for booting
  1020.   the system (boot partition and backup boot partition). My system boot
  1021.   from dos using loadlin, however linux partition(s) and lilo will work
  1022.   fine.  My system uses:
  1023.  
  1024.           cd /root/raidboot/mnt           <--- initrd root
  1025.           mkdir dosa                      dos partition mount point
  1026.           mkdir dosb                      dos mirror mount point
  1027.  
  1028.  
  1029.   The rescue file system is complete!
  1030.  
  1031.   You will note upon examination of the files in the rescue file system,
  1032.   that there are still many files that could be deleted.  I have not
  1033.   done this since it would overly complicate this procedure and most
  1034.   raid systems have adequate disk and memory.  If you wish to skinny
  1035.   down the file system, go to it!
  1036.  
  1037.  
  1038.   4.11.  Making 'initrd' boot the RAID device - linuxrc
  1039.  
  1040.   To make the rescue disk boot the raid device, you need only copy the
  1041.   executable script file:
  1042.  
  1043.  
  1044.        linuxrc
  1045.  
  1046.  
  1047.   to the root of the device.
  1048.  
  1049.   The theory of operation for this linuxrc file is discussed in
  1050.   ``Appendix G, linuxrc theory of operation''.
  1051.  
  1052.   A very simple and much easier to understand (working) linuxrc is
  1053.   included in ``Appendix D'', obsolete linuxrc and shutdown scripts.
  1054.   Copy the following text to linuxrc and save in your development area.
  1055.  
  1056.  
  1057.    -------------------- linuxrc ----------------------
  1058.   #!/bin/sh
  1059.   # ver 1.13 3-6-98
  1060.   #
  1061.   ################# BEGIN 'linuxrc' ##################
  1062.   #                DEFINE FUNCTIONS                  #
  1063.   ####################################################
  1064.   # Define 'Fault' function in the event something
  1065.   # goes wrong during the execution of 'linuxrc'
  1066.   #
  1067.   FaultExit () {
  1068.   # correct fstab to show '/dev/ram0' for rescue system
  1069.       /bin/cat /etc/fstab | {
  1070.       while read Line
  1071.       do
  1072.           if [ -z "$( echo ${Line} | /usr/bin/grep md0 )" ]; then
  1073.               echo ${Line}
  1074.           else
  1075.               echo "/dev/ram0 / ext2 defaults 1 1"
  1076.           fi
  1077.       done
  1078.       } > /etc/tmp.$$
  1079.       /bin/mv /etc/tmp.$$ /etc/fstab
  1080.   #       point root at /dev/ram0 (the rescue system)
  1081.           echo 0x100>/proc/sys/kernel/real-root-dev
  1082.           /bin/umount /proc
  1083.           exit
  1084.   }
  1085.  
  1086.   # Define 'Warning' procdure to print banner on boot terminal
  1087.   #
  1088.   Warning () {
  1089.       echo '*********************************'
  1090.       echo -e " $*"
  1091.       echo '*********************************'
  1092.   }
  1093.  
  1094.   # Define 'SplitKernelArg' to help extract 'Raid' related kernel arguments
  1095.   SplitKernelArg () { eval $1='$( IFS=,; echo $2)' }
  1096.  
  1097.   #Define 'SplitConfArgs' to help extract system configuration arguments
  1098.   SplitConfArgs () {
  1099.       RaidBootType=$1
  1100.       RaidBootDevice=$2
  1101.       RaidConfigPath=$3
  1102.   }
  1103.   ########################################################
  1104.   ################### MAIN linuxrc #######################
  1105.   ########################################################
  1106.   # mount the proc file system
  1107.   /bin/mount /proc
  1108.  
  1109.   # Get the boot partition and configuration location from command line
  1110.   CMDLINE=`/bin/cat /proc/cmdline`
  1111.   for Parameter in $CMDLINE; do
  1112.       Parameter=$( IFS='='; echo ${Parameter} )
  1113.       case $Parameter in
  1114.           Raid*) SplitKernelArg $Parameter;;
  1115.       esac
  1116.   done
  1117.  
  1118.   # check for 'required raid boot'
  1119.   if [ -z "${Raid_Conf}" ]; then
  1120.       Warning Kernel command line \'Raid_Conf\' missing
  1121.       FaultExit
  1122.   fi
  1123.   SplitConfArgs $Raid_Conf
  1124.  
  1125.   # tmp mount the boot partition
  1126.   /bin/mount -t ${RaidBootType} ${RaidBootDevice} /mnt
  1127.  
  1128.   # get etc files from primary raid system
  1129.   pushd /etc
  1130.  
  1131.   # this will un-tar into 'etc' (see rc.6)
  1132.   if [ ! -f /mnt/${RaidConfigPath}/raidboot.etc ]; then
  1133.   # bad news, this file should be here
  1134.       Warning required file \'raidboot.etc\' \
  1135.       missing from ${RaidBootDevice}/${RaidConfigPath} \\n \
  1136.       \\tUsing rescue system defaults
  1137.   else
  1138.       /bin/tar -xf /mnt/${RaidConfigPath}/raidboot.etc
  1139.   fi
  1140.   # get 'real' raidboot device for this boot
  1141.   # status path, and name of raidX.conf
  1142.   if [ ! -f /mnt/${RaidConfigPath}/raidboot.cfg ]; then
  1143.   # bad news, this file should be here
  1144.       Warning required file 'raidboot.cfg' \
  1145.       missing from ${RaidBootDevice}/${RaidConfigPath}\\n \
  1146.       \\tUsing rescue system defaults
  1147.   # Get the first raidX.conf file name in $RArg1
  1148.       RaidBootDevs=$RaidBootDevice
  1149.       RaidStatusPath=$RaidConfigPath
  1150.       for RaidConfigEtc in $( ls raid*.conf )
  1151.       do break; done
  1152.   else
  1153.       {
  1154.       read RaidBootDevs
  1155.       read RaidStatusPath
  1156.       read RaidConfigEtc
  1157.       } < /mnt/${RaidConfigPath}/raidboot.cfg
  1158.  
  1159.   fi
  1160.   popd
  1161.   /bin/umount /mnt
  1162.  
  1163.   # Set a flag in case the raid status file is not found
  1164.   #
  1165.   RAIDOWN="raidboot.ro not found"
  1166.   RAIDREF="raidgood.ref not found"
  1167.   echo "Reading md0 shutdown status."
  1168.  
  1169.   # search for raid shutdown status
  1170.   for Device in ${RaidBootDevs}
  1171.   do
  1172.   #   these filesystem types should be in 'fstab' since
  1173.   #   the partitions must be mounted for a clean raid shutdown
  1174.       /bin/mount ${Device} /mnt
  1175.       if [ -f /mnt/${RaidStatusPath}/raidboot.ro ]; then
  1176.           RAIDOWN=`/bin/cat /mnt/${RaidStatusPath}/raidboot.ro`
  1177.           RAIDREF=`/bin/cat /mnt/${RaidStatusPath}/raidgood.ref`
  1178.           /bin/umount /mnt
  1179.           break
  1180.       fi
  1181.       /bin/umount /mnt
  1182.   done
  1183.   # Test for a clean shutdown with array matching reference
  1184.   if [ "${RAIDOWN}" != "${RAIDREF}" ]; then
  1185.       Warning shutdown ERROR ${RAIDOWN}
  1186.       FaultExit
  1187.   fi
  1188.  
  1189.   # The raid array is clean, remove shutdown status files
  1190.   for Device in ${RaidBootDevs}
  1191.   do
  1192.       /bin/mount ${Device} /mnt
  1193.       /bin/rm -f /mnt/${RaidStatusPath}/raidboot.ro
  1194.       /bin/umount /mnt
  1195.   done
  1196.  
  1197.   # Write a clean superblock on all raid devices
  1198.  
  1199.   echo "write clean superblocks"
  1200.   /sbin/mkraid -f --only-superblock /etc/${RaidConfigEtc}
  1201.  
  1202.   # Activate raid array(s)
  1203.   if [ -z "$Raid_ALT" ]; then
  1204.       /sbin/mdadd -ar
  1205.   else
  1206.       /sbin/mdadd $Raid_ALT
  1207.   fi
  1208.  
  1209.   #  If there are errors - BAIL OUT and leave rescue running
  1210.   if [ $? -ne 0 ]; then
  1211.      Warning some RAID device has errors
  1212.      FaultExit
  1213.   fi
  1214.  
  1215.   # Everything is fine, let the kernel mount /dev/md0
  1216.   # tell the kernel to switch to /dev/md0 as the /root device
  1217.   # The 0x900 value is the device number calculated by:
  1218.   #  256*major_device_number + minor_device number
  1219.   echo "/dev/md0 mounted on root"
  1220.   echo 0x900>/proc/sys/kernel/real-root-dev
  1221.   # umount /proc to deallocate initrd device ram space
  1222.   /bin/umount /proc
  1223.   exit
  1224.   #------------------ end linuxrc ----------------------
  1225.  
  1226.  
  1227.   Add 'linuxrc' to initrd boot device
  1228.  
  1229.           cd /root/raidboot
  1230.           chmod 777 linuxrc
  1231.           cp -p linuxrc mnt
  1232.  
  1233.  
  1234.  
  1235.  
  1236.   4.12.  Modifying the rc-scripts for SHUTDOWN
  1237.  
  1238.   To complete the installation, modify the rc scripts to save the md
  1239.   status to the real root device when shutdown occurs.
  1240.  
  1241.   In slackware this is rc.0 -> rc.6
  1242.   In debian 'bo' this is in both 'halt' and 'reboot'
  1243.  
  1244.   If you implement this in another distribution, please e-mail
  1245.   the instructions and sample files so they can be included here.
  1246.  
  1247.  
  1248.   I have modified Bohumil Chalupa's raid stop work-around slightly. His
  1249.   original solution is presented in ``Appendix A''.
  1250.  
  1251.   Since there are no linux partitions left on the production system
  1252.   except md0, the boot partitions are used to store the raidOK readonly
  1253.   status.  I chose to write a file to each of the duplicate boot
  1254.   partitions containing the status of the md array at shutdown and
  1255.   signifying that the md device has been remounted RO. This allows the
  1256.   system to be fail safe when any of the hard drives die.
  1257.  
  1258.   The shutdown script is modified to call ``rc.raidown'' which saves the
  1259.   necessary information to successfully reboot and mount the raid
  1260.   device. Examples of shutdown scripts for various linux distributions
  1261.   are shown in ``Appendix B''.
  1262.  
  1263.  
  1264.   To capture the raid array shutdown status insert a call to
  1265.   ``rc.raidown'' after any case statements (if present) but before the
  1266.   actual shutdown (kills, status saves, etc...) begins and before the
  1267.   file systems are dismounted.
  1268.  
  1269.   ############ Save raid boot and status info ##############
  1270.   #
  1271.     if [ -x /etc/rc.d/rc.raidown ]; then
  1272.       /etc/rc.d/rc.raidown
  1273.     fi
  1274.   ################## end raid boot #########################
  1275.  
  1276.  
  1277.   After all the file systems are dismounted (the root file system
  1278.  
  1279.   ################ for raid arrays #########################
  1280.   # Stop all known raid arrays (except root which won't stop)
  1281.     if [ -x /sbin/mdstop ]; then
  1282.       echo "Stopping raid"
  1283.       /sbin/mdstop -a
  1284.     fi
  1285.   ##########################################################
  1286.  
  1287.  
  1288.   This will cleanly stop all raid devices except root.  Root status is
  1289.   passed to the next boot in raidstat.ro.
  1290.  
  1291.  
  1292.   Copy the rc file to your new raid array, the rescue file system that
  1293.   is still mounted on /root/raidboot/mnt and the development system if
  1294.   it is on the same machine.
  1295.  
  1296.   Modify rescue etc/fstab as needed and make sure rescue mdtab is
  1297.   correct.
  1298.  
  1299.   Now copy the rescue disk to your dos partition and everything should
  1300.   be ready to boot the raid device as root.
  1301.  
  1302.           umount mnt
  1303.           losetup -d /dev/loop0
  1304.           gzip -9 rescue
  1305.  
  1306.  
  1307.   Copy rescue.gz to your boot partitions.
  1308.  
  1309.   All that remains is to creat the configuration file raidboot.conf and
  1310.   test the new file system  by rebooting.
  1311.  
  1312.  
  1313.   4.13.  Configuring RAIDBOOT - raidboot.conf
  1314.  
  1315.   The comments following the example configuration file explain each of
  1316.   the three lines. This example file is for a 4 drive raid5 scsii array
  1317.   with duplicate boot partitions on drives sda1 and sdb1. Put the
  1318.   paramaters descriptive of your file systems here instead.
  1319.  
  1320.  
  1321.     /dev/sda1 /dev/sdb1
  1322.     linux
  1323.     raid5.conf
  1324.   # comments may only be placed 'after' the three
  1325.   # configuration lines.
  1326.   #
  1327.   # This is 'raidboot.conf'
  1328.   #
  1329.   # line one, the partition(s) containing the 'initrd' raid-rescue system
  1330.   #       It is not necessary to boot from these partitions, however,
  1331.   #       since the rescue system will not fit on floppy, it is necessary
  1332.   #       to know which partitions are to be used to load the rescue system
  1333.   #
  1334.   # line two, the path to the raidboot config information
  1335.   #       Where the shutdown status, etc... is located at boot time
  1336.   #       It does NOT include the mount point information, only 'path'
  1337.   #       /mntpoint/'path'
  1338.   #
  1339.   # line -3-, name of the raid configuration file
  1340.   #       Current raid configuration file i.e. raid1.conf, raid5.conf
  1341.  
  1342.  
  1343.  
  1344.  
  1345.   4.14.  Kernel 'loadlin and lilo' variables for RESCUE and RAID
  1346.  
  1347.   There are two kernel variables for the RESCUE and RAID system, only
  1348.   the first need be specified.
  1349.  
  1350.   ╖  Raid_Conf=msdos,/dev/sda1,raidboot
  1351.  
  1352.        This variable points to raid boot device and configuration
  1353.        file.  For floppy rescue boot, you may want to specify this
  1354.        on the kernel command line or in the loadlin or lilo boot
  1355.        file
  1356.  
  1357.  
  1358.        format: 'filesystem-type,device,path-to-config-from-mount¡
  1359.        point'
  1360.  
  1361.  
  1362.   ╖  Raid_ALT=-r,-p5,/dev/md0,/dev/sda3 /dev/sdb3 /dev/sdc3 /dev/sdd3
  1363.  
  1364.        Alternate mdadd parameters necessary when booting with non-
  1365.        redundant raid array. These are the comma separated command
  1366.        line parameters for mdadd. Unless they are needed to start a
  1367.        failed/non-redundant array, COMMENT OUT OR SPECIFY WITH A
  1368.        'NULL'.
  1369.  
  1370.  
  1371.        i.e. Raid_ALT=
  1372.  
  1373.  
  1374.   Either of these parameters may be specified in the lilo or loadlin
  1375.   boot parameter file or on the loadlin kernel command line. Care must
  1376.   be taken that the maximum line length is not exceeded, however, if the
  1377.   command line is used (128 characters).
  1378.  
  1379.  
  1380.   When booting with lilo, the parameters are included in the lilo config
  1381.   file in the form:
  1382.  
  1383.   append="Raid_Conf=msdos,/dev/sda1,raidboot"
  1384.   append="Raid_ALT=-r,-p5,/dev/md0,/dev/sda3 /dev/sdb3 /dev/sdc3 /dev/sdd3"
  1385.  
  1386.  
  1387.   See man lilo.conf for more detailed information.
  1388.  
  1389.   Since I have some hardware that requires DOS configuration utilities,
  1390.   I have a small dos partition on the system.  Therefore, I used loadlin
  1391.   to boot the raid5 system from the dos partition with a mirror (copy)
  1392.   on the companion disk. An identical method is used for the raid1
  1393.   system. The example below uses loadlin, but the procedure is very
  1394.   similar for lilo.
  1395.  
  1396.   My dos root system contains a small editor among the utilities so I
  1397.   can modify the boot parameters of loadlin if necessary, allowing me to
  1398.   reboot the linux system on my swap disk while testing.
  1399.  
  1400.   The dos system contains this tree for linux
  1401.  
  1402.           c:\raidboot.bat
  1403.           c:\raidboot\loadlin.exe
  1404.           c:\raidboot\zimage
  1405.           c:\raidboot\rescue.gz
  1406.           c:\raidboot\raidboot.cfg
  1407.           c:\raidboot\raidboot.etc
  1408.           c:\raidboot\raidgood.ref
  1409.           c:\raidboot\raidstat.ro       (only at shutdown)
  1410.  
  1411.  
  1412.   ---------------------- linux.bat ---------------------------
  1413.   echo "Start the LOADLIN process:"
  1414.   c:\raidboot\loadlin @c:\raidboot\boot.par
  1415.   -------------------- end linux.bat -------------------------
  1416.  
  1417.  
  1418.   boot.par contains:
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.           # loadlin boot parameter file
  1454.           #
  1455.           # version 1.02 3-6-98
  1456.  
  1457.           # linux kernel image
  1458.           c:\linux\zimage
  1459.  
  1460.           # target root device
  1461.           root=/dev/md0
  1462.           #root=/dev/ram0
  1463.           #root=/dev/sdc5
  1464.  
  1465.           # mount root device as 'ro'
  1466.           ro
  1467.  
  1468.           # size of ram disk
  1469.           ramdisk_size=16384
  1470.  
  1471.           # initrd file name
  1472.           initrd=c:\raidboot\rescue.gz
  1473.           #noinitrd
  1474.  
  1475.           # memory ends here
  1476.           mem=131072k
  1477.  
  1478.           # points to raid boot device, configuration file
  1479.           # for floppy rescue boot, you may want to specify
  1480.           # this on the command line instead of here
  1481.           # format 'filesystem-type,device,path-to-config-frm_mntpnt'
  1482.           Raid_Conf=msdos,/dev/sda1,raidboot
  1483.  
  1484.           # Alternate mdadd parameters
  1485.           # necessary when boot with non-redundant raid
  1486.           # otherwise, COMMENT OUT OR SPECIFY 'NULL'
  1487.           #Raid_ALT=-r,-p5,/dev/md0,/dev/sda3 /dev/sdb3 /dev/sdc3 /dev/sdd3
  1488.  
  1489.           # ethernet devices
  1490.           ether=10,0x300,eth0
  1491.  
  1492.   ***** >> NOTE!! the only difference between forcing the rescue system to
  1493.               run and the raid device mounting, is the loadlin parameter
  1494.  
  1495.                   root=/dev/ram0          for the rescue system
  1496.                   root=/dev/md0           for RAID
  1497.  
  1498.                   With root=/dev/ram0 the RAID device will not mount
  1499.                   and the rescue system will run unconditionally.
  1500.  
  1501.  
  1502.  
  1503.   If the RAID array fails, the rescue system is left mounted and
  1504.   running.
  1505.  
  1506.  
  1507.   5.  Configuring the Production RAID system.
  1508.  
  1509.  
  1510.   5.1.  Two systems with identical motherboards were configured.  System
  1511.   specs.
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.                                     Raid-1          Raid-5
  1520.   Motherboard:    Iwill P55TU     dual ide        adaptec scsi
  1521.   Processor:      Intel P200
  1522.   Disks:                          2ea  7 gig      4 ea Segate 4.2 gig
  1523.                                   Maxtors         wide scsii
  1524.  
  1525.  
  1526.   The disk drives are designated by linux as 'sda' through 'sdd' on the
  1527.   raid5 system and 'hda' and 'hdc' on the raid1 system.
  1528.  
  1529.  
  1530.   5.2.  Partitioning the hard drives.
  1531.  
  1532.   Since testing a large root mountable RAID array is difficult because
  1533.   of the ckraid re-boot problem, I re-partitioned my swap space to
  1534.   include a smaller RAID partition for testing purposes,
  1535.   sda6,sdb6,sdc6,sdd6, and a small root and /usr/src partition pair for
  1536.   developing and testing the raid kernel and tools.  You may find this
  1537.   helpful.
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.           <bf/DEVELOPMENT SYSTEM - RAID5/
  1586.      Device       System          Size    Purpose
  1587.  
  1588.     /dev/sda1     dos boot        16 meg  boot partition
  1589.   * /dev/sda2     extended        130 meg (see below)
  1590.     /dev/sda3     linux native    4 gig   primary raid5-1
  1591.   ----------------------sda2------------------------------
  1592.   * /dev/sda5     linux swap      113 meg SWAP space
  1593.   * /dev/sda6     linux native    16 meg  test raid5-1
  1594.   ========================================================
  1595.     /dev/sdb1     dos boot        16 meg  boot partition duplicate
  1596.   * /dev/sdb2     extended        130 meg (see below)
  1597.     /dev/sdb3     linux native    4 gig   primary raid5-2
  1598.   ----------------------sdb2------------------------------
  1599.   * /dev/sdb5     linux swap      113 meg SWAP space
  1600.   * /dev/sdb6     linux native    16 meg  test raid5-2
  1601.   ========================================================
  1602.   * /dev/sdc2     extended        146 meg (see below)
  1603.     /dev/sdc3     linux native    4 gig   primary raid5-3
  1604.   ----------------------sdc2------------------------------
  1605.   * /dev/sdc5     linux swap      130 meg development root partition
  1606.   * /dev/sdc6     linux native    16 meg  test raid5-3
  1607.   ========================================================
  1608.   * /dev/sdd2     extended        146 meg (see below)
  1609.     /dev/sdd3     linux native    4 gig   primary raid5-4
  1610.   ----------------------sdd2------------------------------
  1611.   * /dev/sdd5     linux swap      130 meg development /usr/src
  1612.   * /dev/sdd6     linux native    16 meg  test raid5-4
  1613.  
  1614.  
  1615.           <bf/DEVELOPMENT SYSTEM - RAID1/
  1616.      Device       System          Size    Purpose
  1617.  
  1618.     /dev/hda1     dos             16meg   boot partition
  1619.   * /dev/hda2     extended        126m    (see below)
  1620.     /dev/hda3     linux           126m    development root partition
  1621.     /dev/hda4     linux           6+gig   raid1-1
  1622.   ----------------------hda2------------------------------
  1623.   * /dev/hda5     linux            26m    test raid1-1
  1624.   * /dev/hda6     linux swap      100m
  1625.   ========================================================
  1626.  
  1627.     /dev/hdc1     is simply an exact copy of hda1 so the
  1628.                   partion can be made active if hda fails
  1629.   * /dev/hdc2     extended        126m    (see below)
  1630.     /dev/hdc3     linux           126m    development /usr/src
  1631.     /dev/hdc4     linux           6+gig   raid1-2
  1632.   ----------------------hdc2------------------------------
  1633.   * /dev/hdc5     linux            26m    test raid1-2
  1634.   * /dev/hdc6     linux swap      100m
  1635.  
  1636.  
  1637.   The sdx2 and hdx3 partitions were switched to 'swap' after developing
  1638.   this utility. I could have done it on another machine, however, the
  1639.   libraries and kernels are all about a year or more out of date on my
  1640.   other linux boxes and I preferred to build it on the target machine.
  1641.  
  1642.   The partitioning scheme was chosen so that in the event that any one
  1643.   of the drives fails catastrophically, the system will continue to run
  1644.   and be bootable with minimum effort and NO data loss.
  1645.  
  1646.   ╖  If any single hard drive fails, the boot will abort, and the rescue
  1647.      system will run. Examination of the screen message or
  1648.      /dosx/raidboot/raidstat.ro will tell the operator the status of the
  1649.      failed array.
  1650.  
  1651.   ╖  If sda1 (raid5) or hda1 (raid1) fails, the dos backup boot
  1652.      partition must be made 'active' and the bios must recognize the new
  1653.      partition as the boot device or it must be physically be moved to
  1654.      the xda position.  Alternatively, the system could be booted from a
  1655.      floppy disk using the initrd image on the remaining backup boot
  1656.      drive.  The raid system can then be made active again by issuing:
  1657.  
  1658.               "/sbin/mkraid /etc/raid<it/x/.conf -f --only-superblock"
  1659.  
  1660.  
  1661.   to rebuild the remaining superblock(s).
  1662.  
  1663.   ╖  Once this is done, then
  1664.  
  1665.  
  1666.              mdadd -ar
  1667.  
  1668.  
  1669.  
  1670.   ╖  Examine the status of the array to verify that everything is OK
  1671.      then replace the good array reference with the current status until
  1672.      the failed disk can be repaired or replaced.
  1673.  
  1674.  
  1675.              cat /proc/mdstat | grep md0 > /dosx/raidboot/raidgood.ref
  1676.  
  1677.              shutdown -r now
  1678.  
  1679.  
  1680.   to do a clean reboot, and the system is up again.
  1681.  
  1682.   6.  Building the RAID file system.
  1683.  
  1684.   This description is for my RAID systems described in the system specs.
  1685.   Your system may have a different RAID architecture, so modify as
  1686.   appropriate. Please read the man pages and QuickStart.RAID that come
  1687.   with the raidtools-0.42
  1688.  
  1689.   6.1.  /etc/raid5.conf
  1690.  
  1691.  
  1692.           # raid-5 configuration
  1693.           raiddev                 /dev/md0
  1694.           raid-level              5
  1695.           nr-raid-disks           4
  1696.           chunk-size              32
  1697.  
  1698.           # Parity placement algorithm
  1699.           parity-algorithm        left-symmetric
  1700.  
  1701.           # Spare disks for hot reconstruction
  1702.           #nr-spare-disks         0
  1703.  
  1704.           device                  /dev/sda3
  1705.           raid-disk               0
  1706.  
  1707.           device                  /dev/sdb3
  1708.           raid-disk               1
  1709.  
  1710.           device                  /dev/sdc3
  1711.           raid-disk               2
  1712.  
  1713.           device                  /dev/sdd3
  1714.           raid-disk               3
  1715.  
  1716.  
  1717.   6.2.  /etc/raid1.conf
  1718.  
  1719.  
  1720.           # raid-1 configuration
  1721.           raiddev                 /dev/md0
  1722.           raid-level              1
  1723.           nr-raid-disks           2
  1724.           nr-spare-disks          0
  1725.  
  1726.           device                  /dev/hda4
  1727.           raid-disk               0
  1728.  
  1729.           device                  /dev/hdc4
  1730.           raid-disk               1
  1731.  
  1732.  
  1733.  
  1734.   6.3.  Step by Step procedures for building production RAID file sys¡
  1735.   tem.
  1736.  
  1737.   For my RAID5 system I did a complete install of:
  1738.  
  1739.           Slackware-3.4           any current distribution should work OK
  1740.           linuxthreads-0.71
  1741.           raidtools-0.42
  1742.           linux-2.0.33 with raid145 patch and Gadi's patch
  1743.  
  1744.  
  1745.  
  1746.   Create and format the raid device.
  1747.  
  1748.           mkraid /etc/raid5.conf
  1749.           mdcreate raid5 /dev/md0 /dev/sda3 /dev/sdb3 /dev/sdc3 /dev/sdd3
  1750.           mdadd -ar
  1751.           mke2fs /dev/md0
  1752.           mkdir /md
  1753.           mount -t ext2 /dev/md0 /md
  1754.  
  1755.  
  1756.   Create the reference files that reboot will use, this may be different
  1757.   on your system.
  1758.  
  1759.           cat /proc/mdstat | grep md0 > /dosa/raidboot/raidgood.ref
  1760.           cat /proc/mdstat | grep md0 > /dosb/raidboot/raidgood.ref
  1761.  
  1762.  
  1763.   Use Slackware-3.4 or another distribution to build your OS
  1764.  
  1765.           setup
  1766.  
  1767.  
  1768.   Specify '/md' as the target, and the source whatever your normally
  1769.   use.  Select and install the disksets of interest except for the ker¡
  1770.   nel.  Configure the system, but skip the section on lilo and kernel
  1771.   booting.  Exit setup.
  1772.  
  1773.   Install 'pthreads'
  1774.  
  1775.           cd /usr/src/linuxthreads-0.71
  1776.  
  1777.  
  1778.   edit the Makefile and specify
  1779.  
  1780.  
  1781.  
  1782.  
  1783.           BUILDIR=/md
  1784.  
  1785.           make
  1786.           make install
  1787.  
  1788.  
  1789.   Install 'raidtools'
  1790.  
  1791.           cd /usr/src/raidtools-0.42
  1792.           configure --sbindir=/md/sbin --prefix=/md/usr
  1793.  
  1794.  
  1795.   fix the raidtools make install error
  1796.  
  1797.           cd /md/sbin
  1798.           rm mdrun
  1799.           rm mdstop
  1800.           ln -s mdadd mdrun
  1801.           ln -s mdadd mdstop
  1802.  
  1803.  
  1804.   Create /dev/mdx
  1805.  
  1806.           cp -a /dev/md* /md/dev
  1807.  
  1808.  
  1809.   Add the system configuration from the current system (ignore errors).
  1810.  
  1811.           cp -dp /etc/* mnt/etc
  1812.           cp -dp /etc/rc.d/* mnt/etc/rc.d         (include the new rc.6)
  1813.           mkdir  mnt/lib/modules
  1814.           cp -a  /lib/modules/2.x.x mnt/lib/modules <--- your current 2.x.x
  1815.  
  1816.  
  1817.   Edit the following files to correct them for your file system
  1818.  
  1819.           cd /md
  1820.  
  1821.   Non-network
  1822.           etc/fstab       correct for real root and raid devices.
  1823.           etc/mdtab       should work OK
  1824.   Network
  1825.           etc/hosts
  1826.           etc/resolv.conf
  1827.           etc/hosts.equiv         and related files
  1828.           etc/rc.d/rc.inet1       correct ip#, mask, gateway, etc...
  1829.           etc/rc.d/rc.S           remove entire section on file system status
  1830.                   from:
  1831.                           # Test to see if the root partition isread-only
  1832.                   to but not including:
  1833.                           # remove /etc/mtab* so that mount will .....
  1834.                                   This avoids the annoying warning that
  1835.                                   the ramdisk is mounted rw.
  1836.           etc/rc.d/rc.xxxxx       others as required
  1837.           root/.rhosts            if present
  1838.           home/xxxx/xxxx          others as required
  1839.  
  1840.       WARNING:    The above procedure moves your password and shadow
  1841.                   files onto the new file system!!!!!
  1842.  
  1843.       WARNING:    You may not wish to do this for security reasons.
  1844.  
  1845.  
  1846.   Create any directories for mounting /dev/disk... as may be required
  1847.   that are unique to your system.  Mine need:
  1848.  
  1849.           cd /md          <--- new file system root
  1850.           mkdir dosa                      dos partition mount point
  1851.           mkdir dosb                      dos mirror mount point
  1852.  
  1853.  
  1854.   The new file system is complete. Make sure and save the md reference
  1855.   status to the 'real' root device and you are ready to boot.
  1856.  
  1857.   mount the dos partitions on dosa and dosb
  1858.  
  1859.           cat /proc/mdstat | grep md0 > /dosa/raidboot/raidgood.ref
  1860.           cat /proc/mdstat | grep md0 > /dosb/raidboot/raidgood.ref
  1861.  
  1862.           mdstop /dev/md0
  1863.  
  1864.  
  1865.  
  1866.  
  1867.   7.  One last thought.
  1868.  
  1869.   Remember that an expert is someone who knows at least 1% more than you
  1870.   do about a subject.  Bear this in mind when you e-mail me for help.
  1871.   I'll try, but I've only done this once for raid1 and once for raid5!
  1872.  
  1873.   Michael Robinton Michael@bzs.org <mailto:michael@bzs.org>
  1874.  
  1875.  
  1876.   8.  Appendix A. - Bohumil Chalupa's md0 shutdown
  1877.  
  1878.   Bohumil Chalupa's post to the linux raid list on the work around for
  1879.   the raid1 + 5 mdstop problem. His solution does not address the
  1880.   possibility of the raid device being corrupt at shutdown.  So I have
  1881.   added a simple status comparison to a good reference status at boot.
  1882.   This allows the operator to intervene if something is wrong with a
  1883.   disk in the array. The description of this is in the main body of this
  1884.   document.
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.   > From: Bohumil Chalupa <bochal@apollo.karlov.mff.cuni.cz>
  1916.   >
  1917.   > I can now boot initrd and use linuxrc to start the RAID1 array,
  1918.   > then successfully switch root to /dev/md0.
  1919.   >
  1920.   > I don't know, however, any way how to cleanly _stop_ the array.
  1921.  
  1922.   Well. I have to answer myself :-)
  1923.  
  1924.   > Date: Mon, 29 Dec 1997 02:21:38 -0600 (CST)
  1925.   > From: Edward Welbon <welbon@bga.com>
  1926.   > Subject: Re: dismounting root raid device
  1927.   >
  1928.   > For md devices other than raid0, there is probably state that needs to
  1929.   > be saved that is only known once all writes have completed.  Such state
  1930.   > of course can't be saved to root once it is mounted readonly.  In that
  1931.   > case, you would have to be able to mount a writeable filesystem "X"
  1932.   > on the readonly root and be able to write to "X" (I recall doing this
  1933.   > during "rescue" operations, but not as an automated procedure).
  1934.   >
  1935.   > The filesystem "X" would presumably be a boot device from which the raid
  1936.   > (during linuxrc exection via initrd) would pickup it's initial state from.
  1937.   > Fortunately raid0 isn't required to write out any state (though it would
  1938.   > be pleasant to be able to write the check sums to mdtab after an mdstop).
  1939.   > Eventually, I will fiddle with this but it doesn't seem difficult though
  1940.   > the "devil" is always in the "details".
  1941.  
  1942.   Yes, that's it.
  1943.   I had this idea in mind for some time already, but had no time to try it.
  1944.   Yesterday I did, and it works.
  1945.  
  1946.   With my RAID1 (mirror), I don't save any checksums or raid superblock data.
  1947.   I only save an information on the "real" boot partition, that the root md
  1948.   volume was remounted readonly during shutdown. Then, during boot, the
  1949.   linuxrc script runs mkraid --only-superblock  when it finds this
  1950.   information; otherwise, it runs ckraid.
  1951.   This means, that the raid superblock information is not updated during
  1952.   shutdown; it's updated at the boot time.
  1953.   It is not very clean, I'm afraid,  :-(   but it works.
  1954.  
  1955.   I'm using Slackware and initrd.md by Edward Welbon to boot the root raid
  1956.   device.
  1957.   As far as I remember now, the only modified files are
  1958.   mkdisk and linuxrc, and /etc/rc.d/rc.6 shutdown script.
  1959.   And lilo.conf, of course.
  1960.  
  1961.   I'm appending the important parts.
  1962.  
  1963.   Bohumil Chalupa
  1964.  
  1965.   --------------- my.linuxrc follows -----------------
  1966.   #!/bin/sh
  1967.   # we need /proc
  1968.   /bin/mount /proc
  1969.   # start up the md0 device. let the /etc/rc.d scripts get the rest of them
  1970.   # we should do as little as possible here
  1971.   # ________________________________________
  1972.   # root raid1 shutdown test & recreation
  1973.   # /start must be created on the rd image in my.mkdisk
  1974.   echo "preparing md0: mounting /start"
  1975.   /bin/mount /dev/sda2 /start -t ext2
  1976.   echo "reading saved md0 state from /start"
  1977.   if [ -f /start/root.raid.ok ]; then
  1978.    echo "raid ok, modyfying superblock"
  1979.    rm /start/root.raid.ok
  1980.    /sbin/mkraid /etc/raid1.conf -f --only-superblock
  1981.   else
  1982.    echo "raid not clean, runing ckraid --fix"
  1983.    /sbin/ckraid --fix /etc/raid1.conf
  1984.   fi
  1985.   echo "unmounting /start"
  1986.   /bin/umount /start
  1987.   # _________________________________________
  1988.   #
  1989.   echo "adding md0 for root file system"
  1990.   /sbin/mdadd /dev/md0 /dev/sda1 /dev/sdb1
  1991.   echo "starting md0"
  1992.   /sbin/mdrun -p1 /dev/md0
  1993.   # tell kernel we want to switch to /dev/md0 as root device, the 0x900 value
  1994.   # is arrived at via 256*major_device_number + minor_device number.
  1995.   echo "setting real-root-dev"
  1996.   /bin/echo 0x900>/proc/sys/kernel/real-root-dev
  1997.   #  unmount /proc so that the ram disk can be deallocated.
  1998.   echo "unmounting /proc"
  1999.   /bin/umount /proc
  2000.   /bin/echo "We are hopefully ready to mount /dev/md0 (major 9, minor 0) as
  2001.   root"
  2002.   exit
  2003.   --------------- end of my.linuxrc ----------------------------------
  2004.  
  2005.  
  2006.   ----------- extract from /etc/rc.d/rc.6 follows -----------------
  2007.     # Turn off swap, then unmount local file systems.
  2008.     echo "Turning off swap."
  2009.     swapoff -a
  2010.     echo "Unmounting local file systems."
  2011.     umount -a -tnonfs
  2012.     # Don't remount UMSDOS root volumes:
  2013.     if [ ! "`mount | head -1 | cut -d ' ' -f 5`" = "umsdos" ]; then
  2014.       mount -n -o remount,ro /
  2015.     fi
  2016.  
  2017.     # Save raid state
  2018.     echo "Saving RAID state"
  2019.     /bin/mount -n /dev/sda2 /start -t ext2
  2020.     touch /start/root.raid.ok
  2021.     /bin/umount -n /start
  2022.  
  2023.   -------------- end of excerpt from rc.6 ------------------------
  2024.  
  2025.  
  2026.   ------------------ part of my.mkdisk follows ----------------------
  2027.   #
  2028.   #  now we have the filesystem ready to be populated, we need to
  2029.   #  get a few important directories.  I had endless trouble till
  2030.   #  I created a pristine mtab.  In my case, it is convenient that
  2031.   #  /etc/mdtab is copied over, this way I can activate md with
  2032.   #  a simple "/sbin/mdadd -ar" in linuxrc.
  2033.   #
  2034.   cp -a $ROOT/etc $MOUNTPNT 2>cp.stderr 1>cp.stdout
  2035.   rm -rf $MOUNTPNT/etc/mtab
  2036.   rm -rf $MOUNTPNT/etc/ppp*
  2037.   rm -rf $MOUNTPNT/etc/termcap
  2038.   rm -rf $MOUNTPNT/etc/sendmail*
  2039.   rm -rf $MOUNTPNT/etc/rc.d
  2040.   rm -rf $MOUNTPNT/etc/dos*
  2041.   cp -a $ROOT/sbin $ROOT/dev $ROOT/lib $ROOT/bin $MOUNTPNT 2>>cp.stderr
  2042.   1>>cp.stdout
  2043.   # _____________________________________________________________________
  2044.   #  RAID: will need mkraid and ckraid
  2045.   cp -a $ROOT/usr/sbin/mkraid $ROOT/usr/sbin/ckraid $MOUNTPNT/sbin
  2046.   2>>cp.stderr 1>>cp.stdout
  2047.   # ---------------------------------------------------------------------
  2048.   #  it seems that init wont come out to play unless it has utmp.   this can
  2049.   #  probably be pruned back alot.  no telling what the real bug was 8-).
  2050.   #
  2051.   mkdir $MOUNTPNT/var $MOUNTPNT/var/log $MOUNTPNT/var/run $MOUNTPNT/initrd
  2052.   touch $MOUNTPNT/var/run/utmp $MOUNTPNT/etc/mtab
  2053.   chmod a+r $MOUNTPNT/var/run/utmp $MOUNTPNT/etc/mtab
  2054.   ln -s /var/run/utmp $MOUNTPNT/var/log/utmp
  2055.   ln -s /var/log/utmp $MOUNTPNT/etc/utmp
  2056.   ls -lstrd $MOUNTPNT/etc/utmp $MOUNTPNT/var/log/utmp $MOUNTPNT/var/run/utmp
  2057.   #
  2058.   #  since I wanted to change the mount point, I needed this though
  2059.   #  I suppose that I could have done a "mkdir /proc" in linuxrc.
  2060.   #
  2061.   mkdir $MOUNTPNT/proc
  2062.   chmod 555 $MOUNTPNT/proc
  2063.   #
  2064.   #  ------------------------------------------------------
  2065.   #  we'll mount the real boot device to /start temporarily
  2066.   #  to check the root raid state saved at shutdown time
  2067.   #
  2068.   mkdir $MOUNTPNT/start
  2069.   #  -------------------------------------------------------
  2070.   #
  2071.   #  need linuxrc  (it is, after all, the point of this exercise).
  2072.   #
  2073.   if [ -x ./my.linuxrc ]; then
  2074.     cp -a ./my.linuxrc $MOUNTPNT/linuxrc
  2075.     chmod 777 $MOUNTPNT/linuxrc
  2076.   else
  2077.      ln -s /bin/sh $MOUNTPNT/linuxrc
  2078.   fi
  2079.   #
  2080.   ----------------- part of my.mkdisk ends -----------------
  2081.  
  2082.  
  2083.  
  2084.  
  2085.   9.  Appendix B. - Sample SHUTDOWN scripts
  2086.  
  2087.  
  2088.   ╖  ``Slackware''
  2089.  
  2090.   ╖  ``Debian''
  2091.  
  2092.  
  2093.   9.1.  Slackware - /etc/rc.d/rc.6
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.   #! /bin/sh
  2114.   #
  2115.   # rc.6          This file is executed by init when it goes into runlevel
  2116.   #               0 (halt) or runlevel 6 (reboot). It kills all processes,
  2117.   #               unmounts file systems and then either halts or reboots.
  2118.   #
  2119.   # Version:      @(#)/etc/rc.d/rc.6      1.50    1994-01-15
  2120.   #
  2121.   # Author:       Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
  2122.   # Modified by:  Patrick J. Volkerding, <volkerdi@ftp.cdrom.com>
  2123.   #
  2124.   # Modified by:  Michael A. Robinton < michael@bizsystems.com >
  2125.   #               to add call to rc.raidown
  2126.     # Set the path.
  2127.     PATH=/sbin:/etc:/bin:/usr/bin
  2128.  
  2129.     # Set linefeed mode to avoid staircase effect.
  2130.     stty onlcr
  2131.  
  2132.     echo "Running shutdown script $0:"
  2133.  
  2134.     # Find out how we were called.
  2135.     case "$0" in
  2136.           *0)
  2137.                   message="The system is halted."
  2138.                   command="halt"
  2139.                   ;;
  2140.           *6)
  2141.                   message="Rebooting."
  2142.                   command=reboot
  2143.                   ;;
  2144.           *)
  2145.                   echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
  2146.                   exit 1
  2147.                   ;;
  2148.     esac
  2149.  
  2150.   ############ Save raid boot and status info ##############
  2151.   #
  2152.   if [ -x /etc/rc.d/rc.raidown ]; then
  2153.      /etc/rc.d/rc.raidown
  2154.   fi
  2155.   ################## end raid boot #########################
  2156.  
  2157.     # Kill all processes.
  2158.     # INIT is supposed to handle this entirely now, but this didn't always
  2159.     # work correctly without this second pass at killing off the processes.
  2160.     # Since INIT already notified the user that processes were being killed,
  2161.     # we'll avoid echoing this info this time around.
  2162.     if [ "$1" != "fast" ]; then # shutdown did not already kill all processes
  2163.       killall5 -15
  2164.       killall5 -9
  2165.     fi
  2166.  
  2167.     # Try to turn off quota and accounting.
  2168.     if [ -x /usr/sbin/quotaoff ]
  2169.     then
  2170.           echo "Turning off quota."
  2171.           /usr/sbin/quotaoff -a
  2172.     fi
  2173.     if [ -x /sbin/accton ]
  2174.     then
  2175.           echo "Turning off accounting."
  2176.           /sbin/accton
  2177.     fi
  2178.  
  2179.     # Before unmounting file systems write a reboot or halt record to wtmp.
  2180.     $command -w
  2181.  
  2182.     # Save localtime
  2183.     [ -e /usr/lib/zoneinfo/localtime ] && cp /usr/lib/zoneinfo/localtime /etc
  2184.  
  2185.     # Asynchronously unmount any remote filesystems:
  2186.     echo "Unmounting remote filesystems."
  2187.     umount -a -tnfs &
  2188.  
  2189.     # Turn off swap, then unmount local file systems.
  2190.     echo "Turning off swap."
  2191.     swapoff -a
  2192.     echo "Unmounting local file systems."
  2193.     umount -a -tnonfs
  2194.     # Don't remount UMSDOS root volumes:
  2195.     if [ ! "`mount | head -1 | cut -d ' ' -f 5`" = "umsdos" ]; then
  2196.       mount -n -o remount,ro /
  2197.     fi
  2198.  
  2199.   ################ for raid arrays #########################
  2200.   # Stop all known raid arrays (except root which won't stop)
  2201.   if [ -x /sbin/mdstop ]; then
  2202.     echo "Stopping raid"
  2203.     /sbin/mdstop -a
  2204.   fi
  2205.   ##########################################################
  2206.  
  2207.     # See if this is a powerfail situation.
  2208.     if [ -f /etc/powerstatus ]; then
  2209.       echo "Turning off UPS, bye."
  2210.       /sbin/powerd -q
  2211.       exit 1
  2212.     fi
  2213.  
  2214.     # Now halt or reboot.
  2215.     echo "$message"
  2216.     [ ! -f /etc/fastboot ] && echo "On the next boot fsck will be FORCED."
  2217.     $command -f
  2218.   ############### end rc.6 #################################
  2219.  
  2220.  
  2221.  
  2222.  
  2223.   9.2.  Debian bo - /etc/init.d/halt and /etc/init.d/reboot
  2224.  
  2225.   The modifications shown here for Debian bo halt and reboot files are
  2226.   NOT TESTED. When you test this, please e-mail me so I can remove this
  2227.   comment.
  2228.  
  2229.  
  2230.   9.2.1.  /etc/init.d/halt
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.   #! /bin/sh
  2246.   #
  2247.   # halt          The commands in this script are executed as the last
  2248.   #               step in runlevel 0, ie halt.
  2249.   #
  2250.   # Version:      @(#)halt  1.10  26-Apr-1997  miquels@cistron.nl
  2251.   #
  2252.  
  2253.   PATH=/sbin:/bin:/usr/sbin:/usr/bin
  2254.  
  2255.   ############ Save raid boot and status info ##############
  2256.   #
  2257.   if [ -x /etc/rc.d/rc.raidown ]; then
  2258.      /etc/rc.d/rc.raidown
  2259.   fi
  2260.   ################## end raid boot #########################
  2261.  
  2262.   # Kill all processes.
  2263.   echo -n "Sending all processes the TERM signal... "
  2264.   killall5 -15
  2265.   echo "done."
  2266.   sleep 5
  2267.   echo -n "Sending all processes the KILL signal... "
  2268.   killall5 -9
  2269.   echo "done."
  2270.  
  2271.   # Write a reboot record to /var/log/wtmp.
  2272.   halt -w
  2273.  
  2274.   # Save the random seed between reboots.
  2275.   /etc/init.d/urandom stop
  2276.  
  2277.   echo -n "Deactivating swap... "
  2278.   swapoff -a
  2279.   echo "done."
  2280.  
  2281.   echo -n "Unmounting file systems... "
  2282.   umount -a
  2283.   echo "done."
  2284.  
  2285.   mount -n -o remount,ro /
  2286.  
  2287.   ################ for raid arrays #########################
  2288.   # Stop all known raid arrays (except root which won't stop)
  2289.   if [ -x /sbin/mdstop ]; then
  2290.     echo "Stopping raid"
  2291.     /sbin/mdstop -a
  2292.   fi
  2293.   ##########################################################
  2294.  
  2295.   # See if we need to cut the power.
  2296.   if [ -x /etc/init.d/ups-monitor ]
  2297.   then
  2298.           /etc/init.d/ups-monitor poweroff
  2299.   fi
  2300.  
  2301.   halt -d -f
  2302.   ############# end halt ####################
  2303.  
  2304.  
  2305.  
  2306.   9.2.2.  /etc/init.d/reboot
  2307.  
  2308.  
  2309.  
  2310.  
  2311.   #! /bin/sh
  2312.   #
  2313.   # reboot        The commands in this script are executed as the last
  2314.   #               step in runlevel 6, ie reboot.
  2315.   #
  2316.   # Version:      @(#)reboot  1.9  02-Feb-1997  miquels@cistron.nl
  2317.   #
  2318.  
  2319.   PATH=/sbin:/bin:/usr/sbin:/usr/bin
  2320.  
  2321.   ############ Save raid boot and status info ##############
  2322.   #
  2323.   if [ -x /etc/rc.d/rc.raidown ]; then
  2324.      /etc/rc.d/rc.raidown
  2325.   fi
  2326.   ################## end raid boot #########################
  2327.  
  2328.   # Kill all processes.
  2329.   echo -n "Sending all processes the TERM signal... "
  2330.   killall5 -15
  2331.   echo "done."
  2332.   sleep 5
  2333.   echo -n "Sending all processes the KILL signal... "
  2334.   killall5 -9
  2335.   echo "done."
  2336.  
  2337.   # Write a reboot record to /var/log/wtmp.
  2338.   halt -w
  2339.  
  2340.   # Save the random seed between reboots.
  2341.   /etc/init.d/urandom stop
  2342.  
  2343.   echo -n "Deactivating swap... "
  2344.   swapoff -a
  2345.   echo "done."
  2346.  
  2347.   echo -n "Unmounting file systems... "
  2348.   umount -a
  2349.   echo "done."
  2350.  
  2351.   mount -n -o remount,ro /
  2352.  
  2353.   ################ for raid arrays #########################
  2354.   # Stop all known raid arrays (except root which won't stop)
  2355.   if [ -x /sbin/mdstop ]; then
  2356.     echo "Stopping raid"
  2357.     /sbin/mdstop -a
  2358.   fi
  2359.   ##########################################################
  2360.  
  2361.   echo -n "Rebooting... "
  2362.   reboot -d -f -i
  2363.  
  2364.  
  2365.  
  2366.  
  2367.   10.  Appendix C. - other setup files
  2368.  
  2369.  
  2370.   10.1.  linuxrc``linuxrc file''
  2371.  
  2372.  
  2373.   10.2.  loadlin -- linux.bat file - boot.par``linux.bat file -
  2374.   boot.par''
  2375.  
  2376.  
  2377.   10.3.  linuxthreads Makefile.diff``linuxthreads Makefile.diff''
  2378.  
  2379.  
  2380.   10.4.  raid1.conf``raid1.conf''
  2381.  
  2382.  
  2383.   10.5.  raid5.conf``raid5.conf''
  2384.  
  2385.  
  2386.   10.6.  raidboot.conf``raidboot.conf''
  2387.  
  2388.  
  2389.   10.7.  rc.raidown``rc.raidown''
  2390.  
  2391.   11.  Appendix D. - obsolete linuxrc and shutdown scripts
  2392.  
  2393.  
  2394.   11.1.  Obsolete working - linuxrc
  2395.  
  2396.   This linuxrc file works fine with the shutdown procedure in the next
  2397.   subsection.
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.    ---------------------- linuxrc --------------------
  2444.   #!/bin/sh
  2445.   # ver 1.07 2-12-98
  2446.   # linuxrc - for raid1 using small dos partition and loadlin
  2447.   #
  2448.  
  2449.   # mount the proc file system
  2450.   /bin/mount /proc
  2451.  
  2452.   # This may vary for your system.
  2453.   # Mount the dos partitions, try both
  2454.   # in case one disk is dead
  2455.   /bin/mount /dosa
  2456.   /bin/mount /dosc
  2457.  
  2458.   # Set a flag in case the raid status file is not found
  2459.   # then check both drives for the status file
  2460.   RAIDOWN="raidstat.ro not found"
  2461.   /bin/echo "Reading md0 shutdown status."
  2462.   if [ -f /dosa/raidboot/raidstat.ro ]; then
  2463.     RAIDOWN=`/bin/cat /dosa/raidboot/raidstat.ro`
  2464.     RAIDREF=`/bin/cat /dosc/raidboot/raidgood.ref`
  2465.   else
  2466.     if [ -f /dosc/raidboot/raidstat.ro ]; then
  2467.       RAIDOWN=`/bin/cat /dosc/raidboot/raidstat.ro`
  2468.       RAIDREF=`/bin/cat /dosc/raidboot/raidgood.ref`
  2469.     fi
  2470.   fi
  2471.  
  2472.   # Test for a clean shutdown with all disks operational
  2473.   if [ "${RAIDOWN} != ${RAIDREF}" ]; then
  2474.     echo "ERROR ${RAIDOWN}"
  2475.   #  Use the next 2 lines to BAIL OUT and leave rescue running
  2476.      /bin/echo 0x100>/proc/sys/kernel/real-root-dev
  2477.      exit                 # leaving the error files in dosa/raidboot,etc...
  2478.   fi
  2479.  
  2480.   # The raid array is clean, proceed by removing
  2481.   # status file and writing a clean superblock
  2482.   /bin/rm /dosa/raidboot/raidstat.ro
  2483.   /bin/rm /dosc/raidboot/raidstat.ro
  2484.   /sbin/mkraid /etc/raid1.conf -f --only-superblock
  2485.  
  2486.   /bin/umount /dosa
  2487.   /bin/umount /dosc
  2488.  
  2489.   # Mount raid array
  2490.   echo "Mounting md0, root filesystem"
  2491.   /sbin/mdadd -ar
  2492.  
  2493.   #  If there are errors - BAIL OUT and leave rescue running
  2494.   if [ $? -ne 0 ]; then
  2495.      echo "RAID device has errors"
  2496.   #  Use the next 3 lines to BAIL OUT
  2497.      /bin/rm /etc/mtab            # remove bad mtab
  2498.      /bin/echo 0x100>/proc/sys/kernel/real-root-dev
  2499.      exit
  2500.   fi
  2501.  
  2502.   # else tell the kernel to switch to /dev/md0 as the /root device
  2503.   # The 0x900 value the device number calculated by:
  2504.   #  256*major_device_number + minor_device number
  2505.   /bin/echo 0x900>/proc/sys/kernel/real-root-dev
  2506.  
  2507.   # umount /proc to deallocate initrd device ram space
  2508.   /bin/umount /proc
  2509.   /bin/echo "/dev/md0 mounted as root"
  2510.   exit
  2511.   #------------------ end linuxrc ----------------------
  2512.  
  2513.  
  2514.  
  2515.  
  2516.   11.2.  Obsolete working - shutdown scripts
  2517.  
  2518.   This shutdown procedure works fine with the preceeding linuxrc
  2519.  
  2520.   To capture the raid array shutdown status, just before the file
  2521.   systems are dismounted insert:
  2522.  
  2523.           RAIDSTATUS=`/bin/cat /proc/mdstat | /usr/bin/grep md0`
  2524.  
  2525.  
  2526.   After all the file systems are dismounted (the root file system
  2527.  
  2528.           # root device remains mounted RO
  2529.           # mount dos file systems RW
  2530.           mount -n -o remount,ro /
  2531.           echo "Writing RAID read-only boot FLAG(s)."
  2532.           mount -n /dosa
  2533.           mount -n /dosc
  2534.           # create raid mounted RO flag in duplicate
  2535.           # containing the shutdown status of the raid array
  2536.           echo ${RAIDSTATUS} > /dosa/raidboot/raidstat.ro
  2537.           echo ${RAIDSTATUS} > /dosc/raidboot/raidstat.ro
  2538.  
  2539.           umount -n /dosa
  2540.           umount -n /dosc
  2541.  
  2542.           # Stop all the raid arrays (except root)
  2543.           echo "Stopping raid"
  2544.           mdstop -a
  2545.  
  2546.  
  2547.   This will cleanly stop all raid devices except root.  Root status is
  2548.   passed to the next boot in raidstat.ro.
  2549.  
  2550.   The complete shutdown script from my old raid1 Slackware system
  2551.   follows, I have switched raid1 to the new procedure with the
  2552.   /etc/raidboot.conf file.
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.   #! /bin/sh
  2576.   #
  2577.   # rc.6          This file is executed by init when it goes into runlevel
  2578.   #               0 (halt) or runlevel 6 (reboot). It kills all processes,
  2579.   #               unmounts file systems and then either halts or reboots.
  2580.   #
  2581.   # Version:      @(#)/etc/rc.d/rc.6      1.50    1994-01-15
  2582.   #
  2583.   # Author:       Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
  2584.   # Modified by:  Patrick J. Volkerding, <volkerdi@ftp.cdrom.com>
  2585.   # Modified by:  Michael A. Robinton, <michael@bzs.org> for RAID shutdown
  2586.  
  2587.     # Set the path.
  2588.     PATH=/sbin:/etc:/bin:/usr/bin
  2589.  
  2590.     # Set linefeed mode to avoid staircase effect.
  2591.     stty onlcr
  2592.  
  2593.     echo "Running shutdown script $0:"
  2594.  
  2595.     # Find out how we were called.
  2596.     case "$0" in
  2597.           *0)
  2598.                   message="The system is halted."
  2599.                   command="halt"
  2600.                   ;;
  2601.           *6)
  2602.                   message="Rebooting."
  2603.                   command=reboot
  2604.                   ;;
  2605.           *)
  2606.                   echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
  2607.                   exit 1
  2608.                   ;;
  2609.     esac
  2610.  
  2611.     # Kill all processes.
  2612.     # INIT is supposed to handle this entirely now, but this didn't always
  2613.     # work correctly without this second pass at killing off the processes.
  2614.     # Since INIT already notified the user that processes were being killed,
  2615.     # we'll avoid echoing this info this time around.
  2616.     if [ "$1" != "fast" ]; then # shutdown did not already kill all processes
  2617.       killall5 -15
  2618.       killall5 -9
  2619.     fi
  2620.  
  2621.     # Try to turn off quota and accounting.
  2622.     if [ -x /usr/sbin/quotaoff ]
  2623.     then
  2624.           echo "Turning off quota."
  2625.           /usr/sbin/quotaoff -a
  2626.     fi
  2627.     if [ -x /sbin/accton ]
  2628.     then
  2629.           echo "Turning off accounting."
  2630.           /sbin/accton
  2631.     fi
  2632.  
  2633.     # Before unmounting file systems write a reboot or halt record to wtmp.
  2634.     $command -w
  2635.  
  2636.     # Save localtime
  2637.     [ -e /usr/lib/zoneinfo/localtime ] && cp /usr/lib/zoneinfo/localtime /etc
  2638.  
  2639.     # Asynchronously unmount any remote filesystems:
  2640.     echo "Unmounting remote filesystems."
  2641.     umount -a -tnfs &
  2642.  
  2643.     # you must have issued
  2644.     # 'cat /proc/mdstat | grep md0 > {your boot vol}/raidboot/raidgood.ref'
  2645.     # before linuxrc will execute properly with this info
  2646.     RAIDSTATUS=`/bin/cat /proc/mdstat | /usr/bin/grep md0 # capture raid status`
  2647.  
  2648.     # Turn off swap, then unmount local file systems.
  2649.     # clearing mdtab as well
  2650.     echo "Turning off swap."
  2651.     swapoff -a
  2652.     echo "Unmounting local file systems."
  2653.     umount -a -tnonfs
  2654.  
  2655.     # Don't remount UMSDOS root volumes:
  2656.     if [ ! "`mount | head -1 | cut -d ' ' -f 5`" = "umsdos" ]; then
  2657.       mount -n -o remount,ro /
  2658.     fi
  2659.  
  2660.     # root device remains mounted
  2661.     # mount dos file systems RW
  2662.     echo "Writing RAID read-only boot FLAG(s)."
  2663.     mount -n /dosa
  2664.     mount -n /dosc
  2665.     # create raid mounted RO flag in duplicate
  2666.     # containing the shutdown status of the raid array
  2667.     echo ${RAIDSTATUS} > /dosa/raidboot/raidstat.ro
  2668.     echo ${RAIDSTATUS} > /dosc/raidboot/raidstat.ro
  2669.  
  2670.     umount -n /dosa
  2671.     umount -n /dosc
  2672.  
  2673.     # Stop all the raid arrays (except root)
  2674.     echo "Stopping raid"
  2675.     mdstop -a
  2676.  
  2677.     # See if this is a powerfail situation.
  2678.     if [ -f /etc/power_is_failing ]; then
  2679.       echo "Turning off UPS, bye."
  2680.       /sbin/powerd -q
  2681.       exit 1
  2682.     fi
  2683.  
  2684.     # Now halt or reboot.
  2685.     echo "$message"
  2686.     [ ! -f /etc/fastboot ] && echo "On the next boot fsck will be FORCED."
  2687.     $command -f
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.   12.  Appendix E. - Gadi's raid stop patch for the linux kernel
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.   --- linux/drivers/block/md.c.old        Fri Nov 21 13:37:11 1997
  2708.   +++ linux/drivers/block/md.c    Sat Dec  6 13:34:28 1997
  2709.   @@ -622,8 +622,13 @@
  2710.          return do_md_run (minor, (int) arg);
  2711.  
  2712.        case STOP_MD:
  2713.   -      return do_md_stop (minor, inode);
  2714.   -
  2715.   +      err = do_md_stop(minor, inode);
  2716.   +      if (err) {
  2717.   +        printk("md: enabling auto mdstop for %s\n",
  2718.   kdevname(inode->i_rdev));
  2719.   +        md_dev[minor].auto_mdstop = 1;
  2720.   +      }
  2721.   +      return err;
  2722.   +
  2723.        case BLKGETSIZE:   /* Return device size */
  2724.        if  (!arg)  return -EINVAL;
  2725.        err=verify_area (VERIFY_WRITE, (long *) arg, sizeof(long));
  2726.   @@ -692,6 +697,10 @@
  2727.  
  2728.      sync_dev (inode->i_rdev);
  2729.      md_dev[minor].busy--;
  2730.   +  if (!md_dev[minor].busy && md_dev[minor].auto_mdstop) {
  2731.   +       do_md_stop(minor, inode);
  2732.   +       md_dev[minor].auto_mdstop = 0;
  2733.   +  }
  2734.    }
  2735.  
  2736.    static int md_read (struct inode *inode, struct file *file,
  2737.   --- linux/include/linux/md.h~   Fri Nov 21 13:29:14 1997
  2738.   +++ linux/include/linux/md.h    Fri Nov 21 13:29:14 1997
  2739.   @@ -260,6 +260,7 @@
  2740.      int                  repartition;
  2741.      int                  busy;
  2742.      int                  nb_dev;
  2743.   +  int                  auto_mdstop;
  2744.      void                 *private;
  2745.    };
  2746.  
  2747.  
  2748.  
  2749.   13.  Appendix F. - rc.raidown
  2750.  
  2751.   Copy the following text into the script file rc.raidown and save it in
  2752.   /etc/rc.d.
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.   #! /bin/sh
  2774.   #
  2775.   # rc.raidown    This file is executed by init when it goes into runlevel
  2776.   #               0 (halt) or runlevel 6 (reboot). It saves the status of
  2777.   #               a root mounted raid array for subsequent re-boot
  2778.   #
  2779.   # Version:      1.08    3-25-98 Michael A. Robinton < michael@bizsystems.com >
  2780.   #
  2781.   ############ Save raid boot and status info ##############
  2782.   if [ -f /etc/raidboot.conf ]
  2783.   then
  2784.     {
  2785.     read RaidBootDevs
  2786.     read RaidStatusPath
  2787.     read RaidConfigEtc
  2788.     } < /etc/raidboot.conf
  2789.  
  2790.   # you must have issued
  2791.   #       cat /proc/mdstat | grep md0 >
  2792.   #               {your boot vol mnt(s)}/{RaidStatusPath}/raidgood.ref
  2793.   # before linuxrc will execute properly with this info
  2794.   #
  2795.   #       capture raid status
  2796.     RAIDSTATUS=`/bin/cat /proc/mdstat | /usr/bin/grep md0`
  2797.     mkdir /tmp/raid$$
  2798.     echo "Writing RAID read-only boot FLAG(s)."
  2799.     for Device in ${RaidBootDevs}
  2800.     do
  2801.   # get mount point for raid boot device or use tmp
  2802.       RBmount=$( cat /proc/mounts | /usr/bin/grep ${Device} )
  2803.       if [ -n ${RBmounts} ]; then
  2804.         RBmount=$( echo ${RBmount} | cut -f 2 -d ' ' )
  2805.       else
  2806.         RBmount="/tmp/raid$$"
  2807.         mount ${Device} ${RBmount}
  2808.       fi
  2809.     if [ -d ${RBmount}/${RaidStatusPath} ]; then
  2810.   # Create raid mounted RO flag = shutdown status of raid array
  2811.       echo ${RAIDSTATUS} > ${RBmount}/${RaidStatusPath}/raidboot.ro
  2812.   # Don't propagate 'fstab' from ramdisk
  2813.       if [ -f /linuxrc ]; then
  2814.         FSTAB=
  2815.       else
  2816.         FSTAB=fstab
  2817.       fi
  2818.       pushd /etc
  2819.   # Save etc files for rescue system
  2820.       /bin/tar --ignore-failed-read \
  2821.           -cf ${RBmount}/${RaidStatusPath}/raidboot.etc \
  2822.           raid*.conf mdtab* ${FSTAB} lilo.conf
  2823.       popd
  2824.   # Create new raidboot.cfg
  2825.       {
  2826.       /bin/echo ${RaidBootDevs}
  2827.       /bin/echo ${RaidStatusPath}
  2828.       /bin/echo ${RaidConfigEtc}
  2829.       } > ${RBmount}/${RaidStatusPath}/raidboot.cfg
  2830.       /bin/umount ${RBmount}
  2831.     fi
  2832.     done
  2833.     rmdir /tmp/raid$$
  2834.     echo "Raid boot armed"
  2835.   fi
  2836.   ################## end raid boot #########################
  2837.  
  2838.  
  2839.   14.  Appendix G. - linuxrc theory of operation
  2840.  
  2841.   This is the complex form of the linuxrc file for root mounted raid.
  2842.   It must be processed with 'bash' or another shell that recognizes
  2843.   shell functions.
  2844.  
  2845.   The advantage is that it is generic and is not dependent on startup
  2846.   files and parameters located in the initrd image.
  2847.  
  2848.   A Raid_Conf parameter passed to linuxrc by the kernel at boot from
  2849.   lilo or loadlin contains a pointer to the boot devices and location
  2850.   the of initial 2 raidboot files needed by linuxrc (raidboot.etc and
  2851.   raidboot.cfg placed by the shutdown script).
  2852.  
  2853.        raidboot.etc containing the 'tar'ed files:
  2854.  
  2855.                raid*
  2856.                mdtab*
  2857.                fstab
  2858.                lilo.conf               ( if applicable )
  2859.  
  2860.  
  2861.        from the primary system that are transferred to the initrd
  2862.        /etcetc directory at startup. With care, this file may be
  2863.        edited if necessary when your system 'really' crashes.
  2864.  
  2865.        raidboot.cfg contains the name of the boot partition in use
  2866.        and applicable backup(s) as well as the path to the rest of
  2867.        the raid start up file used by linuxrc.  This file is
  2868.        normally created by the shutdown file and may be created
  2869.        manually if necessary.
  2870.  
  2871.        raidboot.cfg is of the form, 3 lines - no comments
  2872.  
  2873.                /dev/bootdev1 /dev/bootdev2 [/dev/bootdev3 ... and so on]
  2874.                raid-status/path
  2875.                name_of_raidX.conf_file
  2876.  
  2877.  
  2878.  
  2879.        the raid-status/path does not include the name of the mount¡
  2880.        point
  2881.  
  2882.        the raidX.conf filename is that one found in /etc and
  2883.        normally used for ckraid and mkraid.
  2884.  
  2885.  
  2886.  
  2887.   The following additional files reside on the permanent raid boot par¡
  2888.   titions.  This is usually the same as above, but in emergency situa¡
  2889.   tions may be loaded from anywhere they are available, such as a floppy
  2890.   boot disk.
  2891.  
  2892.   ╖  raidgood.ref created by the command cat /proc/mdstat | grep md0 >
  2893.      /{raid_status_path}/raidgood.ref
  2894.  
  2895.  
  2896.      See the ``shutdown scripts'' for saving this file and the next
  2897.  
  2898.  
  2899.   ╖  raidstat.ro created at each shutdown by the shutdown rc file,
  2900.      saving the exit status of the raid array.
  2901.  
  2902.  
  2903.  
  2904.  
  2905.