Wednesday, January 26, 2011

softraid on OpenBSD 4.9

Scenario: 1 Operating system hard drive and 2 hard drives to be configured as a RAID 1 mirror

checking the dmesg and /etc/fstab, wd0 is the boot drive and wd1 + wd2 are supposed to be the mirror drives

Below is slightly modified content of manpage of softraid

            # fdisk -iy wd1
            # fdisk -iy wd2

Now create RAID partitions on all disks:
            # printf "a\n\n\n\nRAID\nw\nq\n\n" | disklabel -E wd1
            # printf "a\n\n\n\nRAID\nw\nq\n\n" | disklabel -E wd2


Assemble the RAID volume:

            # bioctl -c 1 -l /dev/wd1a,/dev/wd2a softraid0

It is good practice to wipe the front of the disk before using it:

            # dd if=/dev/zero of=/dev/rsd0c bs=1m count=1

Initialize the partition table and create a filesystem on the new RAID volume:

           # fdisk -iy sd0
           # printf "a\n\n\n\n4.2BSD\nw\nq\n\n" | disklabel -E sd0
           # newfs /dev/rsd0a
------------------------------------------------------------------------------------------------------
Now the next part is missing from manpage, but its trivial.

           # mkdir /datamirror
           # mount /dev/sd0a /datamirror (OR mount -t ffs /dev/sd0a /datamirror)
           # chown  normal_openbsd_user /datamirror

if the mount works, then add the following line to the very end of /etc/fstab to make it work everytime after normal boot.

/dev/sd0a /datamirror ffs rw,softdep,nodev,nosuid 1 2

2 Comments:

Anonymous Anonymous said...

And how I can do if I want to do a raid 1 with all the system ? Just with wd0 and wd1.

Thanks.

Wed Feb 23, 03:47:00 AM 2011  
Blogger Amit Kulkarni said...

To me Operating System disk is not that valuable. I value data more than OS. So if it dies, just replace. I personally save my current configuration (etc/pf.conf, etc/rc.conf.local etc) in a different machine.

Sorry I couldn't help, ask on misc@ for help

Fri Feb 25, 02:17:00 PM 2011  

Post a Comment

Links to this post:

Create a Link

<< Home