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

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

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