-[[!meta title="Easy Software RAID with DragonFly BSD and natacontrol(8)"]]
+[[!meta title="Easy Software RAID with DragonFly BSD"]]
# Scenario
I am running 2.11-DEVELOPMENT DragonFly 64Bit with i5 Core on an IntelĀ® Server-Mainboard S1200BT with 8GB RAM.
## Goal
On an already running System I want to add a cheap inexpensive pool of disks keeping mission critical data.
-Failure tolerance is more important than speed.
+Failure tolerance is more important than speed. So here I will show you how easy it is to setup a software RAID with natacontrol(8).
-[[!toc levels=2]]
+[[!toc levels=3]]
# Pre-steps
Master: ad18 <WDC WD5000AADS-00S9B0/01.00A01> Serial ATA II
Slave: no device present
-Perfect, there they are: ad10 .. ad18 :-)
+Perfect, there they are: ad8 .. ad14 :-)
-### Problems finding the disks?
-But you see the controller in the dmnesg message?
+#### Problems finding the disks?
+But you see the controller in the dmesg message?
First, maybe natacontrol doesn't find them because the ata channel is not attached.
So attach it first! You can operate on the channels with the following commands:
+
natacontrol info channel
natacontrol attach channel
natacontrol detach channel
For further investigation you can try out other commands to find the disks:
also look out for the disks
- > sysctl kern.disks
- > kern.disks: ad18 ad16 ad14 ad12 da0 da1 md0
+
+ sysctl kern.disks
+
+ kern.disks: ad14 ad12 ad10 ad8 da0 da1 md0
+
You could also use the devattr command:
+
devattr -m driver:disk
or
- devattr -d da\* # for example
+ devattr -d ad\* # for example
-
## Chosing the right RAID
-You can look around in the intert for various Raid calculators
+You can look around on the internet for various Raid calculators
A very helpful page for general info is this one:
+
http://www.icc-usa.com/raid-calculator.asp
-One of the better: http://kossky.sitesled.com/tools/rcdemo_en.htm
+
+One of the better ones: http://kossky.sitesled.com/tools/rcdemo_en.htm
+
As I want to have a Backup Fileserver I am chosing a VERY HIGH fault tolerant kind of RAID10 thing. Certainly there are other maybe better ones around, like the RAID60 or even RAID50 but we have to consider what the nata(4) driver offers and that I only have 4 disks.
tors. The RAID will be created of the individual disks named
disk0 ... diskN.
-Dont worry, natacontrol is offering more than the listed spanning RAIDs and mirroring options.
+As I only have 4 1TB disks I think RAID0+1 is the best solution as mentioned above.
-Looking into the source code on DragonFly's OpenGrok we find more options than the man pages lists:
- lynx http://pkgbox64.dragonflybsd.org/source/xref/DragonFly-master/sys/sys/nata.h
+# Creating the Array
- struct ata_ioc_raid_config {
- int lun;
- int type;
- #define AR_JBOD 0x0001
- #define AR_SPAN 0x0002
- #define AR_RAID0 0x0004
- #define AR_RAID1 0x0008
- #define AR_RAID01 0x0010
- #define AR_RAID3 0x0020
- #define AR_RAID4 0x0040
- #define AR_RAID5 0x0080
-
-Ah, so we can use more than the man page documents!
+Let's dive into real world practice and setup the RAID with a simple command:
-RAID5 is the most versatile RAID, and suitable for normal servers - Home and Office use - but in my opinion too inefficient for a backup space with financial and accounting data.
+ # natacontrol create RAID10 128 ad14 ad12 ad10 ad8
+ > ar1 created
-As I only have 4 1TB disks I think RAID0+1 is the best solution as mentioned above.
+Interestingly RAID10 is accepted, I think it is just a synonym for RAID0+1.
+The 128 is the interleave I used - which should be reasonable for this kind of setup. If you have not much space natacontrol will automatically adjust the stripe to a minor number (to 64KB a.e.)
+Let's check what happened and look into the logs.
-## Creating the Array
-Let's dive into real world practice:
+ # dmesg | tail
+ WARNING!! - not able to determine metadata format
+ WARNING!! - Using FreeBSD PseudoRAID metadata
+ If that is not what you want, use the BIOS to create the array
+ disk scheduler: set policy of ar1 to noop
+ ar1: 1907739MB <FreeBSD PseudoRAID RAID0+1 (stripe 128 KB)> status: READY
+ ar1: disk0 READY (master) using ad8 at ata4-master
+ ar1: disk1 READY (master) using ad10 at ata5-master
+ ar1: disk2 READY (mirror) using ad12 at ata6-master
+ ar1: disk3 READY (mirror) using ad14 at ata7-master
-Just to be sure we don't overwrite the wrong disks we could list them again:
- natacontrol create RAID10 128 ad8 ad10 ad12 ad14
+Ja, this is looking good ;-)
-Interestingly RAID10 is accepted, I think it is just a synonym for RAID0+1.
-The 128 is the interleave I used - which should be reasonable for this kind of setup.
+## Configuring the RAID
+
+This setup will allow your disk to work correctly with other operating systems that might be installed on your computer and will not confuse other operating systems' fdisk utilities. It is recommended to use this method for new disk installs.
+
+Now comes business as usual:
+
+### Initializing the new pseudo disk ar1 with fdisk
+
+ fdisk -BI /dev/ar1
+
+### Editing the disklabel
+
+ # label it
+ disklabel64 -B -w -r /dev/ar1s1 auto
+ # edit the disklabel just created and add any partitions. In this case it's perfect to uncomment slice a and substitute 4.2BSD with HAMMER ;-)
+ disklabel64 -e ar1s1
+
+
+### Formatting with HAMMER
+
+ newfs_hammer -L DATA /dev/ar1s1a
+
+
+### Mounting, setting up fstab
+
+ mkdir /mnt/data
+ vi /etc/fstab # Add the appropriate entry/entries to your `/etc/fstab`
+ mount /mnt/data
+
+
+# Rebooting and being HAPPY :-)
+ shutdown -r now