# RAID1 degraded mode



## noobster (Feb 26, 2010)

I have the following errors in /var/log/messages:


```
Feb 25 04:39:44 host kernel: ad4: TIMEOUT - READ_DMA48 retrying (1 retry left) LBA=2633433538
Feb 25 04:39:44 host kernel: ad4: FAILURE - READ_DMA48 status=51<READY,DSC,ERROR> error=10<NID_NOT_FOUND> LBA=2633433538
Feb 25 04:39:44 host kernel: ar0: WARNING - mirror protection lost. RAID1 array in DEGRADED mode
Feb 25 04:39:44 host kernel: ar0: writing of nVidia MediaShield metadata is NOT supported yet
```

Does this necessarily imply a hardware failure? Is it safe to reboot the machine? I vaguely remember a situation like this before, when after rebooting the system assumed the array was healthy which eventually lead to a crash, I guess because the drives were out of sync.

Any help is appreciated.


----------



## SirDice (Feb 26, 2010)

Looks like one of the drives of your mirror is broken. Most likely due to bad sectors. Replace it.


----------



## User23 (Feb 26, 2010)

The following Message means to me that FreeBSD cant tell the bios of the "raid controller" that ad4 is degraded.



			
				noobster said:
			
		

> I have the following errors in /var/log/messages:
> Feb 25 04:39:44 host kernel: ar0: writing of nVidia MediaShield metadata is NOT supported yet
> ...
> I vaguely remember a situation like this before, when after rebooting the system assumed the array was healthy which eventually lead to a crash.




```
man ataraid


DESCRIPTION
     The ataraid driver provides support for so-called software RAID (some-
     times referred to as fake RAID or pseudo RAID).

     When a controller that supports software RAID is instructed to create a
     RAID array, its BIOS writes data structures in a specific metadata format
     to the disks.  These data structures are picked up by the ataraid driver,
     so that FreeBSD can work with the array.  The ataraid driver has to
     understand the specific metadata format of a controller BIOS in order to
     support its RAID capabilities.

     Read-only support for a metadata format means that FreeBSD can use the
     given RAID array for normal read/write operations.  Creation and rebuild
     of such arrays has to be done from the controller BIOS.
```

Make a backup of all important data in that situation.
After that i would shutdown the computer, and use the bios of the "raid controller" to replace ad4 and rebuild the array.

good luck

--

imho: thats why i always pray dont use this poor chipset implemented raid functions ... use software raid instead or a real raid controller.


----------



## kisscool-fr (Feb 26, 2010)

Maybe you should install smartmontools and check your disks with smartctl. 
It may exclude or not the hardware.


----------



## achix (Feb 26, 2010)

.... or just scrap those broken semi-hardware semi-software ATA raid controllers and deploy FreeBSD software RAID1, GEOM(4)'s gmirror(8) instead.
Has worked really nice for me, (tested in-vivo in the case of a damaged hard disk, already).
ATA raid for me never did what it was supposed to do. (although, that was back in FreeBSD-6 i must say).


----------



## noobster (Feb 26, 2010)

Thanks for all the useful replies. In the future I'll look into gmirror, but for now I have to stick to my current configuration. Obviously, I have backups of all the data but I prefer not to restore because there's lots of it.

I will run smartctl to check the condition of the harddisk. Apparently, the harddisk could be healthy: http://wiki.freebsd.org/JeremyChadwick/ATA_issues_and_troubleshooting. In any case, the next time I reboot I should make sure that I remove ad4 from the raid to prevent any problems caused by the harddisks being out of sync. This sounds tricky (and a good argument for using gmirror) but I hope it'll work.


----------



## noobster (Mar 5, 2010)

I decided to switch to using gmirror. Any advice how to set it up?


----------



## dennylin93 (Mar 5, 2010)

Take a look at RAID1 - Mirroring.


----------



## User23 (Mar 5, 2010)

Please rtfm >

---

Lets say you have installed freebsd on ad4 and want to use it with ad6 as a mirror:

set the geom debug flag or the following operation will not be permitted


```
sysctl kern.geom.debugflags=16
```

--

create a gmirror (plz read the manpage for other methods than round-robin)


```
gmirror label -v -b round-robin gm0 ad4
```

--

add the following line to your /boot/loader.conf because geom_mirror is not part of the GENERIC kernel.


```
geom_mirror_load="YES"
```

--

edit your /etc/fstab and replace /dev/ad4* with /dev/mirror/gm0*


```
Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/mirror/gm0s1b              none            swap    sw              0       0
/dev/mirror/gm0s1a              /               ufs     rw              1       1
/dev/mirror/gm0s1f              /home           ufs     rw              2       2
/dev/mirror/gm0s1d              /usr            ufs     rw              2       2
/dev/mirror/gm0s1e              /var            ufs     rw              2       2

# old entries
#
#/dev/ad4s1b              none            swap    sw              0       0
#/dev/ad4s1a              /               ufs     rw              1       1
#/dev/ad4s1f              /home           ufs     rw              2       2
#/dev/ad4s1d              /usr            ufs     rw              2       2
#/dev/ad4s1e              /var            ufs     rw              2       2
```

--

ok everything should be ready to


```
reboot
```

--

add the second harddrive to gm0


```
gmirror insert gm0 ad6
```

--

now gmirror will sync the disks. you can prove that with


```
gmirror list
```

--

iostat can show you with how many MB/s the second disk ist syncing. Because every bit is synced you can calculate how long its take, depending on the harddisk size.


```
iostat -vm
```


----------



## noobster (Mar 5, 2010)

Thanks for the useful feedback. Btw,


```
sysctl kern.geom.debugflags=16
```

should be


```
sysctl kern.geom.debugflags=17
```

according to the handbook.


----------



## noobster (Mar 8, 2010)

I set up gmirror without problems. However, I am trying to use geli on top and that doesn't work yet. I can see /dev/mirror/gm0s2, which is my geli encrypted slice, but when I run `geli attach /dev/mirror/gm0s2` it shows the error

```
geli: Cannot read metadata from /dev/mirror/gm0s2: No such file or directory.
```
Any suggestions how to make this work?


----------



## noobster (Mar 8, 2010)

Problem solved. If you create a mirror out of the boot drive, the last sector is overwritten. This sector was part of my geli encrypted slice and, consequently, resulted in the problem I encountered. The solution is easy: shrink the slice slightly. Nasty.


----------

