(no commit message)
[ikiwiki.git] / docs / docs / howtos / howtosoftwareraid / index.mdwn
1 [[!meta title="Easy Software RAID with DragonFly BSD"]]
2
3 # Scenario
4 I am running 2.11-DEVELOPMENT DragonFly 64Bit with i5 Core on an IntelĀ® Server-Mainboard S1200BT with 8GB RAM.
5 The Main System is on two Disks mirrored RAID1 with 500GB each.
6
7 I want to use dfBSD as our company fileserver for important backups. Also I found an old (not much used) Dawi controler (with Sillicon's SiL Chip) with 4 SATA Ports that I want to use for our Backup Fileserver.
8
9 ## Goal
10 On an already running System I want to add a cheap inexpensive pool of disks keeping mission critical data.
11 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).
12
13 [[!toc  levels=3]]
14
15 # Pre-steps
16
17 ## Don't configure the SATA Adapter in the BIOS
18 Please make sure that the adapter is not configured (after the BIOS just before dfBSD starts) with RAID - just expose the disks individually to Dragonfly. We are going to setup a Software RAID.
19
20 ## Identifying the disks
21 After booting up the system please check that the Adapter you are going to use is correctly found.
22
23 dmesg reveales:
24
25         atapci1: <SiI 3114 SATA150 controller> port 0xe100-0xe10f,0xe110-0xe113,0xe120-0xe127,0xe130-0xe133,0xe140-0xe147 mem 0xfe4a1000-0xfe4a13ff irq 21 at device 0.0 on pci1
26
27 ### let natacontrol look out for our possible drives
28     su-4.2# natacontrol list
29     ATA channel 2:
30     Master:      no device present
31     Slave:       no device present
32     ATA channel 3:
33     Master:      no device present
34     Slave:       no device present
35     ATA channel 4:
36     Master:  ad8 <WDC WD10EALX-009BA0/15.01H15> Serial ATA II
37     Slave:       no device present
38     ATA channel 5:
39     Master: ad10 <WDC WD10EALX-009BA0/15.01H15> Serial ATA II
40     Slave:       no device present
41     ATA channel 6:
42     Master: ad12 <WDC WD10EALX-009BA0/15.01H15> Serial ATA II
43     Slave:       no device present
44     ATA channel 7:
45     Master: ad14 <WDC WD10EALX-759BA1/17.01H17> Serial ATA II
46     Slave:       no device present
47     ATA channel 8:
48     Master: ad16 <WDC WD5000AADS-00S9B0/01.00A01> Serial ATA II
49     Slave:       no device present
50     ATA channel 9:
51     Master: ad18 <WDC WD5000AADS-00S9B0/01.00A01> Serial ATA II
52     Slave:       no device present
53
54 Perfect, there they are: ad10 .. ad18 :-)
55
56
57 #### Problems finding the disks?
58 But you see the controller in the dmnesg message?
59 First, maybe natacontrol doesn't find them because the ata channel is not attached.
60 So attach it first! You can operate on the channels with the following commands:
61     natacontrol info channel
62     natacontrol attach channel
63     natacontrol detach channel
64     natacontrol reinit channel
65
66 Do it, until natacontrol can list all single disks you are going to use.
67
68 For further investigation you can try out other commands to find the disks:
69 also look out for the disks
70
71     sysctl kern.disks
72
73     kern.disks: ad18 ad16 ad14 ad12 da0 da1 md0
74
75
76 You could also use the devattr command:
77     devattr -m driver:disk
78   or
79     devattr -d da\* # for example
80
81
82 ## Chosing the right RAID
83 You can look around in the intert for various Raid calculators 
84 A very helpful page for general info is this one:
85 http://www.icc-usa.com/raid-calculator.asp
86 One of the better: http://kossky.sitesled.com/tools/rcdemo_en.htm
87
88 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.
89
90 Looking at the man page of natacontrol(8) we see our software RAID options:
91
92         create   Create a type ATA RAID.  The type can be RAID0 (stripe), RAID1
93               (mirror), RAID0+1, SPAN or JBOD.  In case the RAID has a RAID0
94               component, the interleave must be specified in number of sec-
95               tors.  The RAID will be created of the individual disks named
96               disk0 ... diskN.
97
98 Dont worry, natacontrol is offering more than the listed spanning RAIDs and mirroring options.
99
100 Looking into the source code on DragonFly's OpenGrok we find more options than the man pages lists:
101
102         lynx http://pkgbox64.dragonflybsd.org/source/xref/DragonFly-master/sys/sys/nata.h
103
104         struct ata_ioc_raid_config {
105                     int                 lun;
106                     int                 type;
107         #define AR_JBOD                         0x0001
108         #define AR_SPAN                         0x0002
109         #define AR_RAID0                        0x0004
110         #define AR_RAID1                        0x0008
111         #define AR_RAID01                       0x0010
112         #define AR_RAID3                        0x0020
113         #define AR_RAID4                        0x0040
114         #define AR_RAID5                        0x0080
115         
116 Ah, so we can use more than the man page documents!
117
118 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.
119
120 As I only have 4 1TB disks I think RAID0+1 is the best solution as mentioned above.
121
122
123 # Creating the Array
124
125 Let's dive into real world practice:
126
127 Just to be sure we don't overwrite the wrong disks we could list them again:
128
129     # natacontrol create RAID10 128 ad14 ad12 ad10 ad8
130     ar0 created
131
132 Interestingly RAID10 is accepted, I think it is just a synonym for RAID0+1.
133 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.)
134
135 Let's check what happened and look into the logs.
136
137
138     # dmesg | tail
139     WARNING!! - not able to determine metadata format
140     WARNING!! - Using FreeBSD PseudoRAID metadata
141     If that is not what you want, use the BIOS to create the array
142     disk scheduler: set policy of ar1 to noop
143     ar1: 1907739MB <FreeBSD PseudoRAID RAID0+1 (stripe 128 KB)> status: READY
144     ar1: disk0 READY (master) using ad8 at ata4-master
145     ar1: disk1 READY (master) using ad10 at ata5-master
146     ar1: disk2 READY (mirror) using ad12 at ata6-master
147     ar1: disk3 READY (mirror) using ad14 at ata7-master
148
149 ## Configuring the RAID
150
151 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.
152
153 Now comes the business as usual:
154
155 ### Initializing the new pseudo disk ar1 with fdisk
156
157     fdisk -BI /dev/ar1
158
159 ### Editing the disklabel
160
161     disklabel64 -B -w -r /dev/ar1s0 auto        # label it
162     disklabel64 -e ar1s0                        # edit the disklabel just created and add any partitions
163
164 ### Formatting with HAMMER
165
166     newfs_hammer -L DATA /dev/ar1s0a
167
168
169 ### Mounting, setting up fstab
170
171     mkdir /mnt/data
172     vi /etc/fstab                               # Add the appropriate entry/entries to your `/etc/fstab` 
173     mount /mnt/data
174
175
176 ### Rebooting and being HAPPY :-)
177
178     shutdown -r now
179