Beyhan CALISKAN <byhkaan *noSPAM* gmail.com>

Installing OpenBSD on a software RAID1

1. Perform basic installation

At the disk setup stage only use one of the disk (in our example it is wd0 )

Initial label editor (enter '?' for help at any prompt)
> z
> a a
offset: [63]
size: [#########] 1g
FS type: [4.2BSD]
mount point: [none] /
> a b
offset: [########]
size: [#########] 512m
FS type: [swap]
> a d
offset: [########]
size: [#########]
FS type: [4.2BSD] RAID (THIS IS THE IMPORTANT POINT)
mount point: [none]
> q
Write new label?: [y]
Available disks are: wd1.
Which one do you wish to initialize? (or 'done') [done]
The next step *DESTROYS* all existing data on these partitions!
Are you really sure that you're ready to proceed? [no] y

Reboot after normal installation procedures ....

2. Initialize the second disk and build RAID supported Kernel

openbsd# disklabel -E wd1
Initial label editor (enter '?' for help at any prompt)
> z
> a a
offset: [63]
size: [###########]
FS type: [4.2BSD]
> q
Write new label? [y]

openbsd# newfs /dev/rwd1a

openbsd# mount /dev/wd1a /mnt

openbsd# cd /mnt

openbsd# ftp ftp://ftp.ulak.net.tr/OpenBSD/4.6/sys.tar.gz (fetch the kernel source)

openbsd# tar zxvf sys.tar.gz

openbsd# cd sys/arch/amd64/conf

openbsd# vi GENERIC (uncomment "pseudo-device raid 4" line and add below "option RAID_AUTOCONFIG" )

openbsd# config GENERIC.MP (probably you have multiplie cpu core, if not try "config GENERIC" )

openbsd# cd ../compile/GENERIC.MP && make depend && make -j8

openbsd# mv /bsd /bsd.old

openbsd# mv bsd /bsd (replace with new kernel)

openbsd# rm -rf /mnt/* && reboot

openbsd# disklabel wd0 > wd1_disklabel

openbsd# fdisk -i wd1 (say [y] here)

openbsd# disklabel -R wd1 wd1_disklabel

3. Setting up RAID configuration

openbsd# vi /etc/raid0.conf (add below lines)

START array
1 2 0
START disks
/dev/wd0d
/dev/wd1d
START layout
128 1 1 1
START queue
fifo 100

openbsd# mount /dev/wd1a /mnt && cd /mnt

openbsd# dump -0f - / | restore -rf -

openbsd# cd /

openbsd# /usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot wd1

openbsd# umount /mnt

openbsd# raidctl -C /etc/raid0.conf raid0

openbsd# raidctl -I 100 raid0

openbsd# raidctl -iv raid0 (depending on disk size parity re-write takes some time)

openbsd# disklabel -E raid0

Initial label editor (enter '?' for help at any prompt)
> a a (/)
offset: [0]
size: [#########] 10g
FS type: [4.2BSD]
> a b (swap)
offset: [######]
size: [#########] 1g
FS type: [swap]
> a d (/usr)
offset: [#######]
size: [#########] 20g
FS type: [4.2BSD]
> a e (/var)
offset: [########]
size: [#########] 20g
FS type: [4.2BSD]
> q
Write new label? [y]

openbsd# newfs /dev/rraid0a

openbsd# newfs /dev/rraid0d

openbsd# newfs /dev/rraid0e

NOTE: do not make newfs on rraid0b (swap) !!!

openbsd# mount /dev/raid0a /mnt

openbsd# mkdir /mnt/var && mkdir /mnt/usr

openbsd# mount /dev/raid0d /mnt/var

openbsd# mount /dev/raid0e /mnt/usr

openbsd# cd /mnt

openbsd# dump -0f - / | restore -rf -

openbsd# raidctl -A root root0 (make raid disk bootable)

openbsd# vi /mnt/etc/fstab (change fstab like below)

dev/raid0a / ffs rw 1 1
/dev/raid0b none swap sw 0 0
/dev/raid0d /var ffs rw,nodev,nosuid,softdep 1 2
/dev/raid0e /usr ffs rw,nodev,softdep 1 2

openbsd# reboot

openbsd# raidctl -sv raid0 (show raid status)

WELL DONE !!!