Removing E (DiskError) flag on system drive of a Synology NAS

By dose | March 14, 2023
Under: Uncategorized

Recently, I came across the following problem: A user of a Synology DiskStation wanted upgrade the disk drives to bigger ones. So he tried to do everything correctly:
First, he identified the list of possible disk drives officially supported for his Disk Station and bought the appropriate hard disk.
Then removed one disk drive (drive 2) in the bay and exchanged it with one of the newly bought disks and tols the NAS to repair the volume in order to sync system and data to the new drive.
And here is, where the problems started: The data RAID fortunately synced fine to the second drive, but the System RAID did not sync and left him with a faulty system volume.

This is where I came into play. A quick check via commandline revealed the following status:

sh-4.3# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] 
[raid4]
md2 : active raid1 sda5[2] sdb5[1]
1948779648 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sda2[0] sdb2[1]
2097088 blocks [2/2] [UU]

md0 : active raid1 sdb1[1](E)
2490176 blocks [2/1] [_E]

Now my first thought was: Status E? I’m used to Linux Software RAID, but I never saw such a RAID status code. Checked documentation, no mention if it either. It’s not “F” for faulty, it’s “E”.
After digging around in Google I finally figured out that this is a proprietary status code from Synology RAIDs not implemented in official Linux kernel.

Now how to find out more about it? I found an article on how to reset the “Faulty” flag on an existing array disk, but it didn’t sound very safe given the fact that I didn’t know the original RAID parameters of the RAID. 
Now the first thing to do when working with such volumes obviously is to make a copy and work only with the copied drive to have the original drive secured in case something goes wrong. So I dug out another good spare drive of the same size from my collection and copied the existing drive to it sector per sector with dd.

During copying, it turned out there was a bad block (fortunately only one!) on the original drive within the system partition, so that was the reason why the drive’s state went to “E”, which seems to indicate “Disk error”. ddrescue to the rescue! It skipped the bad sector and I had a working copy of the drive to mess around with. I later checked the location of the bad sector and there were sectors with 00s around it, so I guess that there was nothing important on that bad sector anyway.

Now how to reset this damn E flag? First, I needed to identify the Superblock of the RAID volume that went bed. So obviously, just examine it with

mdadm --examine /dev/sdb1

right? BOOM:

mdadm: No md superblock detected on /dev/sdb1.

Where the heck is it? After much googling around, I found a hint, that the Superblock has swapped endianness and was in fact version 0.9 as opposed to the data partition which has a version 1.2 superblock:

# mdadm --examine /dev/sdb1 -e 0
mdadm: No super block found on /dev/sdb1 (Expected magic a92b4efc, got fc4e2ba9)

Now the author of the article changed byte endianness to use the RAID on a PC, but my intention was to just remove the E flag and not mess around with the partition style. By looking at the mdadm source code, I found out that there already was a parameter to obey the different endianness of the superblock, the parameter to be specified is: “-e 0.9” 

So I finally was able to dump the superblock of the disk with:

# ./mdadm.synology --examine /dev/sdb1 -e 0.9
/dev/sdb1:
 Magic : a92b4efc
 Version : 0.90.00
 UUID : 5b116fc2:267b242b:3017a5a8:c86610be
 Creation Time : Sat Jan 1 00:00:02 2000
 Raid Level : raid1
 Used Dev Size : 2490176 (2.37 GiB 2.55 GB)
 Array Size : 2490176 (2.37 GiB 2.55 GB)
 Raid Devices : 2
 Total Devices : 1
Preferred Minor : 0

Update Time : Wed Mar 8 16:25:39 2023
 State : clean
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
 Spare Devices : 0
 Checksum : c15399ef - correct
 Events : 12649239


 Number Major Minor RaidDevice State
this 1 8 17 1 active sync /dev/sdb1

0 0 0 0 0 removed
 1 1 8 17 1 active sync /dev/sdb1

When looking at the output, the array component seemed to be in a perfectly fine condition, no sign of the failure indication from Synology. So I checked the available open source of the Synology Linux kernel for this disk error flag. Turns out that it can be found in md_p.h header file:

#ifdef MY_ABC_HERE
#define MD_DISK_ERROR 6 
#endif

Fortunately, Synology marked all their changes to the Stock Linux kernel with the #define MY_ABC_HERE, so specific code paths are easy to spot in the source.
Next, I had to identify the location of the flag in the superblock to confirm my findings. I hexdumped the superblock of the affected device. The 0.90 superblock is of struct mdp_superblock_s, which -according to md_p.h has the following structure:

typedef struct mdp_superblock_s {
 /*
 * Constant generic information
 */
 __u32 md_magic; /* 0 MD identifier */
 __u32 major_version; /* 1 major version to which the set conforms */
 __u32 minor_version; /* 2 minor version ... */
 __u32 patch_version; /* 3 patchlevel version ... */
...
 /*
 * Disks information
 */
 mdp_disk_t disks[MD_SB_DISKS];

/*
 * Reserved
 */
 __u32 reserved[MD_SB_RESERVED_WORDS];

/*
 * Active descriptor
 */
 mdp_disk_t this_disk;

} mdp_super_t;


typedef struct mdp_device_descriptor_s {
 __u32 number; /* 0 Device number in the entire set */
 __u32 major; /* 1 Device major number */
 __u32 minor; /* 2 Device minor number */
 __u32 raid_disk; /* 3 The role of the device in the raid set */
 __u32 state; /* 4 Operational state */
 __u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5];
} mdp_disk_t;

So the state of the individual disks is in the state field of the mdp_disk_t structure. Let’s check the dump and interpret it:

mdp_super_t:
------------
 0000 A9 2B 4E FC 00 00 00 00 00 00 00 5A 00 00 00 00
 0010 00 00 00 00 5B 11 6F C2 38 6D 43 82 00 00 00 01
 0020 00 25 FF 40 00 00 00 01 00 00 00 02 00 00 00 00
 0030 00 00 00 00 26 7B 24 2B 30 17 A5 A8 C8 66 10 BE
 0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0080 64 08 B7 03 00 00 00 01 00 00 00 01 00 00 00 01
 0090 00 00 00 00 00 00 00 00 C1 53 9A 6F 00 00 00 00
 00A0 00 C1 03 17 00 00 00 00 00 C1 03 17 FF FF FF FF
 00B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 01D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 01E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 01F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0210 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00
 0220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

mdp_disk_t disks[MD_SB_DISKS];
 0280 00 00 00 01 00 00 00 08 00 00 00 11 00 00 00 01
 0290 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00
 02A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 02B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 02C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 02D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 02E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 02F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0370 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0380 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0390 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 03A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 03B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 03C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 03D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 03E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 03F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0420 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0430 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0440 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0450 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0460 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0470 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0480 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0490 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 04A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 04B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 04C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 04D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 04E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 04F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0500 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0510 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0520 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0530 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0540 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0550 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0560 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0570 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0580 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0590 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 05A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 05B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 05C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 05D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 05E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 05F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0600 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0610 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0620 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0630 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0640 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0650 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0660 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0670 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0680 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0690 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 06A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 06B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 06C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 06D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 06E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 06F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0700 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0710 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0720 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0730 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0740 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0750 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0760 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0770 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0780 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0790 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 07A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 07B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 07C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 07D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 07E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 07F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0800 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0810 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0820 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0830 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0840 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0850 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0860 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0870 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0880 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0890 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 08A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 08B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 08C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 08D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 08E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 08F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0900 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0910 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0920 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0930 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0940 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0950 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0960 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0970 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0980 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0990 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 09A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 09B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 09C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 09D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 09E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 09F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0A90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0AA0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0AB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0AC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0AD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0AE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0AF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0B90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0BA0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0BB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0BC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0BD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0BE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0BF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0C90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0CA0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0CB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0CC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0CD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0CE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0CF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0D90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0DA0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0DB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0DC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0DD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0DE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0DF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0E90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0EA0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0EB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0EC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0ED0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0EE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0EF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0F00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0F10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0F20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0F30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0F40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0F50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0F60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0F70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

mdp_disk_t this_disk;
 0F80 00 00 00 01 00 00 00 08 00 00 00 11 00 00 00 01
 0F90 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00
 0FA0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0FB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0FC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0FD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0FE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 0FF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

I marked the significant fields in the dump. It can be seen that the state flag is 0x46 (that is 1000110b) which indicates: 

#define MD_DISK_FAULTY 0 
#define MD_DISK_ACTIVE 1 
#define MD_DISK_SYNC 2 
#define MD_DISK_REMOVED 3 
#define MD_DISK_CLUSTER_ADD 4 
#define MD_DISK_CANDIDATE 5
#define MD_DISK_ERROR 6 

#define MD_DISK_WRITEMOSTLY 9 
#define MD_DISK_JOURNAL 18

Bingo, there it is, MD_DISK_ERROR! So I was temtped to just remove the flag with a Hex editor, but beware: There is a checksum for the superblock header! So what’s the easiest thing to do?
First, check if Synology’s mdadm fork contained functions to maybe already clear the error flag. There must be a custom implementation, because it is able to display the E flag.
Turns out, there is no such function, so I had to extend the mdadm source code to introduce such a feature.

So, in short, I forked mdadm and implemented it, it can be downlaoded here together with a description on how to use it, so read the README there for a continuation of this story.

In short, I cleared the errorflag of the partition with my patched mdadm:

./mdadm.synology --misc --no-diskerr /dev/sdb1 -e 0.9

and put the disk back in the Synology, booted up, repaired system partition and got back a running system without having to reinstall the Synology DSM Software and its settings.

 

Leave a Comment

Name:

E-Mail :

Subscribe :
Website :

Comments :