1

So, during a recent dnf update on my system, apparently according to the system logs at some point selinux suddenly disallowed write access to the kernel and it then marked the raid drive as "Failed".

I got the system back running by taking the raid drive in question out of fstab, (I'd rebooted, since there was a new kernel, and didn't know that the raid drive had suddenly ceased to function).

So, everything looks fine but the raid drive will not "start", and so I I did a

for x in a b c d e f; do 
    mdadm --examine /dev/sd${x}1 > mdstats.$x; 
    done

and then looked at the state of each of the raid elements in the mdstats.x files. This was actually good news, as all the devices were marked as "Clean", and all had the exact same number of "events".

Looking at the state of the raid device, from the command line, I did

% cat /proc/mdstat
Personalities : 
md127 : inactive sdf1[3] sde1[0] sda1[6] sdb1[5] sdd1[1] sdc1[4]
      17581198678 blocks super 1.2
       
unused devices: <none>

And I'll include two of the mdadm --examine outputs, in case I've missed something, but they all look similar,

  % mdadm --examine /dev/sda1
/dev/sda1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x1
     Array UUID : e90d6691:7ad14e07:68ee7f2a:f5bbcfbc
           Name : LostCreek:0
  Creation Time : Wed Mar 25 11:56:03 2020
     Raid Level : raid6
   Raid Devices : 6

 Avail Dev Size : 5860399104 sectors (2.73 TiB 3.00 TB)
     Array Size : 11720531968 KiB (10.92 TiB 12.00 TB)
  Used Dev Size : 5860265984 sectors (2.73 TiB 3.00 TB)
    Data Offset : 131072 sectors
   Super Offset : 8 sectors
   Unused Space : before=130992 sectors, after=133120 sectors
          State : clean
    Device UUID : 100e1983:e323daa4:a28faf75:68afde64

Internal Bitmap : 8 sectors from superblock
    Update Time : Fri Aug  5 03:45:48 2022
  Bad Block Log : 512 entries available at offset 24 sectors
       Checksum : f6f4c925 - correct
         Events : 128119

         Layout : left-symmetric
     Chunk Size : 512K

   Device Role : Active device 3
   Array State : AAAAAA ('A' == active, '.' == missing, 'R' == replacing)

and for comparison:

   % mdadm --examine /dev/sdf1
/dev/sdf1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x1
     Array UUID : e90d6691:7ad14e07:68ee7f2a:f5bbcfbc
           Name : LostCreek:0
  Creation Time : Wed Mar 25 11:56:03 2020
     Raid Level : raid6
   Raid Devices : 6

 Avail Dev Size : 5860400015 sectors (2.73 TiB 3.00 TB)
     Array Size : 11720531968 KiB (10.92 TiB 12.00 TB)
  Used Dev Size : 5860265984 sectors (2.73 TiB 3.00 TB)
    Data Offset : 131072 sectors
   Super Offset : 8 sectors
   Unused Space : before=130992 sectors, after=134031 sectors
          State : clean
    Device UUID : 8a99c085:51469860:99f42094:5dea9904

Internal Bitmap : 8 sectors from superblock
    Update Time : Fri Aug  5 03:45:48 2022
  Bad Block Log : 512 entries available at offset 24 sectors
       Checksum : 73871a85 - correct
         Events : 128119

         Layout: left-symmetric
     Chunk Size : 512K

   Device Role : Active device 2
   Array State : AAAAAA ('A' == active, '.' == missing, 'R' == replacing)

And in these, the only lines that vary between all 6 devices are

 1. /dev/sda1 
 11. Avail Dev Size
 16. Unused Space
 18. Device UUID : 100e1983:e323daa4:a28faf75:68afde64
 23. Checksum : f6f4c925 - correct
 29. Device Role : Active device 3

The leading numbers are the line numbers of the files created with the for loop at the top of this post, obtained via a

   vimdiff mdstat.?

The "update time", "events", etc all match. The device role lines (last item noted as different) are all different, and go from to 0 to 5.

This all looks like it should work, but after much google searching, I believe I will need to get it back to functional with the following command.

mdadm --create /dev/md127 --level=6 --raid-devices=6 --chunk=512 --name=LostCreek:0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 --assume-clean

This is from, in part, the question/answer of MDADM - Disaster recovery or move on.. and mdadm-re-added-disk-treated-as-spare.

I am about to try this, but wanted to see if I'm missing anything. I also don't see any similar issue where there was no actual failed drive, but simply selinux "keeping me save" by stopping a write in the software raid. (I had selinux at "permissive", and thought I was safe, but now I'm at "disabled").

Hopefully this will be useful to others, especially if it "just works". The issues seems sufficiently rare that I expect to answer my own question, but I'd really rather not have to restore the whole raid from a backup over a month old. (and yes, as always, I should have more frequent backups, but losing it won't be the end of the world, thankfully).

Cheers

Mike

Schatzi
  • 81
  • 7
  • not a fan of selinux for such reasons. dmesg / kernel messages from assembly attempt? if there is really nothing in examine then that's strange. see also [my answer on mdadm create](https://unix.stackexchange.com/a/131927/30851), do use overlays for such experiments if possible – frostschutz Aug 06 '22 at 18:56
  • frostschutz, that post is exactly the sort of information I was looking for. I'm now in the process of digging in to that, which clarified much of what I thought was going on, and also added information that will make this much more likely to end without tears. I do generally end up with selinux disabled on systems after I've lived with them a while, and that is the state this one is going to be in till I can figure out exactly how that disallowed write occured. Much, much thanks! – Schatzi Aug 06 '22 at 19:07
  • 1
    And now, things just went south. Found out as I was playing around that there were no modules for raid 6 in the kernel I was running, and the actual issue was that the upgrade did not go well. I rebooted into a kernel 2 updates back, and voila, the /dev/md127 was there, and "active" via /proc/mdstat. I thought all was well, so I cleaned up all the kernel installs, and got back to the latest kernel, and the array is running there, but the indiviual mdadm --examine info is different. I'm guessing it re-assembled the array, but didn't keep the original info. Now trying to assess what next – Schatzi Aug 06 '22 at 21:06
  • At this point, I don't think I can make things worse, so I'm going to try recreate the array with a --create , a correct --size, and the order given by the "Role" number. I haven't tried to do anything with the new /dev/md127, but I'm not sure it didn't overwrite things as it was reassmbling the thing, or when I tried to reboot the "just previous" kernel, and it was doing something for a long time, then ending up not able to boot. – Schatzi Aug 06 '22 at 21:34
  • Oh right, I missed that one (that your /proc/mdstat had empty `Personalities` — very odd). – frostschutz Aug 07 '22 at 01:33
  • So it seems the raid modules are missing. `journalctl -b`? – U. Windl Aug 19 '22 at 00:39
  • There was much that happened during that update gone wrong, and I'm still finding issues that occurred then. The loss of the raid was only one. By the time I'd gotten this system back, the logs had "rotated" past that date, and now it's lost to the bit bucket, as far as I can tell. But the modules came back as soon as the kernels were successfully re-installed. – Schatzi Aug 23 '22 at 21:25

1 Answers1

1

Woo Hoo!, and I do mean WOOHOO!

It's back! And frostchutz, if I can buy you a beer, or dinner at some point, I would love to do that!

See my comments above for how things progressed, but using frostshutz's answer, and what I had from the mdadm --examine, I did the following, and it's currently back!

The commands, with the addition of a --size, and putting the devices in the order specified by the "Role" line of the mdadm --examine output, is

mdadm --stop /dev/md127

mdadm --create /dev/md42 --assume-clean \
    --level=6 --chunk=512K --metadata=1.2 --data-offset=131072s \
    --size=2930132992K \
    --raid-devices=6 /dev/sde1 /dev/sdd1 /dev/sdf1 /dev/sda1 /dev/sdb1 /dev/sdc1

The raid that had the wrong info was in md127, and /dev/md42 I was hoping would be the raid device I had before all these gyrations. This raid device is an encrytped disk, which is then formatted on top of that. I looked at the mdadm --examine bits (using the same for loop) and compared with what I had before, and it was golden, or seemed to be. The "Role", size, etc, now matched up. There were no "events", obviously, but it looked as good as I could have expected to find. So then, the moment of truth

cryptsetup luksOpen /dev/md42 woot

and lo and behold I have a /dev/mapper/woot device. It mounts, and all is good in the world.

Much, much thanks. Would not have been able to get to this point without frostschutz's very clear description of how to do this. I'm so jazzed! I'm so starting the new backup.

Schatzi
  • 81
  • 7