Tag Archives: IT

RAID-5 Horror Story – A tale of woe and notes on how to avoid a similar fate

As a starting point, since someone is sure to mention it, I KNOW THAT RAID IS NOT A BACKUP!!. On the other hand I’ve yet to meet someone who can tell me an affordable way to back up a 12TB array short of buying enough disks to clone it.

I’ve had a home-build linux md server for quite some time now. Brought the array online ~2011 and have grown it multiple times since then. It was at 7 x 2TB (apparently a bad idea all by itself, not that the software would warn you when you add the disk to the pool) disks and over the years had survived disk failures, power cuts while being grown, and 2 house moves.

Basic Setup

  • Linux MD disk array
  • 7 x 2TB 3.5″ SATA Disks
  • Whole disk (or array in this case) encryption (cryptsetup)
  • XFS Filesystem on top

Where it started to go wrong

It started, as these things usually do with an e-mail from my server, cheerfully informing me that one of the disks had died and that the raid array was degraded. Not really a problem as this had happened before without major drama.

  • Order a new disk
  • Figure out which one is /dev/sdf
    • hwinfo --disks helps a lot for this since it can get serial numbers
  • Shut the server down
  • Swap in the new disk
  • Add it to the array, and take things easy while it rebuilds (approx time required ~10 hours when disks are not being used)

And that was when I hit the dreaded Unrecoverable Read Error 🙁 Much has been written about this, but it was my first experience of it (and won’t forget it in a hurry).

[  772.229943] md: bind<sdh>
[  772.793789] RAID conf printout:
[  772.793794]  --- level:5 rd:7 wd:6
[  772.793798]  disk 0, o:1, dev:sdg
[  772.793802]  disk 1, o:1, dev:sdh
[  772.793805]  disk 2, o:1, dev:sdi
[  772.793809]  disk 3, o:1, dev:sdf
[  772.793812]  disk 4, o:1, dev:sdd
[  772.793816]  disk 5, o:1, dev:sdb
[  772.793819]  disk 6, o:1, dev:sda
[  772.794310] md: recovery of RAID array md0
[  772.794316] md: minimum _guaranteed_  speed: 1000 KB/sec/disk.
[  772.794368] md: using maximum available idle IO bandwidth (but not more than 200000 KB/sec) for recovery.
[  772.794378] md: using 128k window, over a total of 1953514496k.
...
[35295.808096] ata9.00: exception Emask 0x0 SAct 0x7fffffff SErr 0x0 action 0x6 frozen
[35295.808105] ata9.00: failed command: READ FPDMA QUEUED
[35295.808116] ata9.00: cmd 60/08:00:20:01:ce/00:00:ab:00:00/40 tag 0 ncq 4096 in
[35295.808118]          res 40/00:01:00:4f:c2/00:00:00:00:00/00 Emask 0x4 (timeout)
[35295.808124] ata9.00: status: { DRDY }
[35397.139031] sd 8:0:0:0: [sdf]  Add. Sense: Unrecovered read error - auto reallocate failed
[35397.139041] sd 8:0:0:0: [sdf] CDB: Read(10): 28 00 ab cd f8 58 00 03 08 00
[35397.139057] end_request: I/O error, dev sdf, sector 2882403160
[35397.139066] md/raid:md0: read error not correctable (sector 2882403160 on sdf).
[35397.139073] md/raid:md0: Disk failure on sdf, disabling device.
[35397.139075] md/raid:md0: Operation continuing on 5 devices.
[35397.139116] ata9: EH complete
[35397.708320] md: md0: recovery done.
[35397.822385] RAID conf printout:
[35397.822391]  --- level:5 rd:7 wd:5
[35397.822397]  disk 0, o:1, dev:sdg
[35397.822401]  disk 1, o:1, dev:sdh
[35397.822405]  disk 2, o:1, dev:sdi
[35397.822409]  disk 3, o:0, dev:sdf
[35397.822412]  disk 4, o:1, dev:sdd
[35397.822416]  disk 5, o:1, dev:sdb
[35397.822419]  disk 6, o:1, dev:sda
[35397.824183] RAID conf printout:
[35397.824188]  --- level:5 rd:7 wd:5
[35397.824191]  disk 0, o:1, dev:sdg
[35397.824195]  disk 2, o:1, dev:sdi
[35397.824198]  disk 3, o:0, dev:sdf
[35397.824201]  disk 4, o:1, dev:sdd
[35397.824205]  disk 5, o:1, dev:sdb
[35397.824208]  disk 6, o:1, dev:sda
[35397.824218] RAID conf printout:
[35397.824221]  --- level:5 rd:7 wd:5
[35397.824224]  disk 0, o:1, dev:sdg
[35397.824228]  disk 2, o:1, dev:sdi
[35397.824231]  disk 3, o:0, dev:sdf
[35397.824234]  disk 4, o:1, dev:sdd
[35397.824237]  disk 5, o:1, dev:sdb
[35397.824240]  disk 6, o:1, dev:sda
[35397.824380] RAID conf printout:
[35397.824386]  --- level:5 rd:7 wd:5
[35397.824390]  disk 0, o:1, dev:sdg
[35397.824394]  disk 2, o:1, dev:sdi
[35397.824398]  disk 4, o:1, dev:sdd
[35397.824401]  disk 5, o:1, dev:sdb
[35397.824404]  disk 6, o:1, dev:sda

At which point the array is basically dead. Which seems a bit insane – read error in one sector makes 12TB of data unavailable but there you go. We apparently can’t mount, rebuild or do anything – bear in mind that at this point all our data is still intact, except for that one dodgy sector. Looking at the raid array in more detail (it is a mess):

[~]=> sudo mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Mon May 16 22:34:59 2011
     Raid Level : raid5
  Used Dev Size : 1953514496 (1863.02 GiB 2000.40 GB)
   Raid Devices : 7
  Total Devices : 5
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed Apr 29 12:28:08 2015
          State : active, FAILED, Not Started 
 Active Devices : 4
Working Devices : 5
 Failed Devices : 0
  Spare Devices : 1

         Layout : left-symmetric
     Chunk Size : 64K

           UUID : 4a3bba9b:8299bd9b:3cb2199d:f2060f75
         Events : 0.1434672

    Number   Major   Minor   RaidDevice State
       0       8       96        0      active sync   /dev/sdg
       1       0        0        1      removed
       2       8      128        2      active sync   /dev/sdi
       3       0        0        3      removed
       4       8       48        4      active sync   /dev/sdd
       5       8       16        5      active sync   /dev/sdb
       6       0        0        6      removed

       7       8      112        -      spare   /dev/sdh

Pay close attention to the metadata version – this is where I went horribly wrong (more on that later). From the list of disks we have /dev/sdf removed automatically due to the read error and /dev/sdh in as a spare since it was in the process of being synced when everything went pear shaped.

Steps to recovery

At this point I was quite annoyed and a bit desperate so I concocted a plan that would have worked, but for one mistake. My plan was simple

  1. Remove /dev/sdh from the md0 set – it’s basically useless now anyway
  2. Get /dev/sdf back in by recreating the array
  3. Run XFS checks on the file system to be sure that is ok
  4. Use gddrescue to clone the slightly dodgy /dev/sdf to /dev/sdh – with multiple retries to try and get the problem sector
  5. Reassemble the array using /dev/sdh rather then /dev/sdf
  6. Buy another new disk and slot it in and hope the rebuild works this time
  7. Low level format /dev/sdf to get the sector marked as bad. If that fails, bin it.
  8. Convert to RAID-6 so this can’t happen again

Step 1 went as expected:

[~]=> sudo mdadm --remove /dev/md0 /dev/sdh
mdadm: hot removed /dev/sdh from /dev/md0
[~]=> sudo mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Mon May 16 22:34:59 2011
     Raid Level : raid5
  Used Dev Size : 1953514496 (1863.02 GiB 2000.40 GB)
   Raid Devices : 7
  Total Devices : 5
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed Apr 29 12:41:58 2015
          State : active, FAILED, Not Started 
 Active Devices : 5
Working Devices : 5
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 64K

           UUID : 4a3bba9b:8299bd9b:3cb2199d:f2060f75
         Events : 0.1434673

    Number   Major   Minor   RaidDevice State
       0       8       96        0      active sync   /dev/sdg
       1       0        0        1      removed
       2       8      128        2      active sync   /dev/sdi
       3       8       80        3      removed
       4       8       48        4      active sync   /dev/sdd
       5       8       16        5      active sync   /dev/sdb
       6       8        0        6      active sync   /dev/sda

So I decided to re-create the array rather then re-assemble (with assume-clean), and here I went very wrong. I didn’t specify the metadata version.

MD RAID Metadata Versions

It used to be the default format of raid superblock during array creation on most distributions until 2009, the older version-0.90 superblock format had several limitations that limited its applicability for use on large arrays or arrays with many component devices.

The version-0.90 superblock limits the number of component devices within an array to 28, and limits each component device to a maximum size of 2TB on kernel version <3.1 and 4TB on kernel version >=3.1.

The superblock is 4K long and is written into a 64K aligned block that starts at least 64K and less than 128K from the end of the device (i.e. to get the address of the superblock round the size of the device down to a multiple of 64K and then subtract 64K). The available size of each device is the amount of space before the super block, so between 64K and 128K is lost when a device in incorporated into an MD array.

Also, and this is important – it is stored at the end of the device. If you want mdadm to use this you have to specify –metadata=0.9

The shiny new (and now the default) is version 1.2 which grabs 4K from the beginning of the device, and while doing so torches the XFS superblock.

XFS Gone

When I realised my mistake, got the drives into a sort of working order, and mounted, I was presented with

[~]=> sudo mount /dev/mapper/storage /mnt/storage
mount: /dev/mapper/storage: can't read superblock

From our message log

[ 1337.665651] SGI XFS with ACLs, security attributes, realtime, large block/inode numbers, no debug enabled
[ 1337.666154] SGI XFS Quota Management subsystem
[ 1337.666931] XFS (dm-3): Mounting Filesystem
[ 1339.452417] XFS (dm-3): Log inconsistent (didn't find previous header)
[ 1339.452441] XFS (dm-3): failed to find log head
[ 1339.452447] XFS (dm-3): log mount/recovery failed: error 5
[ 1339.452524] XFS (dm-3): log mount failed

xfs_repair, after throwing around many dots seemed to be completely unhappy with any of the secondary superblocks, and UFS Recover could only re-assemble some bits and pieces.

And that was the end of that.

Lessons learned

  • Never more the 4 devices in RAID-5
  • Always make a backup
  • Be very very careful when trying to repair
  • For tools that have been in service for longer then a few months, be very very careful. Some idiot developer has probably changed the defaults in a way that will screw you

UPC Ireland – Tiers of Service and NAT

The 120Mbps Tier

As a long time and very happy UPC customer (120Mb unlimited package) I was quite pleased with the service offered – to local speedtest server 10ms RTT, 118Mbps down, 10Mbps up, generous ‘fair-use’ limits and most importantly a public IP address.

Ideally, I’d like to use my own modem/router but instead I’m stuck with the Thompson TWG870, though to be fair it’s not the worst in the world. Not sure when, if ever, the firmware has ever been updated but all the important settings are at least accessible.

The 60Mbps Tier

With a new job I’m based in Limerick at least some of the time so made the decision to put in the basic package (60Mbps, 30Gb cap) and not bother with TV service. Installation was fine but no self-install so ended out having to sit at home for the scheduled installation window… 09:00 – 18:00 – they do make it easy for themselves.

Once installed and the tech out the door I had a poke at the new box. This one seems to be infamous as the Technicolor 7200 – clearly one of the cheapest cable modem/Wireless APs ever built. Prettier interface but fewer configuration options. Also issues with the WiFi connections to a Mac (not the only router to have this problem to be fair – I blame Apple).

Horizon WiFree

Interestingly the default internal IP range for the network is 192.168.1.0/24. When I tried to switch it to the more conventional 192.168.1.0/24 I was told that that address range is already in use. It seems that Horizon Wi-Free is configured to use the 192.168.1.0/24 subnet and that portion of the configuration is hidden away somewhere with the only options being to turn it on or off.

Public IPs

As I stated above something I love about the service I had was the public IP address. Making full use of the options that gives you I have a number of self-hosted ‘cloud’ services running on a Linux box I keep running – file store, VPN, Media Library, Document backup, etc. For the new gaff I have a RaspberryPi B+ that I use to run RASPBMC and a few other small services, but just by default had intended to make that internet accessible – sadly it was not to be.

It seems that the lowest tier of UPC has you running through a NAT system at some point. So while I have the port forwarding setup on the router, nothing reaches the Pi. It also seems to have some very aggressive ageing of flows running – had to set SSH keepalives to <60 seconds or the connections were constantly dropping. Poking at the IP address my connections seem to be originating from I see that there are two different pools in use (not unexpected in any case e.g. Dublin vs. rest of country).

Lowest Tier (60Mbps)


[colinmac@thor][~]=> dig +answer -x 188.141.a.b

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> +answer -x 188.141.a.b
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, a.bid: 22797
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;115.82.141.188.in-addr.arpa.   IN      PTR

;; ANSWER SECTION:
115.82.141.188.in-addr.arpa. 86389 IN   PTR     188-141-82-115.dynamic.upc.ie.

;; Query time: 15 msec
;; SERVER: 89.101.160.5#53(89.101.160.5)
;; WHEN: Tue Aug 26 09:04:24 2014
;; MSG SIZE  rcvd: 88

Notice the Pointer Record has the dynamic.upc.ie

Middle Tier (120Mbps)


[colinmac@thor][~]=> dig +answer -x 109.255.x.y

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> +answer -x 109.255.x.y
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 54912
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;7.123.255.109.in-addr.arpa.    IN      PTR

;; AUTHORITY SECTION:
255.109.in-addr.arpa.   600     IN      SOA     ns1.upc.biz. hostmaster.chello.at. 2010071503 86400 7200 2592000 7200

;; Query time: 33 msec
;; SERVER: 89.101.160.5#53(89.101.160.5)
;; WHEN: Tue Aug 26 09:05:04 2014
;; MSG SIZE  rcvd: 111

Whereas for the higher tier we have the Start Of Authority record pointing back towards the older chello and our nameserver is sitting within a biz domain.

Will add more to this post later 🙂

Internet Access in Awkward Places

Finally got around to putting up a description of a project I’ve been poking along for a while to put Internet access and a remotely accessible security camera in the parents holiday home (ld building, thick walls and no wireline connectivity) – all the hardware used and details on the build are available here.

Link

An EMC systems engineer has written a blog post about the VMAX FAST VP array. While it’s full of good advice, he unintentionally sums up everything that’s wrong with many applications in IT today: the knobs.

This is a problem I’ve seem more then once – the box has many nerd-knobs and therefore people feel they have to fiddle with them. Once they start to do that, inevitably something goes wrong and the performance drops. Then they start to fiddle some more to try and ‘fix’ it, until there are so many knobs turned it is impossible to maintain/troubleshoot.