File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_install_netbsd_on_raid1_using_raidframe.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sun Feb 5 07:14:36 2012 UTC (2 years, 2 months ago) by schmonz
Branches: MAIN
CVS tags: HEAD
dos2unix

In this article I will explain, step by step, how to install NetBSD on a RAID-1 root disk.

**Contents**

[[!toc]]

#Foreword

So, you just got yourself a pair of shiny new SCSI or SATA disks? You care about your data and you think backup is as important as having redundant data? You are disappointed because the netbsd raid1-root guide at [1](http://www.netbsd.org/docs/guide/en/chap-rf.html#chap-rf-ex-raid1root) looks rather complicated? You want to setup a raid1 mirror during installation? This guide is losely based on the netbsd.org guide above, so check that out as well to get a better understanding of what's happening here.
#Requirements

[NetBSD 5.0](http://www.netbsd.org/releases/formal-5/NetBSD-5.0.html) and 2 free harddisks :-)
#Booting from the CD

Boot the NetBSD 5.0 CD and, after selecting your language and keyboard layout, navigate to

    e: Utility menu

and then

    a: Run /bin/sh

Now make sure you know your disk names, you can either see them during boot (you can get those messages again by typing dmesg at the shell prompt you just opened) or use something like sysctl hw.disknames. I'll use wd0 and wd01 (both as whole disk) in this guide. 

#fdisk

Let's interactively setup the first partition on both disks with *fdisk* and mark the active partition as well (**bold text** is what you should enter, otherwise just accept the default by pressing return):

# fdisk -0ua wd0  
<fdisk>  
fdisk: primary partition table invalid, no magic in sector 0  
Disk: /dev/rwd0d  
NetBSD disklabel disk geometry:  
cylinders: 16645, heads: 16, sectors/track: 63 (1008 sectors/cylinder)  
total sectors: 16778160  
  
BIOS disk geometry:  
cylinders: 1024, heads: 255, sectors/track: 63 (16065 sectors/cylinder)  
total sectors: 16778160  
  
Do you want to change our idea of what the BIOS thinks? [n]  
  
Partition 0:  
<UNUSED>  
The data for partition 0 is:  
<UNUSED>  
sysid: [0..255 default: 169]  
start: [0..1044cyl default: 63, 0cyl, 0MB]  
size: [0..144cyl default: 16778097, 1044cyl, 8192MB]  
bootmenu: []  
Do you want to change the active partition? [n] **y**  
Choosing 4 will make no partition active.  
active partition: [0..4 default: 0]  
Are you happy with this choice? [n] **y**  
  
We haven't written the MBR back to disk yet.  This is your last chance.  
Partition table:  
0: NetBSD (sysid 169)  
    start 63, size 33555249 (16384 MB, Cyls 0-2088/183/63), Active  
1: <UNUSED>  
2: <UNUSED>  
3: <UNUSED>  
Bootselector disabled.  
First active partition: 0  
Should we write new partition table? [n] **y**  
 
Do the same for wd1:

    # fdisk -0ua wd1
... see above

#disklabel

Now we need to edit the disklabel, it's easy, we just need to change one thing:

# disklabel -i -I wd0  
partition> **P**  
...  
e:  33555312         63       4.2BSD     ...  
partition> **e**  
Filesystem type [?] [4.2BSD]: **RAID**  
Start offset ('x' to start after partition 'x') [0.0625c, 63s, 0.0307617M]:  
Partition size ('$' for all remaining) [16644.9c, 16778097s, 8192.43M]:  
partition> **W**  
Label disk [n]?**y**  
Label written  
partition> **Q**  

Note that the letter e is only an example; you need to identify your root partition

Do the same with wd1

    # disklabel -i -I wd1
...

You may save typing by copying the configuration:

    # disklabel wd0 >/tmp/wd0.inf
    # disklabel -R wd1 /tmp/wd0.inf

#raid0.conf and raidctl

Next we'll configure RAIDframe (again, check the guide above, and the [raidframe manpage](http://netbsd.gw.com/cgi-bin/man-cgi?raidctl++NetBSD-current), what all this is about):
<pre><code>
# cat > /tmp/raid0.conf
START array
1 2 0

START disks
/dev/wd0e
/dev/wd1e

START layout
128 1 1 1

START queue
fifo 100
^D
# raidctl -v -C /tmp/raid0.conf raid0
raid0: Component /dev/wd0e being configured at col: 0
         Column: 0 Num Columns: 0
         Version: 0 Serial Number: 0 Mod Counter: 0
         Clean: No Status: 0
Number of columns do not match for /dev/wd0e
/dev/wd0e is not clean!
raid0: Component /dev/wd1e being configured at col: 1
         Column: 0 Num Columns: 0
         Version: 0 Serial Number: 0 Mod Counter: 0
         Clean: No Status: 0
Number of columns do not match for /dev/wd1e
/dev/wd1e is not clean!
raid0: There were fatal errors
raid0: Fatal errors being ignored.
raid0: RAID Level 1
raid0: Components: /dev/wd0e /dev/wd1e
raid0: Total Sectors 16777984 (8192 MB)
# raidctl -v -I 2009072201 raid0
# raidctl -v -i raid0
Initiating re-write of parity
Parity Re-write status:
 98% |***************************************| ETA:    00:01 -
# raidctl -v -A root raid0
raid0: New autoconfig value is: 1
raid0: New rootpartition value is: 1
raid0: Autoconfigure: Yes
raid0: Root: Yes
</code></pre>
#installboot

One last thing, we need to make both disks bootable:

    # installboot -o timeout=30 -v /dev/rwd0e /usr/mdec/bootxx_ffsv1
    File system:		/dev/rwd0e
    Primary bootstrap:	/usr/mdec/bootxx_ffsv1
    Ignoring PBR with invalid magic in sector 0 of '/dev/rwd0e'
    Boot options:		timeout 30, flags 0, speed 9600, ioaddr 0, console pc
    # installboot -o timeout=30 -v /dev/rwd1e /usr/mdec/bootxx_ffsv1
    ...

#Returning to sysinst

And that's it, return to sysinst and continue the installation of NetBSD, just select *raid0* as the disk you want to install NetBSD to (and, of course, make sure you can boot from both disks after that):

    # exit

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