Annotation of wikisrc/guide/raidframe.mdwn, revision 1.7

1.1       jdf         1: # NetBSD RAIDframe
                      2: 
                      3: ## RAIDframe Introduction
                      4: 
                      5: ### About RAIDframe
                      6: 
1.6       jdf         7: NetBSD uses the [CMU RAIDframe](http://www.pdl.cmu.edu/RAIDframe/) software for
                      8: its RAID subsystem. NetBSD is the primary platform for RAIDframe development.
                      9: RAIDframe can also be found in older versions of FreeBSD and OpenBSD. NetBSD
                     10: also has another way of bundling disks, the
                     11: [ccd(4)](http://netbsd.gw.com/cgi-bin/man-cgi?ccd+4+NetBSD-5.0.1+i386) subsystem
                     12: (see [Concatenated Disk Device](/guide/ccd)). You should possess some [basic
                     13: knowledge](http://www.acnc.com/04_00.html) about RAID concepts and terminology
                     14: before continuing. You should also be at least familiar with the different
                     15: levels of RAID - Adaptec provides an [excellent
                     16: reference](http://www.adaptec.com/en-US/_common/compatibility/_education/RAID_level_compar_wp.htm),
                     17: and the [raid(4)](http://netbsd.gw.com/cgi-bin/man-cgi?raid+4+NetBSD-5.0.1+i386)
1.1       jdf        18: manpage contains a short overview too.
                     19: 
                     20: ### A warning about Data Integrity, Backups, and High Availability
                     21: 
1.6       jdf        22: RAIDframe is a Software RAID implementation, as opposed to Hardware RAID. As
                     23: such, it does not need special disk controllers supported by NetBSD. System
                     24: administrators should give a great deal of consideration to whether software
                     25: RAID or hardware RAID is more appropriate for their "Mission Critical"
                     26: applications. For some projects you might consider the use of many of the
                     27: hardware RAID devices [supported by
                     28: NetBSD](http://www.NetBSD.org/support/hardware/). It is truly at your discretion
                     29: what type of RAID you use, but it is recommend that you consider factors such
1.1       jdf        30: as: manageability, commercial vendor support, load-balancing and failover, etc.
                     31: 
1.6       jdf        32: Depending on the RAID level used, RAIDframe does provide redundancy in the event
                     33: of a hardware failure. However, it is *not* a replacement for reliable backups!
                     34: Software and user-error can still cause data loss. RAIDframe may be used as a
                     35: mechanism for facilitating backups in systems without backup hardware, but this
                     36: is not an ideal configuration. Finally, with regard to "high availability", RAID
1.1       jdf        37: is only a very small component to ensuring data availability.
                     38: 
                     39: Once more for good measure: *Back up your data!*
                     40: 
                     41: ### Hardware versus Software RAID
                     42: 
1.6       jdf        43: If you run a server, it will most probably already have a Hardware RAID
                     44: controller. There are reasons for and against using a Software RAID, depending
1.1       jdf        45: on the scenario.
                     46: 
1.6       jdf        47: In general, a Software RAID is well suited for low-IO system disks. If you run a
                     48: Software RAID, you can exchange disks and disk controllers, or even move the
                     49: disks to a completely different machine. The computational overhead for the RAID
1.1       jdf        50: is negligible if there is only few disk IO operations.
                     51: 
1.6       jdf        52: If you need much IO, you should use a Hardware RAID. With a Software RAID, the
                     53: redundancy data has to be transferred via the bus your disk controller is
                     54: connected to. With a Hardware RAID, you transfer data only once - the redundancy
1.1       jdf        55: computation and transfer is done by the controller.
                     56: 
                     57: ### Getting Help
                     58: 
1.6       jdf        59: If you encounter problems using RAIDframe, you have several options for
1.1       jdf        60: obtaining help.
                     61: 
1.6       jdf        62:  1. Read the RAIDframe man pages:
                     63:     [raid(4)](http://netbsd.gw.com/cgi-bin/man-cgi?raid+4+NetBSD-5.0.1+i386) and
                     64:     [raidctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?raidctl+8+NetBSD-5.0.1+i386)
1.1       jdf        65:     thoroughly.
                     66: 
1.6       jdf        67:  2. Search the mailing list archives. Unfortunately, there is no NetBSD list
1.1       jdf        68:     dedicated to RAIDframe support. Depending on the nature of the problem, posts
                     69:     tend to end up in a variety of lists. At a very minimum, search
                     70:     [netbsd-help](http://mail-index.NetBSD.org/netbsd-help/),
                     71:     [netbsd-users@NetBSD.org](http://mail-index.NetBSD.org/netbsd-users/),
                     72:     [current-users@NetBSD.org](http://mail-index.NetBSD.org/current-users/). Also
                     73:     search the list for the NetBSD platform on which you are using RAIDframe:
                     74:     port-*`${ARCH}`*@NetBSD.org.
                     75: 
1.7     ! jdf        76:     *Caution*: Because RAIDframe is constantly undergoing development, some information in
1.1       jdf        77:        mailing list archives has the potential of being dated and inaccurate.
                     78: 
1.6       jdf        79:  3. Search the [Problem Report
1.1       jdf        80:     database](http://www.NetBSD.org/support/send-pr.html).
                     81: 
1.6       jdf        82:  4. If your problem persists: Post to the mailing list most appropriate
                     83:     (judgment call). Collect as much verbosely detailed information as possible
                     84:     before posting: Include your
                     85:     [dmesg(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dmesg+8+NetBSD-5.0.1+i386)
                     86:     output from `/var/run/dmesg.boot`, your kernel
                     87:     [config(5)](http://netbsd.gw.com/cgi-bin/man-cgi?config+5+NetBSD-5.0.1+i386) ,
                     88:     your `/etc/raid[0-9].conf`, any relevant errors on `/dev/console`,
                     89:     `/var/log/messages`, or to `stdout/stderr` of
                     90:     [raidctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?raidctl+8+NetBSD-5.0.1+i386).
                     91:     The output of **raidctl -s** (if available) will be useful as well. Also
                     92:     include details on the troubleshooting steps you've taken thus far, exactly
                     93:     when the problem started, and any notes on recent changes that may have
                     94:     prompted the problem to develop. Remember to be patient when waiting for a
1.1       jdf        95:     response.
                     96: 
                     97: ## Setup RAIDframe Support
                     98: 
                     99: The use of RAID will require software and hardware configuration changes.
                    100: 
                    101: ### Kernel Support
                    102: 
1.6       jdf       103: The GENERIC kernel already has support for RAIDframe. If you have built a custom
                    104: kernel for your environment the kernel configuration must have the following
1.1       jdf       105: options:
                    106: 
                    107:     pseudo-device   raid            8       # RAIDframe disk driver
                    108:     options         RAID_AUTOCONFIG         # auto-configuration of RAID components
                    109: 
1.6       jdf       110: The RAID support must be detected by the NetBSD kernel, which can be checked by
                    111: looking at the output of the
                    112: [dmesg(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dmesg+8+NetBSD-5.0.1+i386)
1.1       jdf       113: command.
                    114: 
                    115:     # dmesg|grep -i raid
                    116:     Kernelized RAIDframe activated
                    117: 
1.6       jdf       118: Historically, the kernel must also contain static mappings between bus addresses
                    119: and device nodes in `/dev`. This used to ensure consistency of devices within
                    120: RAID sets in the event of a device failure after reboot. Since NetBSD 1.6,
                    121: however, using the auto-configuration features of RAIDframe has been recommended
                    122: over statically mapping devices. The auto-configuration features allow drives to
                    123: move around on the system, and RAIDframe will automatically determine which
1.1       jdf       124: components belong to which RAID sets.
                    125: 
                    126: ### Power Redundancy and Disk Caching
                    127: 
1.6       jdf       128: If your system has an Uninterruptible Power Supply (UPS), if your system has
                    129: redundant power supplies, or your disk controller has a battery, you should
                    130: consider enabling the read and write caches on your drives. On systems with
                    131: redundant power, this will improve drive performance. On systems without
                    132: redundant power, the write cache could endanger the integrity of RAID data in
1.1       jdf       133: the event of a power loss.
                    134: 
1.6       jdf       135: The [dkctl(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dkctl+8+NetBSD-5.0.1+i386)
                    136: utility to can be used for this on all kinds of disks that support the operation
1.1       jdf       137: (SCSI, EIDE, SATA, ...):
                    138: 
                    139:     # dkctl wd0 getcache
                    140:     /dev/rwd0d: read cache enabled
                    141:     /dev/rwd0d: read cache enable is not changeable
                    142:     /dev/rwd0d: write cache enable is changeable
                    143:     /dev/rwd0d: cache parameters are not savable
                    144:     # dkctl wd0 setcache rw
                    145:     # dkctl wd0 getcache
                    146:     /dev/rwd0d: read cache enabled
                    147:     /dev/rwd0d: write-back cache enabled
                    148:     /dev/rwd0d: read cache enable is not changeable
                    149:     /dev/rwd0d: write cache enable is changeable
                    150:     /dev/rwd0d: cache parameters are not savable
                    151: 
                    152: ## Example: RAID-1 Root Disk
                    153: 
1.6       jdf       154: This example explains how to setup RAID-1 root disk. With RAID-1 components are
                    155: mirrored and therefore the server can be fully functional in the event of a
                    156: single component failure. The goal is to provide a level of redundancy that will
                    157: allow the system to encounter a component failure on either component disk in
1.1       jdf       158: the RAID and:
                    159: 
                    160:  * Continue normal operations until a maintenance window can be scheduled.
1.6       jdf       161:  * Or, in the unlikely event that the component failure causes a system reboot,
1.1       jdf       162:    be able to quickly reconfigure the system to boot from the remaining
                    163:    component (platform dependent).
                    164: 
1.7     ! jdf       165: ![RAID-1 Disk Logical Layout](/guide/images/raidframe_raidl1-diskdia.png)
1.1       jdf       166: **RAID-1 Disk Logical Layout**
                    167: 
1.6       jdf       168: Because RAID-1 provides both redundancy and performance improvements, its most
                    169: practical application is on critical "system" partitions such as `/`, `/usr`,
                    170: `/var`, `swap`, etc., where read operations are more frequent than write
                    171: operations. For other file systems, such as `/home` or `/var/`, other RAID
                    172: levels might be considered (see the references above). If one were simply
                    173: creating a generic RAID-1 volume for a non-root file system, the cookie-cutter
                    174: examples from the man page could be followed, but because the root volume must
1.1       jdf       175: be bootable, certain special steps must be taken during initial setup.
                    176: 
1.6       jdf       177: *Note*: This example will outline a process that differs only slightly between
                    178: the i386 and sparc64 platforms. In an attempt to reduce excessive duplication of
                    179: content, where differences do exist and are cosmetic in nature, they will be
                    180: pointed out using a section such as this. If the process is drastically
1.1       jdf       181: different, the process will branch into separate, platform dependent steps.
                    182: 
                    183: ### Pseudo-Process Outline
                    184: 
1.6       jdf       185: Although a much more refined process could be developed using a custom copy of
                    186: NetBSD installed on custom-developed removable media, presently the NetBSD
1.1       jdf       187: install media lacks RAIDframe tools and support, so the following pseudo process
                    188: has become the de facto standard for setting up RAID-1 Root.
                    189: 
                    190:  1. Install a stock NetBSD onto Disk0 of your system.
                    191: 
1.6       jdf       192: 
1.4       jdf       193:     ![Perform generic install onto Disk0/wd0](/guide/images/raidframe_r1r-pp1.png)
1.1       jdf       194:     **Perform generic install onto Disk0/wd0**
                    195: 
1.6       jdf       196:  2. Use the installed system on Disk0/wd0 to setup a RAID Set composed of
1.1       jdf       197:     Disk1/wd1 only.
                    198: 
1.7     ! jdf       199:     ![Setup RAID Set](/guide/images/raidframe_r1r-pp2.png)
1.1       jdf       200:     **Setup RAID Set**
                    201: 
                    202:  3. Reboot the system off the Disk1/wd1 with the newly created RAID volume.
                    203: 
1.6       jdf       204: 
1.4       jdf       205:     ![Reboot using Disk1/wd1 of RAID](/guide/images/raidframe_r1r-pp3.png)
1.6       jdf       206:     **Reboot using Disk1/wd1 of RAID**
1.5       jdf       207: 
1.1       jdf       208: 
1.7     ! jdf       209:  4. Add/re-sync Disk0/wd0 back into the RAID set.
1.1       jdf       210: 
1.4       jdf       211:     ![Mirror Disk1/wd1 back to Disk0/wd0](/guide/images/raidframe_r1r-pp4.png)
1.1       jdf       212:     **Mirror Disk1/wd1 back to Disk0/wd0**
                    213: 
                    214: ### Hardware Review
                    215: 
1.6       jdf       216: At present, the alpha, amd64, i386, pmax, sparc, sparc64, and vax NetBSD
                    217: platforms support booting from RAID-1. Booting is not supported from any other
                    218: RAID level. Booting from a RAID set is accomplished by teaching the 1st stage
                    219: boot loader to understand both 4.2BSD/FFS and RAID partitions. The 1st boot
                    220: block code only needs to know enough about the disk partitions and file systems
                    221: to be able to read the 2nd stage boot blocks. Therefore, at any time, the
1.7     ! jdf       222: system's BIOS/firmware must be able to read a drive with 1st stage boot blocks
1.6       jdf       223: installed. On the i386 platform, configuring this is entirely dependent on the
1.7     ! jdf       224: vendor of the controller card/host bus adapter to which your disks are
1.1       jdf       225: connected. On sparc64 this is controlled by the IEEE 1275 Sun OpenBoot Firmware.
                    226: 
1.6       jdf       227: This article assumes two identical IDE disks (`/dev/wd{0,1}`) which we are going
1.1       jdf       228: to mirror (RAID-1). These disks are identified as:
                    229: 
                    230:     # grep ^wd /var/run/dmesg.boot
                    231:     wd0 at atabus0 drive 0: <WDC WD100BB-75CLB0>
                    232:     wd0: drive supports 16-sector PIO transfers, LBA addressing
                    233:     wd0: 9541 MB, 19386 cyl, 16 head, 63 sec, 512 bytes/sect x 19541088 sectors
                    234:     wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)
                    235:     wd0(piixide0:0:0): using PIO mode 4, Ultra-DMA mode 2 (Ultra/33) (using DMA data transfers)
                    236:     
                    237:     wd1 at atabus1 drive 0: <WDC WD100BB-75CLB0>
                    238:     wd1: drive supports 16-sector PIO transfers, LBA addressing
                    239:     wd1: 9541 MB, 19386 cyl, 16 head, 63 sec, 512 bytes/sect x 19541088 sectors
                    240:     wd1: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)
                    241:     wd1(piixide0:1:0): using PIO mode 4, Ultra-DMA mode 2 (Ultra/33) (using DMA data transfers)
                    242: 
1.6       jdf       243: *Note*: If you are using SCSI, replace `/dev/{,r}wd{0,1}` with
                    244: `/dev/{,r}sd{0,1}`.
1.1       jdf       245: 
1.6       jdf       246: In this example, both disks are jumpered as Master on separate channels on the
                    247: same controller. You usually wouldn't want to have both disks on the same bus on
                    248: the same controller; this creates a single point of failure. Ideally you would
                    249: have the disks on separate channels on separate controllers. Nonetheless, in
                    250: most cases the most critical point is the hard disk, so having redundant
                    251: channels or controllers is not that important. Plus, having more channels or
                    252: controllers increases costs. Some SCSI controllers have multiple channels on the
                    253: same controller, however, a SCSI bus reset on one channel could adversely affect
                    254: the other channel if the ASIC/IC becomes overloaded. The trade-off with two
                    255: controllers is that twice the bandwidth is used on the system bus. For purposes
                    256: of simplification, this example shows two disks on different channels on the
1.1       jdf       257: same controller.
                    258: 
1.6       jdf       259: *Note*: RAIDframe requires that all components be of the same size. Actually, it
                    260: will use the lowest common denominator among components of dissimilar sizes. For
                    261: purposes of illustration, the example uses two disks of identical geometries.
                    262: Also, consider the availability of replacement disks if a component suffers a
1.1       jdf       263: critical hardware failure.
                    264: 
1.6       jdf       265: *Tip*: Two disks of identical vendor model numbers could have different
                    266: geometries if the drive possesses "grown defects". Use a low-level program to
                    267: examine the grown defects table of the disk. These disks are obviously
1.1       jdf       268: suboptimal candidates for use in RAID and should be avoided.
                    269: 
                    270: ### Initial Install on Disk0/wd0
                    271: 
1.6       jdf       272: Perform a very generic installation onto your Disk0/wd0. Follow the `INSTALL`
                    273: instructions for your platform. Install all the sets but do not bother
1.1       jdf       274: customizing anything other than the kernel as it will be overwritten.
                    275: 
1.6       jdf       276: *Tip*: On i386, during the sysinst install, when prompted if you want to `use
1.1       jdf       277: the entire disk for NetBSD`, answer `yes`.
                    278: 
1.3       jdf       279:  * [Installing NetBSD: Preliminary considerations and preparations](/guide/inst)
1.6       jdf       280:  * [NetBSD/i386 Install](http://ftp.NetBSD.org/pub/NetBSD/NetBSD-5.0.2/i386/INSTALL.html)
                    281:  * [NetBSD/sparc64 Install](http://ftp.NetBSD.org/pub/NetBSD/NetBSD-5.0.2/sparc64/INSTALL.html)
1.1       jdf       282: 
1.6       jdf       283: Once the installation is complete, you should examine the
                    284: [disklabel(8)](http://netbsd.gw.com/cgi-bin/man-cgi?disklabel+8+NetBSD-5.0.1+i386)
                    285: and [fdisk(8)](http://netbsd.gw.com/cgi-bin/man-cgi?fdisk+8+NetBSD-5.0.1+i386) /
                    286: [sunlabel(8)](http://netbsd.gw.com/cgi-bin/man-cgi?sunlabel+8+NetBSD-5.0.1+i386)
1.1       jdf       287: outputs on the system:
                    288: 
                    289:     # df
                    290:     Filesystem   1K-blocks        Used       Avail %Cap Mounted on
                    291:     /dev/wd0a       9487886      502132     8511360   5% /
                    292: 
                    293: On i386:
                    294: 
                    295:     # disklabel -r wd0
                    296:     type: unknown
                    297:     disk: Disk00
                    298:     label:
                    299:     flags:
                    300:     bytes/sector: 512
                    301:     sectors/track: 63
                    302:     tracks/cylinder: 16
                    303:     sectors/cylinder: 1008
                    304:     cylinders: 19386
                    305:     total sectors: 19541088
                    306:     rpm: 3600
                    307:     interleave: 1
                    308:     trackskew: 0
                    309:     cylinderskew: 0
                    310:     headswitch: 0           # microseconds
                    311:     track-to-track seek: 0  # microseconds
                    312:     drivedata: 0
                    313:     
                    314:     16 partitions:
                    315:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    316:      a:  19276992        63     4.2BSD   1024  8192 46568  # (Cyl.      0* - 19124*)
                    317:      b:    264033  19277055       swap                     # (Cyl.  19124* - 19385)
                    318:      c:  19541025        63     unused      0     0        # (Cyl.      0* - 19385)
                    319:      d:  19541088         0     unused      0     0        # (Cyl.      0 - 19385)
                    320:     
                    321:     # fdisk /dev/rwd0d
                    322:     Disk: /dev/rwd0d
                    323:     NetBSD disklabel disk geometry:
                    324:     cylinders: 19386, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
                    325:     total sectors: 19541088
                    326:     
                    327:     BIOS disk geometry:
                    328:     cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
                    329:     total sectors: 19541088
                    330:     
                    331:     Partition table:
                    332:     0: NetBSD (sysid 169)
                    333:         start 63, size 19541025 (9542 MB, Cyls 0-1216/96/1), Active
                    334:     1: <UNUSED>
                    335:     2: <UNUSED>
                    336:     3: <UNUSED>
                    337:     Bootselector disabled.
                    338:     First active partition: 0
                    339: 
                    340: On Sparc64 the command and output differ slightly:
                    341: 
                    342:     # disklabel -r wd0
                    343:     type: unknown
                    344:     disk: Disk0
                    345:     [...snip...]
                    346:     8 partitions:
                    347:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    348:      a:  19278000         0     4.2BSD   1024  8192 46568  # (Cyl.      0 -  19124)
                    349:      b:    263088  19278000       swap                     # (Cyl.  19125 -  19385)
                    350:      c:  19541088         0     unused      0     0        # (Cyl.      0 -  19385)
                    351:     
                    352:     # sunlabel /dev/rwd0c
                    353:     sunlabel> P
                    354:     a: start cyl =      0, size = 19278000 (19125/0/0 - 9413.09Mb)
                    355:     b: start cyl =  19125, size =   263088 (261/0/0 - 128.461Mb)
                    356:     c: start cyl =      0, size = 19541088 (19386/0/0 - 9541.55Mb)
                    357: 
                    358: ### Preparing Disk1/wd1
                    359: 
1.6       jdf       360: Once you have a stock install of NetBSD on Disk0/wd0, you are ready to begin.
                    361: Disk1/wd1 will be visible and unused by the system. To setup Disk1/wd1, you will
                    362: use
                    363: [disklabel(8)](http://netbsd.gw.com/cgi-bin/man-cgi?disklabel+8+NetBSD-5.0.1+i386)
1.1       jdf       364: to allocate the entire second disk to the RAID-1 set.
                    365: 
1.6       jdf       366: *Tip*: The best way to ensure that Disk1/wd1 is completely empty is to 'zero'
                    367: out the first few sectors of the disk with
                    368: [dd(1)](http://netbsd.gw.com/cgi-bin/man-cgi?dd+1+NetBSD-5.0.1+i386) . This will
                    369: erase the MBR (i386) or Sun disk label (sparc64), as well as the NetBSD disk
                    370: label. If you make a mistake at any point during the RAID setup process, you can
1.1       jdf       371: always refer to this process to restore the disk to an empty state.
                    372: 
                    373: *Note*: On sparc64, use `/dev/rwd1c` instead of `/dev/rwd1d`!
                    374: 
                    375:     # dd if=/dev/zero of=/dev/rwd1d bs=8k count=1
                    376:     1+0 records in
                    377:     1+0 records out
                    378:     8192 bytes transferred in 0.003 secs (2730666 bytes/sec)
                    379: 
1.6       jdf       380: Once this is complete, on i386, verify that both the MBR and NetBSD disk labels
1.1       jdf       381: are gone. On sparc64, verify that the Sun Disk label is gone as well.
                    382: 
                    383: On i386:
                    384: 
                    385:     # fdisk /dev/rwd1d
                    386:     
                    387:     fdisk: primary partition table invalid, no magic in sector 0
                    388:     Disk: /dev/rwd1d
                    389:     NetBSD disklabel disk geometry:
                    390:     cylinders: 19386, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
                    391:     total sectors: 19541088
                    392:     
                    393:     BIOS disk geometry:
                    394:     cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
                    395:     total sectors: 19541088
                    396:     
                    397:     Partition table:
                    398:     0: <UNUSED>
                    399:     1: <UNUSED>
                    400:     2: <UNUSED>
                    401:     3: <UNUSED>
                    402:     Bootselector disabled.
                    403:     
                    404:     # disklabel -r wd1
                    405:     
                    406:     [...snip...]
                    407:     16 partitions:
                    408:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    409:      c:  19541025        63     unused      0     0        # (Cyl.      0* - 19385)
                    410:      d:  19541088         0     unused      0     0        # (Cyl.      0 - 19385)
                    411: 
                    412: On sparc64:
                    413: 
                    414:     # sunlabel /dev/rwd1c
                    415:     
                    416:     sunlabel: bogus label on `/dev/wd1c' (bad magic number)
                    417:     
                    418:     # disklabel -r wd1
                    419:     
                    420:     [...snip...]
                    421:     3 partitions:
                    422:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    423:      c:  19541088         0     unused      0     0        # (Cyl.      0 -  19385)
                    424:     disklabel: boot block size 0
                    425:     disklabel: super block size 0
                    426: 
1.6       jdf       427: Now that you are certain the second disk is empty, on i386 you must establish
                    428: the MBR on the second disk using the values obtained from Disk0/wd0 above. We
                    429: must remember to mark the NetBSD partition active or the system will not boot.
                    430: You must also create a NetBSD disklabel on Disk1/wd1 that will enable a RAID
                    431: volume to exist upon it. On sparc64, you will need to simply
                    432: [disklabel(8)](http://netbsd.gw.com/cgi-bin/man-cgi?disklabel+8+NetBSD-5.0.1+i386)
1.1       jdf       433: the second disk which will write the proper Sun Disk Label.
                    434: 
1.6       jdf       435: *Tip*:
                    436: [disklabel(8)](http://netbsd.gw.com/cgi-bin/man-cgi?disklabel+8+NetBSD-5.0.1+i386)
                    437: will use your shell' s environment variable `$EDITOR` variable to edit the
                    438: disklabel. The default is
1.1       jdf       439: [vi(1)](http://netbsd.gw.com/cgi-bin/man-cgi?vi+1+NetBSD-5.0.1+i386)
                    440: 
                    441: On i386:
                    442: 
                    443:     # fdisk -0ua /dev/rwd1d
                    444:     fdisk: primary partition table invalid, no magic in sector 0
                    445:     Disk: /dev/rwd1d
                    446:     NetBSD disklabel disk geometry:
                    447:     cylinders: 19386, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
                    448:     total sectors: 19541088
                    449:     
                    450:     BIOS disk geometry:
                    451:     cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
                    452:     total sectors: 19541088
                    453:     
                    454:     Do you want to change our idea of what BIOS thinks? [n]
                    455:     
                    456:     Partition 0:
                    457:     <UNUSED>
                    458:     The data for partition 0 is:
                    459:     <UNUSED>
                    460:     sysid: [0..255 default: 169]
                    461:     start: [0..1216cyl default: 63, 0cyl, 0MB]
                    462:     size: [0..1216cyl default: 19541025, 1216cyl, 9542MB]
                    463:     bootmenu: []
                    464:     Do you want to change the active partition? [n] y
                    465:     Choosing 4 will make no partition active.
                    466:     active partition: [0..4 default: 0] 0
                    467:     Are you happy with this choice? [n] y
                    468:     
                    469:     We haven't written the MBR back to disk yet.  This is your last chance.
                    470:     Partition table:
                    471:     0: NetBSD (sysid 169)
                    472:         start 63, size 19541025 (9542 MB, Cyls 0-1216/96/1), Active
                    473:     1: <UNUSED>
                    474:     2: <UNUSED>
                    475:     3: <UNUSED>
                    476:     Bootselector disabled.
                    477:     Should we write new partition table? [n] y
                    478:     
                    479:     # disklabel -r -e -I wd1
                    480:     type: unknown
                    481:     disk: Disk1
                    482:     label:
                    483:     flags:
                    484:     bytes/sector: 512
                    485:     sectors/track: 63
                    486:     tracks/cylinder: 16
                    487:     sectors/cylinder: 1008
                    488:     cylinders: 19386
                    489:     total sectors: 19541088
                    490:     [...snip...]
                    491:     16 partitions:
                    492:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    493:      a:  19541025        63       RAID                     # (Cyl.      0*-19385)
                    494:      c:  19541025        63     unused      0     0        # (Cyl.      0*-19385)
                    495:      d:  19541088         0     unused      0     0        # (Cyl.      0 -19385)
                    496: 
                    497: On sparc64:
                    498: 
                    499:     # disklabel -r -e -I wd1
                    500:     type: unknown
                    501:     disk: Disk1
                    502:     label:
                    503:     flags:
                    504:     bytes/sector: 512
                    505:     sectors/track: 63
                    506:     tracks/cylinder: 16
                    507:     sectors/cylinder: 1008
                    508:     cylinders: 19386
                    509:     total sectors: 19541088
                    510:     [...snip...]
                    511:     3 partitions:
                    512:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    513:      a:  19541088         0       RAID                     # (Cyl.      0 -  19385)
                    514:      c:  19541088         0     unused      0     0        # (Cyl.      0 -  19385)
                    515:     
1.6       jdf       516:     # sunlabel /dev/rwd1c
1.1       jdf       517:     sunlabel> P
                    518:     a: start cyl =      0, size = 19541088 (19386/0/0 - 9541.55Mb)
                    519:     c: start cyl =      0, size = 19541088 (19386/0/0 - 9541.55Mb)
                    520: 
1.6       jdf       521: *Note*: On i386, the `c:` and `d:` slices are reserved. `c:` represents the
                    522: NetBSD portion of the disk. `d:` represents the entire disk. Because we want to
                    523: allocate the entire NetBSD MBR partition to RAID, and because `a:` resides
                    524: within the bounds of `c:`, the `a:` and `c:` slices have same size and offset
                    525: values and sizes. The offset must start at a track boundary (an increment of
                    526: sectors matching the sectors/track value in the disk label). On sparc64 however,
                    527: `c:` represents the entire NetBSD partition in the Sun disk label and `d:` is
                    528: not reserved. Also note that sparc64's `c:` and `a:` require no offset from the
                    529: beginning of the disk, however if they should need to be, the offset must start
                    530: at a cylinder boundary (an increment of sectors matching the sectors/cylinder
1.1       jdf       531: value).
                    532: 
                    533: ### Initializing the RAID Device
                    534: 
1.7     ! jdf       535: Next we create the configuration file for the RAID set/volume. Traditionally,
1.6       jdf       536: RAIDframe configuration files belong in `/etc` and would be read and initialized
                    537: at boot time, however, because we are creating a bootable RAID volume, the
                    538: configuration data will actually be written into the RAID volume using the
                    539: *auto-configure* feature. Therefore, files are needed only during the initial
1.1       jdf       540: setup and should not reside in `/etc`.
                    541: 
                    542:     # vi /var/tmp/raid0.conf
                    543:     START array
                    544:     1 2 0
                    545:     
                    546:     START disks
                    547:     absent
                    548:     /dev/wd1a
                    549:     
                    550:     START layout
                    551:     128 1 1 1
                    552:     
                    553:     START queue
                    554:     fifo 100
                    555: 
1.6       jdf       556: Note that `absent` means a non-existing disk. This will allow us to establish
                    557: the RAID volume with a bogus component that we will substitute for Disk0/wd0 at
1.1       jdf       558: a later time.
                    559: 
1.6       jdf       560: Next we configure the RAID device and initialize the serial number to something
                    561: unique. In this example we use a "YYYYMMDD*`Revision`*" scheme. The format you
                    562: choose is entirely at your discretion, however the scheme you choose should
1.1       jdf       563: ensure that no two RAID sets use the same serial number at the same time.
                    564: 
1.6       jdf       565: After that we initialize the RAID set for the first time, safely ignoring the
1.1       jdf       566: errors regarding the bogus component.
                    567: 
                    568:     # raidctl -v -C /var/tmp/raid0.conf raid0
                    569:     Ignoring missing component at column 0
                    570:     raid0: Component absent being configured at col: 0
                    571:              Column: 0 Num Columns: 0
                    572:              Version: 0 Serial Number: 0 Mod Counter: 0
                    573:              Clean: No Status: 0
                    574:     Number of columns do not match for: absent
                    575:     absent is not clean!
                    576:     raid0: Component /dev/wd1a being configured at col: 1
                    577:              Column: 0 Num Columns: 0
                    578:              Version: 0 Serial Number: 0 Mod Counter: 0
                    579:              Clean: No Status: 0
                    580:     Column out of alignment for: /dev/wd1a
                    581:     Number of columns do not match for: /dev/wd1a
                    582:     /dev/wd1a is not clean!
                    583:     raid0: There were fatal errors
                    584:     raid0: Fatal errors being ignored.
                    585:     raid0: RAID Level 1
                    586:     raid0: Components: component0[**FAILED**] /dev/wd1a
                    587:     raid0: Total Sectors: 19540864 (9541 MB)
                    588:     # raidctl -v -I 2009122601 raid0
                    589:     # raidctl -v -i raid0
                    590:     Initiating re-write of parity
                    591:     raid0: Error re-writing parity!
                    592:     Parity Re-write status:
                    593:     
                    594:     # tail -1 /var/log/messages
                    595:     Dec 26 00:00:30  /netbsd: raid0: Error re-writing parity!
                    596:     # raidctl -v -s raid0
                    597:     Components:
                    598:               component0: failed
                    599:                /dev/wd1a: optimal
                    600:     No spares.
                    601:     component0 status is: failed.  Skipping label.
                    602:     Component label for /dev/wd1a:
                    603:        Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
                    604:        Version: 2, Serial Number: 2009122601, Mod Counter: 7
                    605:        Clean: No, Status: 0
                    606:        sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
                    607:        Queue size: 100, blocksize: 512, numBlocks: 19540864
                    608:        RAID Level: 1
                    609:        Autoconfig: No
                    610:        Root partition: No
                    611:        Last configured as: raid0
                    612:     Parity status: DIRTY
                    613:     Reconstruction is 100% complete.
                    614:     Parity Re-write is 100% complete.
                    615:     Copyback is 100% complete.
                    616: 
                    617: ### Setting up Filesystems
                    618: 
1.6       jdf       619: *Caution*: The root filesystem must begin at sector 0 of the RAID device. If
1.1       jdf       620: not, the primary boot loader will be unable to find the secondary boot loader.
                    621: 
1.6       jdf       622: The RAID device is now configured and available. The RAID device is a pseudo
                    623: disk-device. It will be created with a default disk label. You must now
                    624: determine the proper sizes for disklabel slices for your production environment.
                    625: For purposes of simplification in this example, our system will have 8.5
                    626: gigabytes dedicated to `/` as `/dev/raid0a` and the rest allocated to `swap`
1.1       jdf       627: as `/dev/raid0b`.
                    628: 
1.6       jdf       629: *Caution*: This is an unrealistic disk layout for a production server; the
                    630: NetBSD Guide can expand on proper partitioning technique. See [Installing
1.1       jdf       631: NetBSD: Preliminary considerations and preparations*](inst).
                    632: 
1.6       jdf       633: *Note*: Note that 1 GB is 2\*1024\*1024=2097152 blocks (1 block is 512 bytes, or
                    634: 0.5 kilobytes). Despite what the underlying hardware composing a RAID set is,
1.1       jdf       635: the RAID pseudo disk will always have 512 bytes/sector.
                    636: 
1.6       jdf       637: *Note*: In our example, the space allocated to the underlying `a:` slice
                    638: composing the RAID set differed between i386 and sparc64, therefore the total
1.1       jdf       639: sectors of the RAID volumes differs:
                    640: 
                    641: On i386:
                    642: 
                    643:      # disklabel -r -e -I raid0
                    644:     type: RAID
                    645:     disk: raid
                    646:     label: fictitious
                    647:     flags:
                    648:     bytes/sector: 512
                    649:     sectors/track: 128
                    650:     tracks/cylinder: 8
                    651:     sectors/cylinder: 1024
                    652:     cylinders: 19082
                    653:     total sectors: 19540864
                    654:     rpm: 3600
                    655:     interleave: 1
                    656:     trackskew: 0
                    657:     cylinderskew: 0
                    658:     headswitch: 0 # microseconds
                    659:     track-to-track seek: 0 # microseconds
                    660:     drivedata: 0
                    661:     
                    662:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    663:      a:  19015680         0     4.2BSD      0     0     0  # (Cyl.      0 - 18569)
                    664:      b:    525184  19015680       swap                     # (Cyl.  18570 - 19082*)
                    665:      d:  19540864         0     unused      0     0        # (Cyl.      0 - 19082*)
                    666: 
                    667: On sparc64:
                    668: 
                    669:     # disklabel -r -e -I raid0
                    670:     [...snip...]
                    671:     total sectors: 19539968
                    672:     [...snip...]
                    673:     3 partitions:
                    674:     #        size    offset     fstype [fsize bsize cpg/sgs]
                    675:      a:  19251200         0     4.2BSD      0     0     0  # (Cyl.      0 -  18799)
                    676:      b:    288768  19251200       swap                     # (Cyl.  18800 -  19081)
                    677:      c:  19539968         0     unused      0     0        # (Cyl.      0 -  19081)
                    678: 
                    679: Next, format the newly created `/` partition as a 4.2BSD FFSv1 File System:
                    680: 
                    681:     # newfs -O 1 /dev/rraid0a
                    682:     /dev/rraid0a: 9285.0MB (19015680 sectors) block size 16384, fragment size 2048
                    683:             using 51 cylinder groups of 182.06MB, 11652 blks, 23040 inodes.
                    684:     super-block backups (for fsck -b #) at:
                    685:     32, 372896, 745760, 1118624, 1491488, 1864352, 2237216, 2610080, 2982944,
                    686:     ...............................................................................
                    687:     
                    688:     # fsck -fy /dev/rraid0a
                    689:     ** /dev/rraid0a
                    690:     ** File system is already clean
                    691:     ** Last Mounted on
                    692:     ** Phase 1 - Check Blocks and Sizes
                    693:     ** Phase 2 - Check Pathnames
                    694:     ** Phase 3 - Check Connectivity
                    695:     ** Phase 4 - Check Reference Counts
                    696:     ** Phase 5 - Check Cyl groups
                    697:     1 files, 1 used, 4679654 free (14 frags, 584955 blocks, 0.0% fragmentation)
                    698: 
                    699: ### Migrating System to RAID
                    700: 
1.6       jdf       701: The new RAID filesystems are now ready for use. We mount them under `/mnt` and
                    702: copy all files from the old system. This can be done using
                    703: [dump(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dump+8+NetBSD-5.0.1+i386) or
1.1       jdf       704: [pax(1)](http://netbsd.gw.com/cgi-bin/man-cgi?pax+1+NetBSD-5.0.1+i386).
                    705: 
                    706:     # mount /dev/raid0a /mnt
                    707:     # df -h /mnt
                    708:     Filesystem        Size       Used      Avail %Cap Mounted on
                    709:     /dev/raid0a       8.9G       2.0K       8.5G   0% /mnt
                    710:     # cd /; pax -v -X -rw -pe . /mnt
                    711:     [...snip...]
                    712: 
1.6       jdf       713: The NetBSD install now exists on the RAID filesystem. We need to fix the
                    714: mount-points in the new copy of `/etc/fstab` or the system will not come up
1.1       jdf       715: correctly. Replace instances of `wd0` with `raid0`.
                    716: 
1.6       jdf       717: The swap should be unconfigured upon shutdown to avoid parity errors on the RAID
1.1       jdf       718: device. This can be done with a simple, one-line setting in `/etc/rc.conf`.
                    719: 
                    720:     # vi /mnt/etc/rc.conf
                    721:     swapoff=YES
                    722: 
1.6       jdf       723: Next, the boot loader must be installed on Disk1/wd1. Failure to install the
1.1       jdf       724: loader on Disk1/wd1 will render the system un-bootable if Disk0/wd0 fails. You
                    725: should hope your system won't have to reboot when wd0 fails.
                    726: 
1.6       jdf       727: *Tip*: Because the BIOS/CMOS menus in many i386 based systems are misleading
                    728: with regard to device boot order. I highly recommend utilizing the `-o
                    729: timeout=X` option supported by the i386 1st stage boot loader. Setup unique
                    730: values for each disk as a point of reference so that you can easily determine
1.1       jdf       731: from which disk the system is booting.
                    732: 
1.6       jdf       733: *Caution*: Although it may seem logical to install the 1st stage boot block into
                    734: `/dev/rwd1{c,d}` (which is historically correct with NetBSD 1.6.x
                    735: [installboot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?installboot+8+NetBSD-5.0.1+i386)
                    736: , this is no longer the case. If you make this mistake, the boot sector will
1.1       jdf       737: become irrecoverably damaged and you will need to start the process over again.
                    738: 
                    739: On i386, install the boot loader into `/dev/rwd1a`:
                    740: 
                    741:     # /usr/sbin/installboot -o timeout=30 -v /dev/rwd1a /usr/mdec/bootxx_ffsv1
                    742:     File system:         /dev/rwd1a
                    743:     Primary bootstrap:   /usr/mdec/bootxx_ffsv1
                    744:     Ignoring PBR with invalid magic in sector 0 of `/dev/rwd1a'
                    745:     Boot options:        timeout 30, flags 0, speed 9600, ioaddr 0, console pc
                    746: 
1.6       jdf       747: On sparc64, install the boot loader into `/dev/rwd1a` as well, however the `-o`
1.1       jdf       748: flag is unsupported (and un-needed thanks to OpenBoot):
                    749: 
                    750:     # /usr/sbin/installboot -v /dev/rwd1a /usr/mdec/bootblk
                    751:     File system:         /dev/rwd1a
                    752:     Primary bootstrap:   /usr/mdec/bootblk
                    753:     Bootstrap start sector: 1
                    754:     Bootstrap byte count:   5140
                    755:     Writing bootstrap
                    756: 
1.6       jdf       757: Finally the RAID set must be made auto-configurable and the system should be
1.1       jdf       758: rebooted. After the reboot everything is mounted from the RAID devices.
                    759: 
                    760:     # raidctl -v -A root raid0
                    761:     raid0: Autoconfigure: Yes
                    762:     raid0: Root: Yes
                    763:     # tail -2 /var/log/messages
                    764:     raid0: New autoconfig value is: 1
                    765:     raid0: New rootpartition value is: 1
                    766:     # raidctl -v -s raid0
                    767:     [...snip...]
                    768:        Autoconfig: Yes
                    769:        Root partition: Yes
                    770:        Last configured as: raid0
                    771:     [...snip...]
                    772:     # shutdown -r now
                    773: 
1.7     ! jdf       774: *Warning*: Always use
1.6       jdf       775: [shutdown(8)](http://netbsd.gw.com/cgi-bin/man-cgi?shutdown+8+NetBSD-5.0.1+i386)
                    776: when shutting down. Never simply use
                    777: [reboot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?reboot+8+NetBSD-5.0.1+i386).
1.5       jdf       778: [reboot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?reboot+8+NetBSD-5.0.1+i386)
1.6       jdf       779: will not properly run shutdown RC scripts and will not safely disable swap. This
1.1       jdf       780: will cause dirty parity at every reboot.
                    781: 
                    782: ### The first boot with RAID
                    783: 
1.6       jdf       784: At this point, temporarily configure your system to boot Disk1/wd1. See notes in
                    785: [[Testing Boot Blocks|guide/rf#adding-text-boot]] for details on this process.
                    786: The system should boot now and all filesystems should be on the RAID devices.
                    787: The RAID will be functional with a single component, however the set is not
1.1       jdf       788: fully functional because the bogus drive (wd9) has failed.
                    789: 
                    790:     # egrep -i "raid|root" /var/run/dmesg.boot
                    791:     raid0: RAID Level 1
                    792:     raid0: Components: component0[**FAILED**] /dev/wd1a
                    793:     raid0: Total Sectors: 19540864 (9541 MB)
                    794:     boot device: raid0
                    795:     root on raid0a dumps on raid0b
                    796:     root file system type: ffs
                    797:     
                    798:     # df -h
                    799:     Filesystem    Size     Used     Avail Capacity  Mounted on
                    800:     /dev/raid0a   8.9G     196M      8.3G     2%    /
                    801:     kernfs        1.0K     1.0K        0B   100%    /kern
                    802:     
                    803:     # swapctl -l
                    804:     Device      1K-blocks     Used    Avail Capacity  Priority
                    805:     /dev/raid0b    262592        0   262592     0%    0
                    806:     # raidctl -s raid0
                    807:     Components:
                    808:               component0: failed
                    809:                /dev/wd1a: optimal
                    810:     No spares.
                    811:     component0 status is: failed.  Skipping label.
                    812:     Component label for /dev/wd1a:
                    813:        Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
                    814:        Version: 2, Serial Number: 2009122601, Mod Counter: 65
                    815:        Clean: No, Status: 0
                    816:        sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
                    817:        Queue size: 100, blocksize: 512, numBlocks: 19540864
                    818:        RAID Level: 1
                    819:        Autoconfig: Yes
                    820:        Root partition: Yes
                    821:        Last configured as: raid0
                    822:     Parity status: DIRTY
                    823:     Reconstruction is 100% complete.
                    824:     Parity Re-write is 100% complete.
                    825:     Copyback is 100% complete.
                    826: 
                    827: ### Adding Disk0/wd0 to RAID
                    828: 
1.6       jdf       829: We will now add Disk0/wd0 as a component of the RAID. This will destroy the
                    830: original file system structure. On i386, the MBR disklabel will be unaffected
                    831: (remember we copied wd0's label to wd1 anyway) , therefore there is no need to
                    832: "zero" Disk0/wd0. However, we need to relabel Disk0/wd0 to have an identical
                    833: NetBSD disklabel layout as Disk1/wd1. Then we add Disk0/wd0 as "hot-spare" to
                    834: the RAID set and initiate the parity reconstruction for all RAID devices,
1.1       jdf       835: effectively bringing Disk0/wd0 into the RAID-1 set and "syncing up" both disks.
                    836: 
                    837:     # disklabel -r wd1 > /tmp/disklabel.wd1
                    838:     # disklabel -R -r wd0 /tmp/disklabel.wd1
                    839: 
1.6       jdf       840: As a last-minute sanity check, you might want to use
                    841: [diff(1)](http://netbsd.gw.com/cgi-bin/man-cgi?diff+1+NetBSD-5.0.1+i386) to
                    842: ensure that the disklabels of Disk0/wd0 match Disk1/wd1. You should also backup
1.1       jdf       843: these files for reference in the event of an emergency.
                    844: 
                    845:     # disklabel -r wd0 > /tmp/disklabel.wd0
                    846:     # disklabel -r wd1 > /tmp/disklabel.wd1
                    847:     # diff /tmp/disklabel.wd0 /tmp/disklabel.wd1
                    848:     # fdisk /dev/rwd0 > /tmp/fdisk.wd0
                    849:     # fdisk /dev/rwd1 > /tmp/fdisk.wd1
                    850:     # diff /tmp/fdisk.wd0 /tmp/fdisk.wd1
                    851:     # mkdir /root/RFbackup
                    852:     # cp -p /tmp/{disklabel,fdisk}* /root/RFbackup
                    853: 
                    854: Once you are sure, add Disk0/wd0 as a spare component, and start reconstruction:
                    855: 
                    856:     # raidctl -v -a /dev/wd0a raid0
                    857:     /netbsd: Warning: truncating spare disk /dev/wd0a to 241254528 blocks
                    858:     # raidctl -v -s raid0
                    859:     Components:
                    860:               component0: failed
                    861:                /dev/wd1a: optimal
                    862:     Spares:
                    863:                /dev/wd0a: spare
                    864:     [...snip...]
                    865:     # raidctl -F component0 raid0
                    866:     RECON: initiating reconstruction on col 0 -> spare at col 2
                    867:      11% |****                                   | ETA:    04:26 \
                    868: 
1.6       jdf       869: Depending on the speed of your hardware, the reconstruction time will vary. You
1.1       jdf       870: may wish to watch it on another terminal (note that you can interrupt
                    871: `raidctl -S` any time without stopping the synchronisation):
                    872: 
                    873:     # raidctl -S raid0
                    874:     Reconstruction is 0% complete.
                    875:     Parity Re-write is 100% complete.
                    876:     Copyback is 100% complete.
                    877:     Reconstruction status:
                    878:       17% |******                                 | ETA: 03:08 -
                    879: 
                    880: After reconstruction, both disks should be *optimal*.
                    881: 
                    882:     # tail -f /var/log/messages
                    883:     raid0: Reconstruction of disk at col 0 completed
                    884:     raid0: Recon time was 1290.625033 seconds, accumulated XOR time was 0 us (0.000000)
                    885:     raid0:  (start time 1093407069 sec 145393 usec, end time 1093408359 sec 770426 usec)
                    886:     raid0: Total head-sep stall count was 0
                    887:     raid0: 305318 recon event waits, 1 recon delays
                    888:     raid0: 1093407069060000 max exec ticks
                    889:     
                    890:     # raidctl -v -s raid0
                    891:     Components:
                    892:                component0: spared
                    893:                /dev/wd1a: optimal
                    894:     Spares:
                    895:          /dev/wd0a: used_spare
                    896:          [...snip...]
                    897: 
1.6       jdf       898: When the reconstruction is finished we need to install the boot loader on the
1.1       jdf       899: Disk0/wd0. On i386, install the boot loader into `/dev/rwd0a`:
                    900: 
                    901:     # /usr/sbin/installboot -o timeout=15 -v /dev/rwd0a /usr/mdec/bootxx_ffsv1
                    902:     File system:         /dev/rwd0a
                    903:     Primary bootstrap:   /usr/mdec/bootxx_ffsv1
                    904:     Boot options:        timeout 15, flags 0, speed 9600, ioaddr 0, console pc
                    905: 
                    906: On sparc64:
                    907: 
                    908:     # /usr/sbin/installboot -v /dev/rwd0a /usr/mdec/bootblk
                    909:     File system:         /dev/rwd0a
                    910:     Primary bootstrap:   /usr/mdec/bootblk
                    911:     Bootstrap start sector: 1
                    912:     Bootstrap byte count:   5140
                    913:     Writing bootstrap
                    914: 
1.6       jdf       915: And finally, reboot the machine one last time before proceeding. This is
                    916: required to migrate Disk0/wd0 from status "used\_spare" as "Component0" to state
                    917: "optimal". Refer to notes in the next section regarding verification of clean
1.1       jdf       918: parity after each reboot.
                    919: 
                    920:     # shutdown -r now
                    921: 
                    922: ### Testing Boot Blocks
                    923: 
1.6       jdf       924: At this point, you need to ensure that your system's hardware can properly boot
                    925: using the boot blocks on either disk. On i386, this is a hardware-dependent
                    926: process that may be done via your motherboard CMOS/BIOS menu or your controller
1.1       jdf       927: card's configuration menu.
                    928: 
1.6       jdf       929: On i386, use the menu system on your machine to set the boot device order /
                    930: priority to Disk1/wd1 before Disk0/wd0. The examples here depict a generic Award
                    931: 
1.1       jdf       932: BIOS.
                    933: 
1.4       jdf       934: ![Award BIOS i386 Boot Disk1/wd1](/guide/images/raidframe_awardbios2.png)
1.1       jdf       935: **Award BIOS i386 Boot Disk1/wd1**
                    936: 
                    937: Save changes and exit:
                    938: 
                    939:     >> NetBSD/i386 BIOS Boot, Revision 5.2 (from NetBSD 5.0.2)
                    940:     >> (builds@b7, Sun Feb 7 00:30:50 UTC 2010)
                    941:     >> Memory: 639/130048 k
                    942:     Press return to boot now, any other key for boot menu
                    943:     booting hd0a:netbsd - starting in 30
                    944: 
1.5       jdf       945: You can determine that the BIOS is reading Disk1/wd1 because the timeout of th
1.6       jdf       946: 
1.5       jdf       947: boot loader is 30 seconds instead of 15. After the reboot, re-enter the BIOS an
1.1       jdf       948: configure the drive boot order back to the default:
                    949: 
1.4       jdf       950: ![Award BIOS i386 Boot Disk0/wd0](/guide/images/raidframe_awardbios1.png)
1.1       jdf       951: **Award BIOS i386 Boot Disk0/wd0**
                    952: 
                    953: Save changes and exit:
                    954: 
                    955:     >> NetBSD/i386 BIOS Boot, Revision 5.2 (from NetBSD 5.0.2)
                    956:     >> Memory: 639/130048 k
                    957:     Press return to boot now, any other key for boot menu
                    958:     booting hd0a:netbsd - starting in 15
                    959: 
1.6       jdf       960: Notice how your custom kernel detects controller/bus/drive assignments
                    961: independent of what the BIOS assigns as the boot disk. This is the expected
1.1       jdf       962: behavior.
                    963: 
                    964: On sparc64, use the Sun OpenBoot **devalias** to confirm that both disks are bootable:
                    965: 
                    966:     Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 400MHz), No Keyboard
                    967:     OpenBoot 3.15, 128 MB memory installed, Serial #nnnnnnnn.
                    968:     Ethernet address 8:0:20:a5:d1:3b, Host ID: nnnnnnnn.
                    969:     
                    970:     ok devalias
                    971:     [...snip...]
                    972:     cdrom /pci@1f,0/pci@1,1/ide@3/cdrom@2,0:f
                    973:     disk /pci@1f,0/pci@1,1/ide@3/disk@0,0
                    974:     disk3 /pci@1f,0/pci@1,1/ide@3/disk@3,0
                    975:     disk2 /pci@1f,0/pci@1,1/ide@3/disk@2,0
                    976:     disk1 /pci@1f,0/pci@1,1/ide@3/disk@1,0
                    977:     disk0 /pci@1f,0/pci@1,1/ide@3/disk@0,0
                    978:     [...snip...]
                    979:     
                    980:     ok boot disk0 netbsd
                    981:     Initializing Memory [...]
                    982:     Boot device /pci/pci/ide@3/disk@0,0 File and args: netbsd
                    983:     NetBSD IEEE 1275 Bootblock
                    984:     >> NetBSD/sparc64 OpenFirmware Boot, Revision 1.13
                    985:     >> (builds@b7.netbsd.org, Wed Jul 29 23:43:42 UTC 2009)
                    986:     loadfile: reading header
                    987:     elf64_exec: Booting [...]
                    988:     symbols @ [....]
                    989:      Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
                    990:          2006, 2007, 2008, 2009
                    991:          The NetBSD Foundation, Inc.  All rights reserved.
                    992:      Copyright (c) 1982, 1986, 1989, 1991, 1993
                    993:          The Regents of the University of California.  All rights reserved.
                    994:     [...snip...]
                    995: 
                    996: And the second disk:
                    997: 
                    998:     ok boot disk2 netbsd
                    999:     Initializing Memory [...]
                   1000:     Boot device /pci/pci/ide@3/disk@2,0: File and args:netbsd
                   1001:     NetBSD IEEE 1275 Bootblock
                   1002:     >> NetBSD/sparc64 OpenFirmware Boot, Revision 1.13
                   1003:     >> (builds@b7.netbsd.org, Wed Jul 29 23:43:42 UTC 2009)
                   1004:     loadfile: reading header
                   1005:     elf64_exec: Booting [...]
                   1006:     symbols @ [....]
                   1007:      Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
                   1008:          2006, 2007, 2008, 2009
                   1009:          The NetBSD Foundation, Inc.  All rights reserved.
                   1010:      Copyright (c) 1982, 1986, 1989, 1991, 1993
                   1011:          The Regents of the University of California.  All rights reserved.
                   1012:     [...snip...]
                   1013: 
1.6       jdf      1014: At each boot, the following should appear in the NetBSD kernel
1.1       jdf      1015: [dmesg(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dmesg+8+NetBSD-5.0.1+i386) :
                   1016: 
                   1017:     Kernelized RAIDframe activated
                   1018:     raid0: RAID Level 1
                   1019:     raid0: Components: /dev/wd0a /dev/wd1a
                   1020:     raid0: Total Sectors: 19540864 (9541 MB)
                   1021:     boot device: raid0
                   1022:     root on raid0a dumps on raid0b
                   1023:     root file system type: ffs
                   1024: 
1.6       jdf      1025: Once you are certain that both disks are bootable, verify the RAID parity is
1.1       jdf      1026: clean after each reboot:
                   1027: 
                   1028:     # raidctl -v -s raid0
                   1029:     Components:
                   1030:               /dev/wd0a: optimal
                   1031:               /dev/wd1a: optimal
                   1032:     No spares.
                   1033:     [...snip...]
                   1034:     Component label for /dev/wd0a:
                   1035:        Row: 0, Column: 0, Num Rows: 1, Num Columns: 2
                   1036:        Version: 2, Serial Number: 2009122601, Mod Counter: 67
                   1037:        Clean: No, Status: 0
                   1038:        sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
                   1039:        Queue size: 100, blocksize: 512, numBlocks: 19540864
                   1040:        RAID Level: 1
                   1041:        Autoconfig: Yes
                   1042:        Root partition: Yes
                   1043:        Last configured as: raid0
                   1044:     Component label for /dev/wd1a:
                   1045:        Row: 0, Column: 1, Num Rows: 1, Num Columns: 2
                   1046:        Version: 2, Serial Number: 2009122601, Mod Counter: 67
                   1047:        Clean: No, Status: 0
                   1048:        sectPerSU: 128, SUsPerPU: 1, SUsPerRU: 1
                   1049:        Queue size: 100, blocksize: 512, numBlocks: 19540864
                   1050:        RAID Level: 1
                   1051:        Autoconfig: Yes
                   1052:        Root partition: Yes
                   1053:        Last configured as: raid0
                   1054:     Parity status: clean
                   1055:     Reconstruction is 100% complete.
                   1056:     Parity Re-write is 100% complete.
                   1057:     Copyback is 100% complete.
                   1058: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb