r/linuxadmin • • Dec 23 '25

Help Requested: NAS failure, attempting data recovery

Background: I have an ancient QNAP TS-412 (MDADM based) that I should have replaced a long time ago, but alas here we are. I had 2 3TB WD RedPlus drives in RAID1 mirror (sda and sdd).

I bought 2 more identical disks. I put them both in and formatted them. I added disk 2 (sdb) and migrated to RAID5. Migration completed successfully.

I then added disk 3 (sdc) and attempted to migrate to RAID6. This failed. Logs say I/O error and medium error. Device is stuck in self-recovery loop and my only access is via (very slow) ssh. Web App hangs do to cpu pinning.

Here is a confusing part; mdstat reports the following:

RAID6 sdc3[3] sda3[0] with [4/2] and [U__U]

RAID5 sdb2[3] sdd2[1] with [3/2] and [_UU]

So the original RAID1 was sda and sdd, the interim RAID5 was sda, sdb, and sdd. So the migration sucessfully moved sda to the new array before sdc caused the failure? I'm okay with linux but not at this level and not with this package.

***KEY QUESTION: Could I take these out of the Qnap and mount them on my debian machine and rebuild the RAID5 manually?

Is there anyone that knows this well? Any insights or links to resources would be helpful. Here is the actual mdstat output:

[~] # cat /proc/mdstat

Personalities : [raid1] [linear] [raid0] [raid10] [raid6] [raid5] [raid4]

md3 : active raid6 sdc3[3] sda3[0]

     5857394560 blocks super 1.0 level 6, 64k chunk, algorithm 2 \[4/2\] \[U__U\]

md0 : active raid5 sdd3[3] sdb3[1]

     5857394816 blocks super 1.0 level 5, 64k chunk, algorithm 2 \[3/2\] \[_UU\]

md4 : active raid1 sdb2[3](S) sdd2[2] sda2[0]

     530128 blocks super 1.0 \[2/2\] \[UU\]

md13 : active raid1 sdc4[2] sdb4[1] sda4[0] sdd4[3]

     458880 blocks \[4/4\] \[UUUU\]

     bitmap: 0/57 pages \[0KB\], 4KB chunk

md9 : active raid1 sdc1[4](F) sdb1[1] sda1[0] sdd1[3]

     530048 blocks \[4/3\] \[UU_U\]

     bitmap: 27/65 pages \[108KB\], 4KB chunk

unused devices: <none>

5 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/michaelpaoli Dec 25 '25

u/aviator_60

FYI, if I do a md raid5 --> raid6 conversion, and crash it part way through:

# (cd /sys/block && grep . sd[a-d]/size)
sda/size:6291456
sdb/size:6291456
sdc/size:6291456
sdd/size:6291456
# mdadm --create /dev/md5 --level=5 --raid-devices=3 /dev/sd[abc]
To optimalize recovery speed, it is recommended to enable write-indent bitmap, do you want to enable it now? [y/N]? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.
# cat /sys/block/md5/size
12570624
# factor 12570624
12570624: 2 2 2 2 2 2 2 2 2 2 2 2 3 3 11 31
# expr 512 \* 1024 \* 4; expr 3 \* 3 \* 11 \* 31
2097152
3069
# dd bs=2097152 count=3069 if=/dev/random of=/dev/md5
3069+0 records in
3069+0 records out
6436159488 bytes (6.4 GB, 6.0 GiB) copied, 38.7904 s, 166 MB/s
# t=$(mktemp -d /var/tmp/r526.XXXXXXXXXX) && cd $t
# sha512sum < /dev/md5 | awk '{print $1;}' > sha512sum && cat sha512sum
7e16d596801332ee4d8fc497822af74bdbc74eb5b9721bccefdd786b0b5123a08531c80c9b0895b2d16b0a1de06355cbff6cac482ba9c67b7afebbddfbd5aa30
# cd / && mdadm --grow /dev/md5 --add /dev/sdd --level=6 --raid-devices=4 --backup-file=$t/backup-file
mdadm: level of /dev/md5 changed to raid6
mdadm: added /dev/sdd
# poweroff -d -f -f -n
Powering off.

And after reboot, we have (I'll add some comments on lines starting with //):

# t=$(dirname /var/tmp/*526.*/sha512sum)
# < /proc/mdstat sed -ne '/^Personalities :/d;/^unused devices: /d;s/^  *$//;/^$/{x;s/\n/ /g;s/^  *//;s/  *$//;s/   */ /g;/./p;d};H' | sort -k 1.3n
md127 : inactive sdb[1](S) sda[4](S) sdc[3](S) sdd[5](S) 12570624 blocks super 1.2
# grep '^[^#]' /etc/mdadm/mdadm.conf
HOMEHOST <system>
MAILADDR root
# 
// I didn't configure that file, so it defaulted to md127 on boot
# mdadm --detail /dev/md127 | sed -ne '3,4p;7{p;q}'
        Raid Level : raid6
     Total Devices : 4
             State : inactive
# (for d in /dev/sd[a-d]; do mdadm --examine "$d" | fgrep Reshape; done)
  Reshape pos'n : 1401856 (1369.00 MiB 1435.50 MB)
  Reshape pos'n : 1401856 (1369.00 MiB 1435.50 MB)
  Reshape pos'n : 1401856 (1369.00 MiB 1435.50 MB)
  Reshape pos'n : 1401856 (1369.00 MiB 1435.50 MB)
# 
// That's why inactive - reshape was in progress.
// Let's get closer to OP's scenario, and effectively remove 2 drives,
// the original first in sequence and last added in sequence
// my a and d, OP's a and c.
# mdadm --stop /dev/md127
mdadm: stopped /dev/md127
// after trying some bit, some resaerch, etc, came up with:
# mdadm --assemble --run /dev/md6 /dev/sd[bc] --invalid-backup --backup-file=$t/backup-file
mdadm: /dev/md6 has been started with 2 drives (out of 4).
# 
// after a bit, it completed the reshape, but still degraded: 
# < /proc/mdstat sed -ne '/^Personalities :/d;/^unused devices: /d;s/^  *$//;/^$/{x;s/\n/ /g;s/^  *//;s/  *$//;s/   */ /g;/./p;d};H' | sort -k 1.3n
md6 : active raid6 sdb[1] sdc[3] 6285312 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/2] [_UU_] bitmap: 0/1 pages [0KB], 65536KB chunk
# sha512sum < /dev/md6 | awk '{print $1}' | cmp - $t/sha512sum
  • /var/tmp/r526.KC5CmVqsZB/sha512sum differ: char 1, line 1
# // Alas, we do have at least some data corruption - not a 100% match // I haven't investigated to see how much data was impacted, but each time I've found the data didn't (quite?) match

Anyway, can test stuff like this, e.g. on VMs, utilize loopback devices, sparse files (though they may quickly balloon as data is written, etc.). I commonly figure out "solution" by such testing, before applying it "for real". Alas, this case, not quite 100%. May also have to adjust based upon, e.g. applicable version of md and array metadata, etc.